See code below. Can anyone tell me why I am getting rubbish characters (some of the time) in the result returned by Parse_CmdLine() Obviously a pointer is getting screwed up somewhere with the PChar conversions, so what is the correct way for me to place the string sParam value in the PChar propery of the record structure do for eg:
result.SQLServerInfo.ServerName := PChar(sParamValue);
TIA
type
TEmailInfo = record
EmailNotification : boolean;
SMTPSvr : PChar;
PeopleToNotify : array of PChar;
end;
TExportInfo = record
ActivePlayersOnly : boolean;
DestPath : PChar;
BaseDataExport : boolean;
GlobalMatchCode : PChar;
end;
TSQLServerInfo = record
ServerName : PChar;
DatabaseName : PChar;
UserName : PChar;
Password : PChar;
end;
TExportSessionSettings = record
LogToStdOut : boolean;
ProcessMessage : TProcessMessage;
EMailInfo : TEmailInfo;
ExportInfo : TExportInfo;
SQLServerInfo : TSQLServerInfo;
end;
function Parse_CmdLine : TExportSessionSettings;
var
iCount, iCount2 : SmallInt;
sParam, sParamValue : string;
begin
FillChar(result, SizeOf(result), 0);
//Iterate over the paramaters the user has supplied
for iCount := 1 to ParamCount do
begin
//Split the paramater into its bits
sParam := After('-', Before('=', ParamStr(iCount)));
sParamValue := After('=', ParamStr(iCount));
{snip}
//Destination Path
if UpperCase(sParam) = 'D' then
result.ExportInfo.DestPath := PChar(sParamValue);
//ServerName
if UpperCase(sParam) = 'SVR' then
result.SQLServerInfo.ServerName := PChar(sParamValue);
end;
end;
----------------------------------------------------------------------
Donovan J. Edye [www.edye.wattle.id.au]
Namadgi Systems [www.namsys.com.au]
Voice: +61 2 6285-3460
Fax: +61 2 6285-3459
TVisualBasic = Class(None);
Heard just before the 'Big Bang': "...Uh Oh...."
----------------------------------------------------------------------
GXExplorer [http://www.gxexplorer.org] Freeware Windows Explorer
replacement. Also includes freeware delphi windows explorer components.
----------------------------------------------------------------------