.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix
DescriptionProcedure PutFile displays a standard file dialog which requests the user to select or create a text file for output.
VAR fileName :STRING);
def vs.PutFile(commentStr, defaultStr): return fileName
commentStr STRING User prompt string for dialog. defaultStr STRING Default file name string. fileName STRING Returns name of the user selected file.
RemarksThis procedure also opens the file for write, so you don't have to call Open to write to the file if PutFile was successful.
P.S. On windows, Putfile appends .txt to the file name if the entered name does not contain a file extension. If the user enters "MyFile.mov" it will create a file called "MyFile.mov" while just entering "MyFile" will create "MyFile.txt". Remember that you can't use any of the following chars for filenaming: / : * ? " < > |
On Windows, if you specify a fully qualified path in defaultStr, PutFile will default to the folder in that path, and to the file at the end of the path. On the Mac, PutFile always defaults to the folder containing the active drawing file, and defaultStr should be used just for the filename.
(Orso, 2007.08.05): PutFile fails if the file name "defaultStr" passed is longer than 31 chars (including eventual extension). The file creates but doesn't open for writing and has 0 kb. (tested only on Mac, valid for VW 12.5.+). This limit related to Mac Classic's Finder could be removed now.
PROCEDURE PutFileExample; VAR fileName :STRING; BEGIN PutFile('Select the file to create:', 'New File.txt', fileName); Message(fileName); IF NOT DidCancel THEN BEGIN WriteLn('some text'); Close(fileName); END; END; RUN(PutFileExample);
VersionAvailability: from All Versions
See AlsoVS Functions:
[[VS:GetLastFileErr]] | [[VS:Rewrite]] | [[VS:GetFile]] | [[VS:Open]]| [[VS:Close]]