Using dialog boxes
Use these commands to get data from the user with the help of system
dialog boxes.
Command |
Availability |
Arguments |
Purpose |
dialog.openFile |
EXE, SCR |
title, filters, default extension,
current file, variable |
Opens the Open File dialog
box. |
dialog.saveFile |
EXE,
SCR |
title, filters, default
extension, current file, variable |
Opens the Save File dialog
box. |
dialog.selectDirectory |
EXE, SCR |
title, root directory, variable |
Opens the Open Folder dialog
box. |
dialog.selectColor |
EXE,
SCR |
current color, variable |
Opens the Choose Color dialog box. |
dialog.openFile
This command opens the dialog box asking the user to select the file
to be opened.
The 1st argument is the title of the dialog box.
The 2nd argument contains file filters. Each filter consists of its description
and mask separated with a vertical bar. If you need to specify several
masks in one filter, use the semicolon ‘;’. Filters are also
separated with a vertical bar.
The 3rd argument is the default file extension.
The 4th argument is the full path to the current file. This file will
be selected in the dialog box by default. Specify an empty argument if
you do not need to select the default file.
The 5th argument is the variable the full path to the selected file will
be assigned to. If no file is selected, an empty string will be assigned
to the variable.
The following script opens the dialog box where the user can select
an image file and assigns the full path to the selected file to the ImgFile
variable.
fscommand(“dialog.openFile”, “Select an image file,Image
Files (*.jpg;*.png)|*.jpg;*.png|All Files (*.*)|*.*,*.jpg,,ImgFile”);
dialog.saveFile
The 1st argument is the title of the dialog box.
The 2nd argument contains file filters. Each filter consists of its description
and mask separated with a vertical bar. If you need to specify several masks
in one filter, use the semicolon ‘;’. Filters are also separated
with a vertical bar.
The 3rd argument is the default file extension.
The 4th argument is the full path to the current file. This file will be selected
in the dialog box by default. Specify an empty argument if you do not need to
select the default file.
The 5th argument is the variable the full path to the selected file will be assigned
to. If no file is selected, an empty string will be assigned to the variable.
This command opens the dialog box asking
the user to select the file for saving and assigns the full path to the
selected file to the ImgFile variable.
fscommand(“dialog.saveFile”, “Select
an image file,JPEG Image File (*.jpg)|*.jpg,*.jpg,,ImgFile”);
dialog.selectDirectory
This command opens the dialog box asking the user to select a folder.
The 1st argument is the title of the dialog box.
The 2nd argument is the full path to the root directory. The user will
not be able to select a directory located above this directory. Specify
an empty argument if you do not need this limitation.
The 3rd argument is the variable the full path to the selected folder
with the trailing slash ‘/’ at the end will be assigned to.
If no folder is selected, an empty string is assigned to the variable.
The following script opens the dialog box where the user can select
a folder and assigns the full path to the selected directory to the Dir1
variable.
fscommand(“dialog.selectDirectory”, “,Dir1”);
dialog.selectColor
This command opens the dialog box asking the user to select a color.
The 1st argument is the current color in the RRGGBB format. This color
will be selected in the dialog box by default. If you do not need the
default color, specify an empty argument.
The 2nd argument is the variable the color in the RRGGBB format will
be assigned to. If no color is selected, an empty string is assigned
to the variable.
The following script will open the Choose Color dialog box with the
white color by default and assign the selected color to the NewColor
variable. fscommand(“dialog.selectColor”, “FFFFFF,NewColor”); |