GETFILENAME$ opens a File Open or Save dialog box and returns the chosen file name. GETFILENAME$ may be used to retrieve a file name for opening, saving or performing any other action on files.
Syntax:FileName = GETFILENAME$(FileTitle AS STRING, _ FileExtension AS STRING _ [, OpenSave AS INTEGER] _ [, HndlWnd AS HWND] _ [, Flags AS INTEGER] _ [, InitialDir AS STRING] _ [, InitialFile AS STRING] _ [, &ExtIndex AS INTEGER]) Return Value:
Parameters:
|
DIM FileName$ DIM Mask$ Mask$ = ".HTML Documents(.Htm;.Html)|*.Htm;*.Html|" Mask$ = Mask$ & "Active Server Pages(.Asp)|*.Asp|" Mask$ = Mask$ & "Text Files(.Txt)|*.Txt|" Mask$ = Mask$ & "All Supported Files(.Htm;.Html;.Asp;.Txt;)" Mask$ = Mask$ & "|*.Htm;*.Html;*.Asp;*.Txt;|" Mask$ = Mask$ & "All Files(*.*)|*.*|" FileName$ = GETFILENAME$("OPEN", Mask$) ' defaults to OPEN Dialog IF LEN(FileName$) THEN MSGBOX FileName$ ELSE MSGBOX "Cancelled" END IF FileName$ = GETFILENAME$("OPEN", Mask$, 0) ' set flag to use OPEN Dialog IF LEN(FileName$) THEN MSGBOX FileName$ ELSE MSGBOX "Cancelled" END IF FileName$ = GETFILENAME$("SAVE", Mask$, 1) ' set flag to use SAVE Dialog IF LEN(FileName$) THEN MSGBOX FileName$ ELSE MSGBOX "Cancelled" END IF
The above example will open a file dialog box with the default directory being that in which the executable was started. The dialog box will display files that have extensions coded in the Mask$ variable. To list all files, use *.* as the FileExtension. The [OPTIONAL] HndlWnd (handle of the window that owns the dialog box) is not used in this example.
GETSAVEASFILENAME$ opens a Windows Shell IFileDialog interface and returns the chosen path and filename, as well as the index number of the file encoding selected in the ComboBox dropdown beside the Save button on the interface. GETSAVEASFILENAME$ may be used to retrieve a file name for opening, saving or performing any other action on files.
Syntax:FileName = GETSAVEASFILENAME$(FileTitle AS STRING, _ FileExtension AS STRING _ [, Un-Used AS INTEGER] _ [, HndlWnd AS HWND] _ [, Flags AS INTEGER] _ [, InitialDir AS STRING] _ [, InitialFile AS STRING] _ [, &ExtIndex AS INTEGER]) Return Value:
Parameters:
|
When the code below is executed, if UTF-8 with BOM is chosen in the Combobox dropdown beside the Save button on the interface, "1" would be stored in the "EncodeNdx" variable.
DIM fmask$, FileName$, EncodeNdx fmask$ = "BCX Source Files (*.bas *.inc)|*.bas;*.inc|" fmask$ = fmask$ + "C/C++ Source Files (*.c *.c++)|*.c;*.cpp|" fmask$ = fmask$ + "Resource Files (*.rc)|*.rc|" fmask$ = fmask$ + "Text Files (*.txt)|*.txt|" fmask$ = fmask$ + "All Files (*.*)|*.*" FileName$ = GETSAVEASFILENAME$("My Caption", fmask$, 0, 0, 0, CURDIR$, "*.*", &EncodeNdx) PRINT : PRINT "You Selected: ", FileName$, " with "; SELECT CASE EncodeNdx CASE 0 : PRINT "UTF-8"; CASE 1 : PRINT "UTF-8 with BOM"; CASE 2 : PRINT "UTF-16 LE"; CASE 3 : PRINT "UTF-16 BE"; END SELECT PRINT " encoding." PAUSE
The above example will open a file interface with the default directory being that in which the executable was started. The file interface will display files that have extensions coded in the Mask$ variable. To list all files, use *.* as the FileExtension. The [OPTIONAL] HndlWnd (handle of the window that owns the interface) is not used in this example.