The savedialog statement displays a modal dialog that allows a user to specify the name and location of a new file.


This statement has three parameters:

path – is a field or variable that will contain the path and filename selected by the user (see Files and Folders. If the user presses the Cancel button, this field or variable will be set to an empty string.

option – The name of an option that modifies the dialogs appearance and/or operation. See below for descriptions of each available option. The option can be specified in either upper or lower case.

value – The option value.


The savedialog statement pauses a procedure and displays the standard system dialog for creating a new file. Once the user has made a choice the procedure resumes and can process the users choice. (Note: The program can determine whether the user pressed the Ok or Cancel button by checking the info(“dialogtrigger”) function. In addition, if the Cancel button is pressed the path parameter will be set to "" (empty).)

This example allows the user to choose any location and filename for a newly exported file.

local fileChoice
savedialog fileChoice
export fileChoice,exportline()

Dialog Options

The appearance and operation of the save dialog can be modified by adding one or more pairs of option/value parameters to the savedialog statement, like this:

savedialog path,option1,value1,option2,value2,option3,value3,option4,value4

Each of the available options are described below.


This option specifies the folder that appears when the dialog first opens. See Files and Folders to learn more about setting up paths. This example initially opens the dialog to the Pictures folder.

local fileChoice
savedialog fileChoice,"InitialPath","~/Pictures"

This example initially opens the dialog to the folder containing the current database.

local fileChoice
savedialog fileChoice,"InitialPath",dbfolder()

If the path option is omitted, the dialog will open to the last folder accessed.


This option specifies the initial name that appears when the dialog first opens. Of course this is just a default, the user can edit the name once the dialog appears. This example will create a default filename based on today’s date, for example Daily Image 2014–06–04.

savedialog fileChoice,
    "FileName","Daily Image "+datepattern(today(),"YYYY-MM-DD")+".jpg"

The default can be set based on database data. This statement will create default filenames like Mary Wilson Headshot.jpg.

savedialog fileChoice,
    "FileName",First+" "+Last+" Headshot.jpg"

If one or more filetypes are specified (see below), the extension can be omitted. It will automatically be supplied based on the first filetype listed. In this example, the default filename will actually be NewImage.png, not NewImage.

savedialog fileChoice,"FileName","NewImage","FileTypes",".png.jpg"

However, if you specify a default filename with extension, that extension will be used. In this example the default is NewImage.jpg, not NewImage.jpg.png.

savedialog fileChoice,"FileName","NewImage.jpg","FileTypes",".png.jpg"

If the filename parameter is omitted, the default filename is simply an empty name.


This option specifies one or more types of files that can be specified with the dialog. If the user attempts to type in a filename of a different type, a warning alert will appear and they will not be allowed to close the dialog. In this example, only filenames ending with .html or .css will be allowed.

savedialog fileChoice,"FileTypes",".html.css"

If the user attempts to enter a filename with an extension that is not listed (for example stuff.csv), the dialog will not allow the save operation to continue. (However, this can be overridden with the allowanyfiletype option, see below.)

If one or more filetypes is specified, the first filetype specified will be the default extension. For example, consider the example above. If the user simply types in the name index, the statement will automatically add the .html extension, so the returned filename will be index.html. The user would also be allowed to type in the extension, so for example index.css could be entered to create a CSS file.

Legacy Support for Type/Creator Codes – The filetypes parameter also supports the older, legacy, 4 character file type codes (see typecreatorcode() in addition to file extensions. Here is an example that allows JPEG, GIF or PNG image files to be created. If you use file types then the filetypes parameter must contain a multiple of 4 characters (4, 8, 12, etc.) and must not start with a period.

saveDialog fileChoice,"FileTypes","JPEGGIFfPNGf"

This option works with the filetypes option described above. Normally, if one or more filetypes are specified, the user is not allowed to enter an extension that is not listed. However, if this option is set to true, the user is allowed to enter any extension, even one not on the list. Why would you want to do that? Consider this example:

saveDialog fileChoice,"FileTypes",".html","AllowAnyFileType",true()

With this statement, the saved filename will default to .html if no extension is specified. However, the user would be allowed to enter any other extension she wanted to, allowing her to create files like stuff.css, list.txt, etc.

Note: Even though this option allows the user to type in any extension he or she wants, the dialog will still ask the user to confirm the extension before completing the save operation. Because of this, it’s usually best to include all of the extensions that would commonly be used, even if you wanted to allow any extension.

saveDialog fileChoice,"FileTypes",".html.css.txt.csv","AllowAnyFileType",true()

This option specifies the title of the Save dialog. The title appears at the very top of the dialog, in the drag bar.

saveDialog fileChoice,"FileTypes",".html","Title","Save New Web Page"

If this option is omitted the default name is simply Save.


This option specifies the name of the Save button. This button appears at the lower right corner of the dialog. Within reason, the button dimensions will expand to accommodate the name you specify.

saveDialog fileChoice,"FileTypes",".html","Button","Save New Web Page"

If this option is omitted the default button name is simply Save.


This option specifies the text that appears just to the left of the filename, at the top of dialog.

saveDialog fileChoice,"FileTypes",".html","Prompt","Web Page:"

Note: Even though their appears to be plenty of room for long prompts, OS X does not display more than about a dozen characters in the prompt area. This may be fixed in future versions of OS X.

If this option is omitted the default prompt is Save As:.


The Save dialog normally has a button at the bottom left that allows the user to create new folders. This option allows you to remove this button, removing the ability to create new folders.

saveDialog fileChoice,"FileTypes",".html","CanCreateFolders",false()

This option allows the dialog to display files that are normally hidden, for example files that start with a period.

saveDialog fileChoice,"FileTypes",".html","ShowHidden",true()

If this option is omitted, hidden files will not be displayed.


This option allows the dialog to open package files as if they were regular folders. Use this option if you want to give the user the option to save a file inside a package (only very advanced users, like developers, would ever need this option).

saveDialog fileChoice,"FileTypes",".html","OpenPackages",true()

If this option is omitted, package files are treated like regular files.

See Also


10.0NewNew in this release.