' Displays Save dialog which allows users to specify
' filename for subsequent file save operation.
' This procedure only provides the user interface and
' returns user input. It does not actually carry out
' the corresponding action.
'
' Parameters:
' FileName - returns the name (without path) of the
' file for the save operation. To supply
' default filename in dialog, assign default
' to FileName then pass it to this procedure.
' PathName - returns the path (without filename) of
' the file for the save operation. To supply
' default path in dialog, assign default to
' PathName then pass it to this procedure.
' Note, only pass a valid drive and path. Do
' not include a filename or file pattern.
' DefaultExt - sets the default search pattern for the
' File Listbox. Default pattern when DefaultExt
' is null is "*.*". To specify a different
' search pattern (i.e. "*.BAS"), assign new
' value to DefaultExt then pass it to this
' procedure.
' DialogTitle - sets the dialog title. Default title
' when DialogTitle is null is "Save As". To
' specify a different title (i.e. "Save My File"),
' assign new value to DialogTitle then pass it to
' this procedure.
' ForeColor - sets the dialog foreground color. Does not affect
' SCREEN.ControlPanel color settings.
' BackColor - sets the dialog background color. Does not affect
' SCREEN.ControlPanel color settings.
' Flags - unused. Use this to customize dialog action if needed.
' Cancel - returns whether or not user pressed the dialog's Cancel
' button. True (-1) means the user cancelled the dialog.
'
SUB FileSave (FileName AS STRING, PathName AS STRING, DefaultExt AS STRING, DialogTitle AS STRING, ForeColor AS INTEGER, BackColor AS INTEGER, Flags AS INTEGER, Cancel AS INTEGER)
' Set up error handling for option validation.
ON LOCAL ERROR GOTO FileSaveError
' Set form caption.
IF DialogTitle = "" THEN
frmCmnDlg.Caption = "Save As"
ELSE
frmCmnDlg.Caption = DialogTitle
END IF
frmCmnDlg.Tag = frmCmnDlg.Tag + "SAVE" ' Set form tag for common unload procedure.
' Determine search pattern for file listbox.
IF DefaultExt <> "" THEN
frmCmnDlg.filOpenList.Pattern = DefaultExt
ELSE
frmCmnDlg.filOpenList.Pattern = "*.*"
END IF
' Determine default path.
IF PathName <> "" THEN
' If the path ends with a backslash, remove it.
IF RIGHT$(PathName, 1) = "\" THEN
PathName = LEFT$(PathName, LEN(PathName) - 1)
END IF
' Set drive and path for file-system controls.
' Set File listbox path. If PathName is different
' than current path, PathChange event will be triggered
' which updates Drive listbox drive and Directory listbox path.