Home > Language Reference > User Dialog Functions > SelectFile


The SelectFile function displays the standard Open File dialog box and returns the user selection.


Used to prompt for a file used later in the script.


ret=SelectFile(<title>, <folder>, <mask>, <selected_folder>, <offset_name>, <offset_extension>)


<title>, string, text to display in the title bar of the dialog box.

<folder>, string, name of the folder to open. If the specified folder is invalid, the default folder is C:.

<mask>, string, list of file types allowed in the dialog box. The syntax is "*.txt;text files (*.txt)" for *.txt files with the label text files (*.txt). To include multiple types, use ; separator, see the example.

, variable, string. It returns the filename selected by the user in the dialog box.

<offset_name>, variable, integer. It returns the position of the first letter of the selected filename (without the path).

<offset_extension>, variable, integer. It returns the position of the first letter of the file extension of the selected filename (without the path).

Return value

ret, optional numeric return code. If the function has successfully opened the selected file, the function returns 0. If the function fails (the Cancel button has been clicked for example), the return value is 1.

See also



SelectFile("Select the file", "C:\wttest","*.txt;text files (*.txt);*.doc;documents (*.doc)",filename$,offsetname,offsetext)
msgbox(filename$)   ' returns c:\wttest\test.txt if the user has selected test.txt and clicked Open button
msgbox(offsetname) 'returns 9, position of t letter, first letter of the selected filename in c:\wttest\test.txt 
msgbox(offsetext)     'returns 14, poistion of the first letter of the extension