FastFieldSolvers Forum
FastFieldSolvers Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
 All Forums
 FastFieldSolvers
 FasterCap and FastCap2
 Automation with Pascal
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

LarsSteffens

4 Posts

Posted - Feb 18 2009 :  16:36:04  Show Profile  Reply with Quote
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();

// ...

Enrico

550 Posts

Posted - Feb 18 2009 :  23:50:31  Show Profile  Reply with Quote
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.
Go to Top of Page

LarsSteffens

4 Posts

Posted - Feb 24 2009 :  16:13:29  Show Profile  Reply with Quote
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;


// ...

Edited by - LarsSteffens on Feb 24 2009 16:14:17
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
FastFieldSolvers Forum © 2020 FastFieldSolvers S.R.L. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.06