[fpc-devel] How to call (access) to an external procedure!

Amir Aavani Aavani at iust.ac.ir
Tue Jan 31 07:35:27 CET 2006


dear friends,
I know that if want to use an external variable/procedure in fpc, i 
should use the following code:

function GetEnvironment (const Name: PChar): PChar; cdecl; external 'c' 
name 'getenv';

but how could i add for example  GetEnvironment function to a class 
(TEnvironment)!
Is there any good (OO) way?

Is it a good idea to use a following method:

TGetEnvironmentFunction= function : PChar;
TEnvironment= class (TObject)
private
  ...
public
  GetEnvironment: TGetEnvironment;
  procedure SetGetEnvironmentFunction (AFunction: TGetEnvironmentFunction);
  ...
end;

procedure TEnvironment.SetGetEnvironmentFunction (AFunction: 
TGetEnvironmentFunction);
begin
  GetEnvironment:= AFunction;
end;






More information about the fpc-devel mailing list