<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>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</STYLE>
<STYLE><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@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>
</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><SPAN>Hi Jolyon</SPAN></DIV>
<DIV><SPAN></SPAN> </DIV>
<DIV><SPAN>Works perfectly.</SPAN></DIV>
<DIV><SPAN></SPAN> </DIV>
<DIV><SPAN>Thanks a lot for all your help.</SPAN></DIV>
<DIV><SPAN></SPAN> </DIV>
<DIV><SPAN>Bob</SPAN></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> Sunday, June 26, 2011 3:07 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">Sorry
Bob, I meant to include an example of your code tweaked to use “raw” a char
array with the Windows API routine. Here it is (this version displays
results rather than storing in a variable, but you get the idea </SPAN><SPAN
style="FONT-FAMILY: wingdings; COLOR: #1f497d; FONT-SIZE: 11pt">J</SPAN><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: 'Courier New'; FONT-SIZE: 9pt">var<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt"> dir: array of
Char;<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt"> s:
String;<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt">begin<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt"> s :=
‘’;<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt"><o:p></o:p></SPAN> </P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt"> SetLength(dir,
MAX_PATH + 1);<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt"> if
Succeeded(SHGetFolderPath(0, CSIDL_Program_Files, 0, 0, @dir[0]))
then<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt"> s :=
PChar(dir);<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt"><o:p></o:p></SPAN> </P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt"> ShowMessageFmt(s + '
(%d chars)', [Length(s)]);<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt"><o:p></o:p></SPAN> </P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt"> // Outcome: s
has both the right length *<B>and</B>* is null terminated
correctly<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt">end;<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>
<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> Monday, 27 June 2011 08:58<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>
<P class=MsoNormal><SPAN style="COLOR: #00002b">I was wondering if my problem is
a conflict between how I derive the value of the variable
(PAnsiChar).<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">Here is the code for doing
that.<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">SetLength(sDir,
MAX_PATH);<o:p></o:p></SPAN></P></DIV>
<DIV>
<P class=MsoNormal><SPAN style="COLOR: #00002b">ZeroMemory(@sDir[1],
MAX_PATH);<o:p></o:p></SPAN></P></DIV>
<DIV>
<P class=MsoNormal><SPAN style="COLOR: #00002b">if Succeeded(SHGetFolderPath(0,
CSIDL_Program_Files, 0, 0, PAnsiChar(sDir))) then<o:p></o:p></SPAN></P></DIV>
<DIV>
<P class=MsoNormal><SPAN style="COLOR: #00002b">FW_Path :=
sDir;<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>
<DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt"> <o:p></o:p></SPAN></P></DIV>
<DIV>
<DIV>
<P style="BACKGROUND: whitesmoke" class=MsoNormal><B><SPAN
style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt">From:</SPAN></B><SPAN
style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt"> <A
title=jsmith@deltics.co.nz href="mailto:jsmith@deltics.co.nz">Jolyon Smith</A>
<o:p></o:p></SPAN></P></DIV>
<DIV>
<P style="BACKGROUND: whitesmoke" class=MsoNormal><B><SPAN
style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt">Sent:</SPAN></B><SPAN
style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt">
Wednesday, June 22, 2011 3:49 PM<o:p></o:p></SPAN></P></DIV>
<DIV>
<P style="BACKGROUND: whitesmoke" class=MsoNormal><B><SPAN
style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt">To:</SPAN></B><SPAN
style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt"> <A
title=delphi@delphi.org.nz href="mailto:delphi@delphi.org.nz">'NZ Borland
Developers Group - Delphi List'</A> <o:p></o:p></SPAN></P></DIV>
<DIV>
<P style="BACKGROUND: whitesmoke" class=MsoNormal><B><SPAN
style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt">Subject:</SPAN></B><SPAN
style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; FONT-SIZE: 10pt"> Re:
[DUG] Variable in String<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>
<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="COLOR: black"> </SPAN><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="COLOR: black"> </SPAN><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="COLOR: black"> </SPAN><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: black"> </SPAN><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="COLOR: black"> </SPAN><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="COLOR: black"> </SPAN><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: black"> </SPAN><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="COLOR: black"> </SPAN><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'; COLOR: black; FONT-SIZE: 10pt"
lang=EN-US>From:</SPAN></B><SPAN
style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: black; 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><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 style="TEXT-ALIGN: center" class=MsoNormal align=center><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: black">
<HR align=center SIZE=2 width="100%">
</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>
<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>