| T O P I C R E V I E W |
| LarsSteffens |
Posted - Feb 18 2009 : 16:36:04 I am trying to run FastCap from a Pascal program (listed below). The program works fine for starting FastCap. But i am not able to get the capacitance with the GetCapacitance command, as i don't know the correct type of the result. Does anybody knows what result type the GetCapacitance function has? Thanks
var Capacitance: variant; begin
// ....
try Server := CreateOleObject(ServerName); except WriteLn('Unable to start FastCap2'); Exit; end; writeln(Server.Run('"C:\Programme\FastFieldSolvers\Fastcap2\Samples\Automation\Office\sphere1.qui"')); Server.ShowWindow();
while Server.IsRunning() do begin Delay(1000); end;
try Capacitance:=Server.GetCapacitance(); except writeln('Error!!') end;
Server.Stop(); Server.Quit();
// ... |
| 2 L A T E S T R E P L I E S (Newest First) |
| LarsSteffens |
Posted - Feb 24 2009 : 16:13:29 In order to complete this topic i post the respective part of my finally working program. Compiled with Free Pascal 2.2.2
// ...
$IFDEF FPC} {$MODE Delphi} {$ELSE} {$APPTYPE CONSOLE} {$ENDIF}
uses SysUtils, Variants, ComObj, Crt;
const ServerName = 'FastCap2.Document';
type TCapacitance = OleVariant;
function GetFCCapacitance() : TCapacitance; var Server : Variant; Capacitance : OleVariant; CapVariant : Pointer;
begin if Assigned(InitProc) then TProcedure(InitProc);
try Server := CreateOleObject(ServerName); WriteLn('Started FastCap2.'); except WriteLn('Could not start FastCap2.'); Exit; end; Server.Run('"C:\FastFieldSolvers\Fastcap2\Samples\Automation\Office\sphere1.qui"'); // Or any other input file writeln('FastCap is running ...');
//Server.ShowWindow();
while Server.IsRunning() do begin Delay(1000); end;
try // CondNames:=Server.GetCondNames(); Capacitance:=Server.GetCapacitance(); CapVariant:= VarArrayLock(Capacitance); //writeln(VarArrayHighBound(Capacitance,1)); //writeln(VarArrayHighBound(Capacitance,2)); VarArrayUnLock(Capacitance); //writeln(Capacitance[0,0]); Result := Capacitance; except writeln('Failed to receive data from FastCap !!'); end;
Server.Stop(); Server.Quit();
writeln('Quit FastCap');
end;
// ...
|
| Enrico |
Posted - Feb 18 2009 : 23:50:31 I guess you checked on-line help? (see below)
Return Value The method returns a 2-dimensional safe-array encapsulated in a variant data. The array contains the capacitance matrix as calculated by FastCap, in Farads. The first dimension of the array is the row index, the second is the column index.
Notes: The array dimensions can be queried from the safe array itself, see the 'safe array' topic in the MS Automation documentation. |
|
|