BROWSE        Display a pop-up open file dialog box

Top  Previous  Next

Syntax:

BROWSE

[ variable ]  [ title ]  [ initdir ] [ filter ] [ options ]

Arguments:

[ variable ]

A variable to store the file name or file name with full path selected in the open file dialog box; if the variable does not previously exist, it is created.

 

[ title ]

Optional variable or string defining a open file dialog box window title. If not specified, neither [ initdir ] nor [ filter ] may be specified.

 

[ initdir ]

Optional variable or string defining the initial folder for the open file dialog box. If not specified, [ filter ] may not be specified.

 

[ filter ]

Optional variable or string defining a filter to be used when displaying files in the open file dialog box.

Options:

/folders

When this option is used, the command permits browsing for a folder rather than an individual file.

 

/nopath

When this option is used only the file name is saved in [ variable ]. By default the full path and file name is returned.

 

 

This command not allowed when running as a Windows service or in a locked minimized window.

 

This script command displays a open file dialog box on your display that permits browsing for a user-selected file or folder. The window title, starting folder, and a file name filter may be specified in the command. Control returns to next script command when you close the dialog by clicking on the OK or Cancel buttons. This command is useful to allow a user to make a select of a file to be processed by a running script.

 

If Robo-FTP is running a script in a unlocked minimized window then Robo-FTP window will be restored when this command is performed.

 

The script file can detect if the Cancel button has been clicked by using the IFERROR command to test for result code 1013 or the $ERROR variable $ERROR_PROMPT_CANCELLED.

 

Consider the following example of a script file that displays the open file dialog box that is prompting you for the name of next file to send to an FTP site.

 

BROWSE file_name "Select File To Upload"

IFERROR= $ERROR_PROMPT_CANCELLED GOTO done

SENDFILE file_name

:done

 

The starting folder to display in the open file dialog box may be specified as shown below. If this parameter is omitted then the default folder is the current working folder. Also note that if the starting folder parameter is omitted then the [ filter ] parameter may not be specified.

 

SET folder = "C:\My Uploads"

BROWSE file_name "Select File To Upload" folder

IFERROR= $ERROR_PROMPT_CANCELLED GOTO next_step

SENDFILE file_name

:next_step

 

The chosen file name can be limited by specifying a [ filter ] which prevents the open file dialog box from displaying any files that do not match the filter. A filter consists of a text description (e.g., Text Files) that is displayed in the dialog box and a corresponding file wildcard designation (e.g., *.txt) separated by the pipe character ‘|’ as shown below.

 

SET folder = "C:\My Uploads"

SET filter = "Text Files|*.txt"

BROWSE filename "Select File To Upload" folder filter

IFERROR= $ERROR_PROMPT_CANCELLED GOTO top

SENDFILE file_name

 

Multiple filters are possible as shown below.

 

SET filter = "Text Files|*.txt|Log Files|*.log"

 

The /nopath option results in only the file name of a selected file being returned as shown below.

 

SET folder = "C:\My Uploads"

BROWSE file_name "Select File To Upload"

DISPLAY file_name

file_name = "C:\My Uploads\Data1.txt"

BROWSE file_name "Select File To Upload" /nopath

DISPLAY file_name

file_name = "Data1.txt"

 

The /folders option changes the behavior of the command to browse for a folder rather then an individual file as shown below.

 

BROWSE folder_name "Select Folder" /folders

 

When using the /folders option, the [ filter ] argument has no effect and a warning will be displayed in such a case. The /folders and /nopath options cannot be used together, and an "Invalid argument" error will occur if they are combined in the same command.

 

Related command(s): MESSAGEBOX, ASK, PROMPT, PLAYSOUND, WEBBROWSER, CONSOLE, CONSOLEMSG, MAILTO, PRINT

See also: Running Robo-FTP With Prompting