<HTML xmlns="http://www.w3.org/TR/REC-html40" 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"><HEAD>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<META name=Generator content="Microsoft Word 12 (filtered medium)">
<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;}
span.EmailStyle17
        {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>
</HEAD>
<BODY dir=ltr lang=EN-NZ link=blue vLink=purple>
<DIV dir=ltr>
<DIV style="FONT-FAMILY: 'Times New Roman'; COLOR: #00002b; FONT-SIZE: 12pt">
<DIV>Hi Jolyon</DIV>
<DIV> </DIV>
<DIV>I was wondering if my problem is a conflict between how I derive the value
of the variable (PAnsiChar).</DIV>
<DIV> </DIV>
<DIV>Here is the code for doing that.</DIV>
<DIV> </DIV>
<DIV>SetLength(sDir, MAX_PATH);</DIV>
<DIV>ZeroMemory(@sDir[1], MAX_PATH);</DIV>
<DIV>if Succeeded(SHGetFolderPath(0, CSIDL_Program_Files, 0, 0,
PAnsiChar(sDir))) then</DIV>
<DIV>FW_Path := sDir;</DIV>
<DIV> </DIV>
<DIV>Bob</DIV>
<DIV
style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
<DIV style="FONT: 10pt tahoma">
<DIV> </DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A title=jsmith@deltics.co.nz
href="mailto:jsmith@deltics.co.nz">Jolyon Smith</A> </DIV>
<DIV><B>Sent:</B> Wednesday, June 22, 2011 3:49 PM</DIV>
<DIV><B>To:</B> <A title=delphi@delphi.org.nz
href="mailto:delphi@delphi.org.nz">'NZ Borland Developers Group - Delphi
List'</A> </DIV>
<DIV><B>Subject:</B> Re: [DUG] Variable in String</DIV></DIV></DIV>
<DIV> </DIV></DIV>
<DIV
style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
<DIV class=WordSection1>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt">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="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt"><o:p></o:p></SPAN> </P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt">e.g.
“path a\sub a\sub b\prog.exe”<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt"><o:p></o:p></SPAN> </P>
<P class=MsoNormal><U><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt">not</SPAN></U><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt">
“path a”\sub\prog.exe<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt"><o:p></o:p></SPAN> </P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt"><o:p></o:p></SPAN> </P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt">So
in your case, this should do the trick:<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt"><o:p></o:p></SPAN> </P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; COLOR: #00002b; FONT-SIZE: 10pt">
FW_Path := X; <o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; COLOR: #00002b; FONT-SIZE: 10pt">
DXF :=
openDialog1.FileName;
<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; COLOR: #00002b; FONT-SIZE: 10pt">
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-FAMILY: 'Courier New'; COLOR: #00002b; FONT-SIZE: 10pt">
ShowMessage(ProgramName);<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt"><o:p></o:p></SPAN> </P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt"><o:p></o:p></SPAN> </P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt">hth<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt"><o:p></o:p></SPAN> </P>
<DIV>
<DIV
style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 0cm; PADDING-RIGHT: 0cm; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<P class=MsoNormal><B><SPAN
style="FONT-FAMILY: 'Tahoma','sans-serif'; FONT-SIZE: 10pt"
lang=EN-US>From:</SPAN></B><SPAN
style="FONT-FAMILY: 'Tahoma','sans-serif'; FONT-SIZE: 10pt" lang=EN-US>
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><o:p></o:p> </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>
<P>
<HR>
_______________________________________________<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</DIV></DIV></DIV></BODY></HTML>