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. It will list files with .bas and .c extensions. To list all files, use *.* as the Extension$. The OPTIONAL HndlWnd (handle of the window that owns the dialog box) is not used in this example.