Thank You for your response Wily. 

 

I'm using FreePascal - latest. (Not using lazarus for this project)

I'm developing for both windows and linux primarily.

The function "GetEnvironmentVariable('namehere')" I was not aware of. I will
see if that works in FreePascal. Kylix I've heard of but I don't think I'm
using that.

 

To my knowledge the other functions I mentioned "call the Os for you" also,
they just cap the string length. I'm happy there might be a nice alternative
you mentioned. Thank you - and I'll look into this! 

 

From: Wily Dev [mailto:wily...@optonline.net] 
Sent: Friday, August 14, 2009 10:54 AM
To: Ararat Synapse
Subject: Re: [Synalist] CGI Blues...

 

Jason,

 

I'm not exactly clear on a few things, including which "getenv," (just
referring to Linux here, right?)  which Delphi (?) you're using, etc.,  but
couldn't you use Delphi's and Kylix's built-in GetEnvironmentVariable(Name :
string) : string   function?  which calls the appropriate OS code
automatically for you?  (Nicely implemented in D7's SysUtils...  which I'm
looking at now. )

 

Or barring that, one can always use the Windows API functions
GetEnvironmentStrings, GetEnvironmentVariable ...

 

 

Seems quite easy to use the built-ins.  Here's the D7 version:

 

{$IFDEF MSWINDOWS}
function GetEnvironmentVariable(const Name: string): string;
const
  BufSize = 1024;
var
  Len: Integer;
  Buffer: array[0..BufSize - 1] of Char;
begin
  Result := '';
  Len := GetEnvironmentVariable(PChar(Name), @Buffer, BufSize);
  if Len < BufSize then
    SetString(Result, PChar(@Buffer), Len)
  else
  begin
    SetLength(Result, Len - 1);
    GetEnvironmentVariable(PChar(Name), PChar(Result), Len);
  end;
end;
{$ENDIF}
{$IFDEF LINUX}
function GetEnvironmentVariable(const Name: string): string;
begin
  Result := getenv(PChar(Name));
end;
{$ENDIF}

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
synalist-public mailing list
synalist-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synalist-public

Reply via email to