<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-NZ link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>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 <u>with</u> is more relevant (i.e. what some other function “sees” ProgramName as containing.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>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.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Demonstration:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>var<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> s: String;<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> msg: String;<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>begin<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> s := 'hat'#0; // < the null char is part of the string (in addition to the null char marking the END of the string<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> msg := 'That''s a nice ' + s + ' you are wearing';<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> ShowMessage('Length of message = ' + IntToStr(Length(msg)) + ' chars');<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> ShowMessage(msg);<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>end;<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> delphi-bounces@delphi.org.nz [mailto:delphi-bounces@delphi.org.nz] <b>On Behalf Of </b>Bob Pawley<br><b>Sent:</b> Monday, 27 June 2011 05:56<br><b>To:</b> 'NZ Borland Developers Group - Delphi List'<br><b>Subject:</b> Re: [DUG] Variable in String<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><div><div><p class=MsoNormal><span style='color:#00002B'>Hi Jolyon<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#00002B'> <o:p></o:p></span></p></div><div><div><p class=MsoNormal><span style='color:#00002B'>Double quoting the path doesn’t seem to work. </span><span style='font-size:10.0pt;font-family:"Courier New";color:#00002B'>ProgramName := ‘”’ + FW_Path + '\FWTools2.4.7\bin\ogr2ogr” "-f" "PostgreSQL" PG:"host=192........ user=postgres dbname=E5R password=........" "'+ DXF +'" -nln Import_Process';</span><span style='font-family:"Calibri","sans-serif";color:black'><o:p></o:p></span></p></div></div><div><div><p class=MsoNormal><span style='font-family:"Calibri","sans-serif";color:black'> <o:p></o:p></span></p></div></div><div><div><p class=MsoNormal><span style='color:#00002B'>All that ProgramName sees is the string variable FW_Path. Even with the +, all of the remaining string is ignored.</span><span style='font-family:"Calibri","sans-serif";color:black'><o:p></o:p></span></p></div></div><div><div><p class=MsoNormal><span style='font-family:"Calibri","sans-serif";color:black'> <o:p></o:p></span></p></div></div><div><div><p class=MsoNormal><span style='color:#00002B'>Bob</span><span style='font-family:"Calibri","sans-serif";color:black'><o:p></o:p></span></p></div></div><div><div><p class=MsoNormal><span style='font-family:"Calibri","sans-serif";color:black'> <o:p></o:p></span></p></div></div><div><div><p class=MsoNormal><span style='font-family:"Calibri","sans-serif";color:black'> <o:p></o:p></span></p></div></div><div><div><p class=MsoNormal><span style='font-family:"Calibri","sans-serif";color:black'> <o:p></o:p></span></p></div><div><div><div><p class=MsoNormal style='background:whitesmoke'><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:#00002B'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:#00002B'> <a href="mailto:jsmith@deltics.co.nz" title="jsmith@deltics.co.nz">Jolyon Smith</a> <o:p></o:p></span></p></div><div><p class=MsoNormal style='background:whitesmoke'><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:#00002B'>Sent:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:#00002B'> Wednesday, June 22, 2011 3:49 PM<o:p></o:p></span></p></div><div><p class=MsoNormal style='background:whitesmoke'><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:#00002B'>To:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:#00002B'> <a href="mailto:delphi@delphi.org.nz" title="delphi@delphi.org.nz">'NZ Borland Developers Group - Delphi List'</a> <o:p></o:p></span></p></div><div><p class=MsoNormal style='background:whitesmoke'><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:#00002B'>Subject:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:#00002B'> Re: [DUG] Variable in String<o:p></o:p></span></p></div></div></div><div><p class=MsoNormal><span style='color:#00002B'> <o:p></o:p></span></p></div></div><div><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Don’t quote FW_Path element of the program path – you need to quote the <u>entire</u> path AND program file name when/if any <u>part</u> of the path or the filename itself does – or may – contain spaces:<o:p></o:p></span></p><p class=MsoNormal><span style='color:black'> </span><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>e.g. “path a\sub a\sub b\prog.exe”<o:p></o:p></span></p><p class=MsoNormal><span style='color:black'> </span><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal><u><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>not</span></u><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> “path a”\sub\prog.exe<o:p></o:p></span></p><p class=MsoNormal><span style='color:black'> </span><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal><span style='color:black'> </span><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>So in your case, this should do the trick:<o:p></o:p></span></p><p class=MsoNormal><span style='color:black'> </span><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New";color:#00002B'> FW_Path := X; <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New";color:#00002B'> DXF := openDialog1.FileName; <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New";color:#00002B'> ProgramName := ‘”’ + FW_Path + '\FWTools2.4.7\bin\ogr2ogr” "-f" "PostgreSQL" PG:"host=192........ user=postgres dbname=E5R password=........" "'+ DXF +'" -nln Import_Process';<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New";color:#00002B'> ShowMessage(ProgramName);<o:p></o:p></span></p><p class=MsoNormal><span style='color:black'> </span><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal><span style='color:black'> </span><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>hth<o:p></o:p></span></p><p class=MsoNormal><span style='color:black'> </span><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p></o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black'> delphi-bounces@delphi.org.nz [mailto:delphi-bounces@delphi.org.nz] <b>On Behalf Of </b>Bob Pawley<br><b>Sent:</b> Thursday, 23 June 2011 10:30<br><b>To:</b> DUG<br><b>Subject:</b> [DUG] Variable in String<o:p></o:p></span></p></div></div><p class=MsoNormal><span style='color:black'> <o:p></o:p></span></p><div><div><div><p class=MsoNormal><span style='color:#00002B'>Hi<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#00002B'> <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#00002B'>I’m having trouble with using a variable in a string path.<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#00002B'> <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#00002B'>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 .<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#00002B'> <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#00002B'>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. <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#00002B'> <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#00002B'>I attempted Quote String and got the following ‘C:\Program Files (x86) with one single quote.<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#00002B'> <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#00002B'>Both cases return the same error - and in both cases ShowMessage(ProgramName); displayed none of the path after C:\Program Files (x86).<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#00002B'> <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#00002B'>Help would be appreciated.<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#00002B'> <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#00002B'>Bob<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#00002B'> <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#00002B'> FW_Path := QuoteStr(X); <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#00002B'> DXF := openDialog1.FileName; <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#00002B'> ProgramName :=FW_Path+'\FWTools2.4.7\bin\ogr2ogr "-f" "PostgreSQL" PG:"host=192........ user=postgres dbname=E5R password=........" "'+ DXF +'" -nln Import_Process';<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='color:#00002B'> ShowMessage(ProgramName);<o:p></o:p></span></p></div></div></div><div class=MsoNormal align=center style='text-align:center'><span style='font-family:"Calibri","sans-serif";color:black'><hr size=2 width="100%" align=center></span></div><p class=MsoNormal><span style='font-family:"Calibri","sans-serif";color:black'>_______________________________________________<br>NZ Borland Developers Group - Delphi mailing list<br>Post: delphi@delphi.org.nz<br>Admin: http://delphi.org.nz/mailman/listinfo/delphi<br>Unsubscribe: send an email to delphi-request@delphi.org.nz with Subject: unsubscribe<o:p></o:p></span></p></div></div></div></div></body></html>