This command opens a Windows Common Filedialog. Liberty BASIC 3+ uses long filenames and an explorer-type filedialog. The dialog lets a user navigate around the directory structure, looking at filenames that have a specific extension and selecting one.

titleString

This parameter is used to label the Filedialog window. It appears in the titlebar of the window. If the window label specified has the word "save" in it, then the save style of the dialog will be used instead of the open style. This means that the button to approve the file selection will say "save" rather than "open".

'will have buttons that say OPEN and CANCEL:

filedialog "Open text file", "*.txt", fileName$

print "File chosen is ";fileName$

'will have buttons that say SAVE and CANCEL:

filedialog "Save As...", "*.txt", fileName$

print "File chosen is ";fileName$

templateString

This parameter is used as a filter so that only files matching a wildcard are listed. To view all file types, the templateString is " *.* " To access multiple extensions in a filedialog, separate the desired extensions with a semicolon character, like this example, which displays files with extensions of both BAS and BAK files in the dialog.

filedialog "Open code file", "*.bas;*.bak", fileName$

receiverVar$

When the user selects a filename, the resulting full path specification will be placed into receiverVar$. This parameter contains an empty string if the user canceled the Filedialog.

Usage

The following example produces a dialog box asking the user to select a text file to open:

filedialog "Open text file", "*.txt", fileName$

If a file named "c:\liberty\summary.txt' was selected, and "Open" was clicked, then program execution would resume after placing the string "c:\liberty\summary.txt" into fileName$. If on the other hand "Cancel" was clicked, then an empty string would be placed into fileName$. Program execution would then resume. Be sure to trap this possibility in your programs, or an error could occur.