There isn’t really enough information to go on here to say for sure what your problem is. “ProgramName” doesn’t “see” anything. What you use ProgramName with is more relevant (i.e. what some other function “sees” ProgramName as containing.
If the value of FW_Path contains a null character and if the function you pass ProgramName to is dealing with null terminated strings, then it will consider the value of the string to be terminated by that null char, regardless of the actual length of the string. Demonstration: var s: String; msg: String; begin s := 'hat'#0; // < the null char is part of the string (in addition to the null char marking the END of the string msg := 'That''s a nice ' + s + ' you are wearing'; ShowMessage('Length of message = ' + IntToStr(Length(msg)) + ' chars'); ShowMessage(msg); end; From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On Behalf Of Bob Pawley Sent: Monday, 27 June 2011 05:56 To: 'NZ Borland Developers Group - Delphi List' Subject: Re: [DUG] Variable in String Hi Jolyon Double quoting the path doesn’t seem to work. ProgramName := ‘”’ + FW_Path + '\FWTools2.4.7\bin\ogr2ogr” "-f" "PostgreSQL" PG:"host=192........ user=postgres dbname=E5R password=........" "'+ DXF +'" -nln Import_Process'; All that ProgramName sees is the string variable FW_Path. Even with the +, all of the remaining string is ignored. Bob From: Jolyon Smith <mailto:jsm...@deltics.co.nz> Sent: Wednesday, June 22, 2011 3:49 PM To: 'NZ Borland Developers Group - Delphi List' <mailto:delphi@delphi.org.nz> Subject: Re: [DUG] Variable in String Don’t quote FW_Path element of the program path – you need to quote the entire path AND program file name when/if any part of the path or the filename itself does – or may – contain spaces: e.g. “path a\sub a\sub b\prog.exe” not “path a”\sub\prog.exe So in your case, this should do the trick: FW_Path := X; DXF := openDialog1.FileName; ProgramName := ‘”’ + FW_Path + '\FWTools2.4.7\bin\ogr2ogr” "-f" "PostgreSQL" PG:"host=192........ user=postgres dbname=E5R password=........" "'+ DXF +'" -nln Import_Process'; ShowMessage(ProgramName); hth From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On Behalf Of Bob Pawley Sent: Thursday, 23 June 2011 10:30 To: DUG Subject: [DUG] Variable in String Hi I’m having trouble with using a variable in a string path. When I use the variable FW_Path := ‘C:\Program Files (x86)’ with two single quotes, the following works well and ShowMessage(ProgramName); displayed the full path . When I reference FW_Path to a variable X I get an error returned “Can Not run....” The variable X is returned as C:\Program Files (x86) without quotes. I attempted Quote String and got the following ‘C:\Program Files (x86) with one single quote. Both cases return the same error - and in both cases ShowMessage(ProgramName); displayed none of the path after C:\Program Files (x86). Help would be appreciated. Bob FW_Path := QuoteStr(X); DXF := openDialog1.FileName; ProgramName :=FW_Path+'\FWTools2.4.7\bin\ogr2ogr "-f" "PostgreSQL" PG:"host=192........ user=postgres dbname=E5R password=........" "'+ DXF +'" -nln Import_Process'; ShowMessage(ProgramName); _____ _______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe
_______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe