<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>Thanks for the gersavefilenamea idea, I have used windows API function calls before in my Windows Console programs, so I thought I would try to get getsavefilenamea or ifilesavedialog to work in my console program.  So I thought I would start small and get message boxes to work on my console program, this was actually pretty easy, I just added the windows unit to my program and then changed my writeln's to windows.messagebox(0,pchar(TapFileName+' Not Found'),pchar('Error'),MB_OK);<o:p></o:p></p><p class=MsoPlainText>And poof I get a message box when I encounter the error, and the program waits until I hit OK to continue.  Neat!  <o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>So it's looking promising, that perhaps I can just keep it a console program that launches the save-as dialog somehow when needed.    This idea appeals to me for several reasons, first, I need to write the status of things somewhere,  it's easy to just have a writeln in a console application, but in a windows application, I have no idea how I would make some kind of text box to display this information.   Also, I want this program to start executing immediately, and if no user intervention is needed, I want it to launch, perform all tasks, and exit.  I just don't have anything to put on a form because the intent is that the user would only interact with this program if it encountered an error, or if the user needed to specify the output file name.<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>So my question is, how can I use Ifilesavedialog with just FreePascal in a console application?  I tried just accessing it the same as I did messagebox, but I just get an error stating the function is not found.   It seems like I ran across this before, I wanted to use a Windows API function that was not included in the windows unit and I was somehow able to add access to it on my own,  but I just can't recall now what function that was, or what program I was working on that needed it, or how it was accomplished.   Perhaps it is in the windows unit, or another unit, but I'm just not calling it correctly.   Current version of my program that uses message boxes for errors is below.<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>James<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>Program JobsList;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>Uses CRT,Classes,Sysutils,windows;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>Var<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>   TapFileRemainder,TapFileHeader,TapFileJobsList : tstrings;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>   TapFileName,TapFileData,OutputTapFileName      : AnsiString;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>   TapFile                                        : Text;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>   TapFileHeaderActive                            : Boolean;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>   StringCount                                    : LongInt;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>   If ParamStr(1)<>'' Then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>      Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>         TapFileName:=ParamStr(1);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>         If FileExists(TapFileName) Then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>            Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>               TapFileHeaderActive:=True;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>               Assign(TapFile,TapFileName);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>               Reset(TapFile);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>               TapfileHeader:=TStringlist.Create;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>               TapfileJobsList:=TStringlist.Create;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>               TapfileRemainder:=TStringlist.Create;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>               While not(EOF(TapFile)) do<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                  Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                     Readln(Tapfile,TapFileData);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                     If TapfileHeaderActive then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                        Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                           If TapFileData='Call [Subroutines]' Then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                              Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                                 Writeln('Subroutine Section Found');<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                                 TapFileHeaderActive:=False<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                              End<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                           Else<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                           If Copy(TapFileData,1,15)='Tap File Name =' Then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                              Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                                 OutputTapFileName:=Copy(TapFileData,16,Length(TapFileData)-15);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                                 Writeln('Saving to: '+OutputTapFileName);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                              End<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                           Else<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                              TapfileHeader.Add(TapFileData)<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                        End<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                     Else<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                        Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                           If Copy(TapFileData,1,6)='[Job #' Then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                              Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                                 Writeln(TapFileData);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                                 TapFileJobsList.Add('Call '+TapFileData);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                              End;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                           TapfileRemainder.Add(TapFileData)<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                        End;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                  End;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>               Close(TapFile);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>               If OutputTapFileName='' Then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                  Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas;color:red'>                     {Do something to get filename from windows Save-As dialog}<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas;color:red'>                     {OutputTapFileName:= Whatever-was-received-by-Windows-Save-As-dialog;}<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                  End;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>               If OutputTapFileName<>'' Then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                  Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                     Writeln('Writing ',TapFileHeader.count+TapFileJobsList.count+TapFileRemainder.count,' Lines to: '+OutputTapFileName);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                     Assign(TapFile,OutputTapFileName);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                     ReWrite(TapFile);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                     If TapFileHeader.count > 1 then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                     For StringCount:=0 to TapFileHeader.count-1 do<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                        Writeln(TapFile,TapFileHeader[StringCount]);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                     If TapFileJobsList.count > 1 then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                     For StringCount:=0 to TapFileJobsList.count-1 do<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                        Writeln(TapFile,TapFileJobsList[StringCount]);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                     If TapFileRemainder.count > 1 then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                     For StringCount:=0 to TapFileRemainder.count-1 do<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                        Writeln(TapFile,TapFileRemainder[StringCount]);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                     Close(TapFile);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                  End<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>               Else<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                  Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                     windows.messagebox(0,pchar('No Output Tap File Specified in Program'),pchar('Error'),MB_OK);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>                  End;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>               TapFileHeader.Free;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>               TapFileJobsList.Free;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>               TapFileRemainder.Free;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>            End<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>         Else<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>            Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>               windows.messagebox(0,pchar(TapFileName+' Not Found'),pchar('Error'),MB_OK);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>            End;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>      End<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>   Else<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>      Begin<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>         windows.messagebox(0,pchar('No File Name Specified'),pchar('Error'),MB_OK);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>      End;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:12.0pt;font-family:Consolas'>End.<o:p></o:p></span></p></div></body></html>