SaveFileRequester()

Syntax

FileName$ = SaveFileRequester(Title$, DefaultFile$, Pattern$, PatternPosition)
Description
Opens the standard requester for the user to save a file. The title can be specified to replace the default one. The DefaultFile$ is useful to initialise the requester in the right directory and with the right filename.

The Pattern is a standard filter which allow to display only the files which end with such or such extension. It must be in the following form : "Text file | *.txt | Music file | *.mus;*.mod" The pattern always work by pair: name (which really appears in the filter) and extention (ie: *.txt). Several extensions can be specified for a single type by using the ; (semi-colon) separator.

Finally 'PatternPosition' specifies which pattern must be the default. It begin from 0 up to the number of pattern. Once the requester has been closed, SelectedFilePattern() can be used to get back the selected pattern.

The returned 'FileName$' can be easily split into file, path and extension string with the following functions: GetFilePart(), GetPathPart() and GetExtensionPart().

Example:
  StandardFile$ = "C:\autoexec.bat"   ; set initial file+path to display
  ; With next string we will set the search patterns ("|" as separator) for file displaying:
  ;  1st: "Text (*.txt)" as name, ".txt" and ".bat" as allowed extension
  ;  2nd: "PureBasic (*.pb)" as name, ".pb" as allowed extension
  ;  3rd: "All files (*.*) as name, "*.*" as allowed extension, valid for all files
  Pattern$ = "Text (*.txt)|*.txt;*.bat|PureBasic (*.pb)|*.pb|All files (*.*)|*.*"
  Pattern = 0    ; use the first of the three possible patterns as standard
  File$ = SaveFileRequester("Please choose file to save", StandardFile$, Pattern$, Pattern)
  If File$
    MessageRequester("Information", "You have selected following file:"+Chr(10)+File$, 0)
  Else
    MessageRequester("Information", "The requester was canceled.", 0) 
  EndIf

Supported OS

All

<- PathRequester() - Requester Index - SelectedFilePattern() ->