<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Thanks Geno <br>
that works, but could you tell me what should i do for an external
variable,<br>
var environ: ppchar; cvar; external;<br>
<br>
<br>
Geno Roupsky wrote:
<blockquote cite="mid1138692471.11357.4.camel@jeni" type="cite">
<pre wrap="">This particular function could be declared as this:
TEnvironment = class
public
class function GetEnvironment(const Name: PChar): PChar; cdecl;
end;
class function GetEnvironment(const Name: PChar): PChar; cdecl; external
'c' name 'getenv';
</pre>
</blockquote>
function TEnvironment.GetEnvironment(const Name: PChar): PChar;
cdecl; external<br>
'c' name 'getenv';
<blockquote cite="mid1138692471.11357.4.camel@jeni" type="cite">
<pre wrap="">
Of course this is not very useful but the idea for methods is this. Just
keep in mind that methods have a hidden parameter Self pointing to the
object. When method is declared as cdecl it is the first parameter.
Tia,
Geno Roupsky
В вт, 2006-01-31 в 10:05 +0330, Amir Aavani написа:
</pre>
<blockquote type="cite">
<pre wrap="">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;
_______________________________________________
fpc-devel maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freepascal.org/mailman/listinfo/fpc-devel">http://lists.freepascal.org/mailman/listinfo/fpc-devel</a>
</pre>
</blockquote>
<pre wrap=""><!---->
_______________________________________________
fpc-devel maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freepascal.org/mailman/listinfo/fpc-devel">http://lists.freepascal.org/mailman/listinfo/fpc-devel</a>
</pre>
</blockquote>
<br>
</body>
</html>