<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 15 (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:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-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.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle20
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
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-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Oh that makes sense… so it would know when there wasn’t another string. I’ll put another #0 that seems to be the correct way.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>James<o:p></o:p></p><p class=MsoNormal><b>From:</b> fpc-pascal <fpc-pascal-bounces@lists.freepascal.org> <b>On Behalf Of </b>Alexander Grotewohl<br><b>Sent:</b> Thursday, May 23, 2019 12:22 PM<br><b>To:</b> FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org><br><b>Subject:</b> Re: [fpc-pascal] Getting multiple files from GetOpenFileNameA<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>The whole structure is documented here<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><a href="https://docs.microsoft.com/en-us/windows/desktop/api/commdlg/ns-commdlg-tagofna">https://docs.microsoft.com/en-us/windows/desktop/api/commdlg/ns-commdlg-tagofna</a><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>I just read through it and noticed that. My guess is anything that takes multiple strings that way.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'><o:p> </o:p></p><div><p class=MsoNormal>--<br>Alexander Grotewohl<br><a href="http://dcclost.com">http://dcclost.com</a><o:p></o:p></p></div></div></div><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>On May 23, 2019 12:09 PM, James Richters <<a href="mailto:james@productionautomation.net">james@productionautomation.net</a>> wrote:<o:p></o:p></p><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><div><div><p><span style='font-size:14.0pt'>I’m not clear about when they need one #0 or two. I thought it was just .lpstrFile to make it clear there weren’t more file names in it.. so one #0 between each name and double #0 at the end.. maybe they all need double #0 at the end?</span><o:p></o:p></p><p> <o:p></o:p></p><p>James<o:p></o:p></p><p> <o:p></o:p></p><p><b>From:</b> fpc-pascal <<a href="mailto:fpc-pascal-bounces@lists.freepascal.org">fpc-pascal-bounces@lists.freepascal.org</a>> <b>On Behalf Of </b>Alexander Grotewohl<br><b>Sent:</b> Thursday, May 23, 2019 11:56 AM<br><b>To:</b> FPC-Pascal users discussions <<a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>><br><b>Subject:</b> Re: [fpc-pascal] Getting multiple files from GetOpenFileNameA<o:p></o:p></p><p> <o:p></o:p></p><div><p style='margin-bottom:12.0pt'>I did notice lpstrFilter is terminated by one #0 instead of two. Other than that not at a pc to test.<o:p></o:p></p><div><p>--<br>Alexander Grotewohl<br><a href="http://dcclost.com">http://dcclost.com</a><o:p></o:p></p></div></div><div><p> <o:p></o:p></p><div><p>On May 23, 2019 7:52 AM, James Richters <<a href="mailto:james@productionautomation.net">james@productionautomation.net</a>> wrote:<o:p></o:p></p><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt'><div><div><p><span style='font-size:14.0pt'>I have put together a program that demonstrates the issue I am having. I have re-structured it a bit to try to make it more clear where the problem is.</span><o:p></o:p></p><p><span style='font-size:14.0pt'>While putting this together, I was able to get it to run fine with no problems if I did not try to put GetOpenFileNameA back to the directory of the last file I processed. Including a file sent in as a parameter. If I set Open_File.lpstrFile:=Pchar(Target_File+#0+#0); where Target_File is the complete path and file name of the last file I processed, If I select only one file, then the next time around it DOES work.. and will put me in the directory of Target_File and will show the filename of Target_File as a default, but if I select more than one file, the next time around, it crashes.. I have detailed the crash information in the sameple program comments.</span><o:p></o:p></p><p><span style='font-size:14.0pt'>Another way I wish to run this is to leave Open_File.lpstrFile alone and use Open_File.lpstrInitialDir to put me in the directory of the last processed file, but not specify a default filename. I can’t get this to work correctly at all, but if I use Open_File.lpstrInitialDir without Open_File.lpstrFile then it does not crash, I am just not put in the directory I expect to be in. </span><o:p></o:p></p><p><span style='font-size:14.0pt'> </span><o:p></o:p></p><p><span style='font-size:14.0pt'>Any Advice or suggestions on any of this, or on how I could improve the structure or methods of this program are greatly appreciated.</span><o:p></o:p></p><p><span style='font-size:14.0pt'> </span><o:p></o:p></p><p><span style='font-size:14.0pt'>James</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> </span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> </span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> </span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>{$mode objfpc}{$H+}</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>// <a href="https://docs.microsoft.com/en-us/windows/desktop/api/commdlg/nf-commdlg-getopenfilenamea">https://docs.microsoft.com/en-us/windows/desktop/api/commdlg/nf-commdlg-getopenfilenamea</a></span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>// <a href="https://docs.microsoft.com/en-us/windows/desktop/api/commdlg/ns-commdlg-tagofna">https://docs.microsoft.com/en-us/windows/desktop/api/commdlg/ns-commdlg-tagofna</a></span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>Uses</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> sysutils,Windows,Commdlg,Classes,CRT;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>Var</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>Open_File : TOpenFileNameA;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>ret : array[0..100000] of char;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>Filenum : Word;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>Target_File : AnsiString;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>File_Stringlist : tstringList;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>{=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=}</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>Procedure Display_File_StringList(Var Display_String_List:tStringList);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>Var</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> SL_Loop : Word;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>Begin</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> If Display_String_List.Count=0 then</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Begin</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Textcolor(12);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Writeln('0 Files Selected')</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> End</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Else</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> If Display_String_List.Count=1 then</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Begin</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> TextColor(10);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Writeln(Display_String_List[0]);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Textcolor(14);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Writeln('1 Files Selected');</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> End</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Else</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Begin</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> TextColor(13);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Writeln('Path for all files: ',Display_String_List[0]);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> TextColor(10);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> For SL_Loop:= 1 to Display_String_List.Count-1 Do</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Writeln('File #',SL_Loop,': ',Display_String_List[SL_Loop]);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Textcolor(14);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Writeln(Display_String_List.Count-1,' Files Selected');</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> End;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>End;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>{=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=}</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>Function Get_Files_Into_Stringlist(Var String_List:tStringList):Boolean;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>Var</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Open_File_Result : Boolean;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Position_of_Filename : Word;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>Begin</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> String_List.Clear;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Open_File_Result:=GetOpenFileNameA(@Open_File);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> If Open_File_Result then</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Begin</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Position_of_Filename:=0;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Repeat</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> String_List.add(StrPas(@Open_File.lpstrFile[Position_of_Filename]));</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> inc(Position_of_Filename,length(String_List[String_List.Count-1])+1);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Until Open_File.lpstrFile[Position_of_Filename]=#0;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> End;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Writeln(Open_File_Result);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Get_Files_Into_Stringlist:=Open_File_Result;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>End;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>{=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=}</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>Procedure Process_File(Some_File: AnsiString);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>Begin</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> TextColor(11);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Writeln('Processing File: ',Some_File);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>End;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>{=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=}</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>Begin {Main Program}</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> fillchar(Open_File, sizeof(Open_File), 0);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> fillchar(ret, sizeof(ret), 0);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Open_File.lStructSize:=sizeof(Open_File);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Open_File.hwndOwner:=0;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Open_File.lpstrFile:=ret;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Open_File.lpstrFile[0]:=#0;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Open_File.nMaxFile:=100000;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Open_File.Flags := OFN_EXPLORER or OFN_FILEMUSTEXIST or OFN_ALLOWMULTISELECT;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Open_File.lpstrDefExt:='.txt';</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Open_File.lpstrTitle:='My Program - Open File';</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Open_File.lpstrFilter:='All Files (*.*)'+#0+'*.*'+#0;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> File_Stringlist:=TStringlist.Create;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> If paramstr(1)<>'' then</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Begin</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Target_File:=paramstr(1);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Process_File(Target_File);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> End</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> else</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Target_File:='';</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Repeat</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> If Target_File<>'' then</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Begin</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // The following line seems to cause my program to crash.</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // It does seem to work as I expect. It puts me in the directory</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // of the file and shows the file name, but for some reason if I select</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // more than one file than I get</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // An unhandled exception occurred at $0040B428:</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // EAccessViolation:</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // $0040B428</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // $0040A03D</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // $00414447</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // $0040AE1E</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // $0040A03D</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // $00414447</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // $0040AE1E</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // $0040A03D</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // $00414447</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // $0040AE1E</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // $0040A03D</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // $00414447</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // $0040AE1E</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // $0040A03D</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // $00414447</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // $0040AE1E</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // $0040A03D</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // in a repeating loop if I use the command with two #0 at the end of</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // Open_File.lpstrFile:=Pchar(Target_File+#0+#0);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> </span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // Or I get:</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // EAccessViolation: An unhandled exception occurred at $0040BB56:</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // with an exit code of 253</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // or </span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // An unhandled exception occurred at $0040BDD2:</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // EAccessViolation: Access violation</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // $0040BDD2</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // with an exit with a code 217</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // if I use one #0 at the end of</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // Open_File.lpstrFile:=Pchar(Target_File+#0);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> </span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // these errors seem to show up more if I select multiple files or </span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // change directories. </span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Open_File.lpstrFile:=Pchar(Target_File+#0);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> </span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> </span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // If I leaved the above commented out, then I should be able to use the </span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // command below to just put me in the directory specified, but with no default file</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // This does not work the way I expect it to work at all.</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // It does not put me into the directory of the file used as a parameter, it</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // Then for other files it puts me one level before the one I was just in</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // I want to be back where I was. If I give it a parameter, I want to </span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // be in the directory of the file the parameter specifies, and then</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // I want to be in the directory of the previous file.</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> // This just is not working the way I expect but does not cause any crash.</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Open_File.lpstrInitialDir:=Pchar(ExtractFilePath(Target_File)+#0+#0);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> End;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Get_Files_Into_Stringlist(File_Stringlist);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Display_File_StringList(File_Stringlist);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> If (File_Stringlist.Count=1) and FileExists(File_Stringlist[0]) Then</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Begin</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Target_File:=File_Stringlist[0];</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Process_File(Target_File);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> End</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Else</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> If (File_Stringlist.Count>1) Then</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Begin</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Filenum:=0;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Repeat</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Inc(Filenum);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> If (Filenum<File_Stringlist.Count) Then</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Begin</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Target_File:=File_Stringlist[0];</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> If Target_File[Length(Target_File)]<>'\' Then</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Target_File:=Target_File+'\';</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Target_File:=Target_File+File_Stringlist[Filenum];</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Process_File(Target_File);</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> End;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Until Filenum>=File_Stringlist.Count;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> End;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> Until File_Stringlist.count=0;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'> File_Stringlist.Free;</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>end.</span><o:p></o:p></p><p><span style='font-size:14.0pt;font-family:Consolas'>{=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=}</span><o:p></o:p></p></div></div></blockquote></div><p> <o:p></o:p></p></div></div></div></blockquote></div><p class=MsoNormal><o:p> </o:p></p></div></div></body></html>