<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:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
{mso-style-priority:99;
mso-style-link:"Plain Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.PlainTextChar
{mso-style-name:"Plain Text Char";
mso-style-priority:99;
mso-style-link:"Plain Text";
font-family:"Calibri",sans-serif;}
.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="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoPlainText><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.<o:p></o:p></span></p><p class=MsoPlainText><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.<o:p></o:p></span></p><p class=MsoPlainText><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. <o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt'><o:p> </o:p></span></p><p class=MsoPlainText><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.<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt'><o:p> </o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt'>James<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>{$mode objfpc}{$H+}<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>// https://docs.microsoft.com/en-us/windows/desktop/api/commdlg/nf-commdlg-getopenfilenamea<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>// https://docs.microsoft.com/en-us/windows/desktop/api/commdlg/ns-commdlg-tagofna<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>Uses<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> sysutils,Windows,Commdlg,Classes,CRT;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>Var<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>Open_File : TOpenFileNameA;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>ret : array[0..100000] of char;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>Filenum : Word;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>Target_File : AnsiString;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>File_Stringlist : tstringList;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>{=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=}<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>Procedure Display_File_StringList(Var Display_String_List:tStringList);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>Var<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> SL_Loop : Word;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> If Display_String_List.Count=0 then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Textcolor(12);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Writeln('0 Files Selected')<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> End<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Else<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> If Display_String_List.Count=1 then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> TextColor(10);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Writeln(Display_String_List[0]);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Textcolor(14);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Writeln('1 Files Selected');<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> End<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Else<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> TextColor(13);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Writeln('Path for all files: ',Display_String_List[0]);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> TextColor(10);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> For SL_Loop:= 1 to Display_String_List.Count-1 Do<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Writeln('File #',SL_Loop,': ',Display_String_List[SL_Loop]);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Textcolor(14);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Writeln(Display_String_List.Count-1,' Files Selected');<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> End;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>End;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>{=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=}<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>Function Get_Files_Into_Stringlist(Var String_List:tStringList):Boolean;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>Var<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Open_File_Result : Boolean;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Position_of_Filename : Word;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> String_List.Clear;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Open_File_Result:=GetOpenFileNameA(@Open_File);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> If Open_File_Result then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Position_of_Filename:=0;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Repeat<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> String_List.add(StrPas(@Open_File.lpstrFile[Position_of_Filename]));<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> inc(Position_of_Filename,length(String_List[String_List.Count-1])+1);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Until Open_File.lpstrFile[Position_of_Filename]=#0;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> End;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Writeln(Open_File_Result);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Get_Files_Into_Stringlist:=Open_File_Result;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>End;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>{=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=}<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>Procedure Process_File(Some_File: AnsiString);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> TextColor(11);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Writeln('Processing File: ',Some_File);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>End;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>{=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=}<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>Begin {Main Program}<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> fillchar(Open_File, sizeof(Open_File), 0);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> fillchar(ret, sizeof(ret), 0);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Open_File.lStructSize:=sizeof(Open_File);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Open_File.hwndOwner:=0;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Open_File.lpstrFile:=ret;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Open_File.lpstrFile[0]:=#0;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Open_File.nMaxFile:=100000;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Open_File.Flags := OFN_EXPLORER or OFN_FILEMUSTEXIST or OFN_ALLOWMULTISELECT;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Open_File.lpstrDefExt:='.txt';<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Open_File.lpstrTitle:='My Program - Open File';<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Open_File.lpstrFilter:='All Files (*.*)'+#0+'*.*'+#0;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> File_Stringlist:=TStringlist.Create;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> If paramstr(1)<>'' then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Target_File:=paramstr(1);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Process_File(Target_File);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> End<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> else<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Target_File:='';<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Repeat<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> If Target_File<>'' then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // The following line seems to cause my program to crash.<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // It does seem to work as I expect. It puts me in the directory<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // of the file and shows the file name, but for some reason if I select<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // more than one file than I get<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // An unhandled exception occurred at $0040B428:<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // EAccessViolation:<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // $0040B428<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // $0040A03D<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // $00414447<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // $0040AE1E<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // $0040A03D<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // $00414447<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // $0040AE1E<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // $0040A03D<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // $00414447<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // $0040AE1E<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // $0040A03D<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // $00414447<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // $0040AE1E<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // $0040A03D<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // $00414447<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // $0040AE1E<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // $0040A03D<o:p></o:p></span></p><p class=MsoPlainText><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<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // Open_File.lpstrFile:=Pchar(Target_File+#0+#0);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> <o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // Or I get:<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // EAccessViolation: An unhandled exception occurred at $0040BB56:<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // with an exit code of 253<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // or <o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // An unhandled exception occurred at $0040BDD2:<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // EAccessViolation: Access violation<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // $0040BDD2<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // with an exit with a code 217<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // if I use one #0 at the end of<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // Open_File.lpstrFile:=Pchar(Target_File+#0);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> <o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // these errors seem to show up more if I select multiple files or <o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // change directories. <o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Open_File.lpstrFile:=Pchar(Target_File+#0);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> <o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> <o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // If I leaved the above commented out, then I should be able to use the <o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // command below to just put me in the directory specified, but with no default file<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // This does not work the way I expect it to work at all.<o:p></o:p></span></p><p class=MsoPlainText><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<o:p></o:p></span></p><p class=MsoPlainText><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<o:p></o:p></span></p><p class=MsoPlainText><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 <o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // be in the directory of the file the parameter specifies, and then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // I want to be in the directory of the previous file.<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> // This just is not working the way I expect but does not cause any crash.<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Open_File.lpstrInitialDir:=Pchar(ExtractFilePath(Target_File)+#0+#0);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> End;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Get_Files_Into_Stringlist(File_Stringlist);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Display_File_StringList(File_Stringlist);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> If (File_Stringlist.Count=1) and FileExists(File_Stringlist[0]) Then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Target_File:=File_Stringlist[0];<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Process_File(Target_File);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> End<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Else<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> If (File_Stringlist.Count>1) Then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Filenum:=0;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Repeat<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Inc(Filenum);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> If (Filenum<File_Stringlist.Count) Then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Target_File:=File_Stringlist[0];<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> If Target_File[Length(Target_File)]<>'\' Then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Target_File:=Target_File+'\';<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Target_File:=Target_File+File_Stringlist[Filenum];<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Process_File(Target_File);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> End;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Until Filenum>=File_Stringlist.Count;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> End;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> Until File_Stringlist.count=0;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'> File_Stringlist.Free;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>end.<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:14.0pt;font-family:Consolas'>{=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=}<o:p></o:p></span></p></div></body></html>