SelectFile

User dialog function.

The SelectFile function returns the LONG name of the files selected by the user in the standard File Open dialog. Not available in WinTask Lite.

Syntax

ret=SelectFile(<title>,<directory>,<filter>,<selected_file>,<offset_name>,<offset_extension>)

Parameters

<title>: string, title of the File Open dialog.

<directory>: initial directory in the File Open dialog.

<filter>: file extensions listed in the File Open dialog; first the extension, followed by the label of this extension; all the arguments are separated by the character ;.

<selected_file>: the file specified in the edit box of the File Open dialog; a return variable, it contains the name of the file selected by the user.

<offset_name>: the position of the first letter of the filename selected. For example, if the file returned is c:\dir1\dir2\file.ext, this argument contains 14.

<offset_extension>: the position of the first letter of the extension. For instance, if the file returned is c:\dir1\dir2\file.ext, this argument contains 19 (position of the letter e).

 

Return value

ret, numeric return code. When the user has selected the OK button, the function returns 0, otherwise use this return code for Error Handling.

Remarks

Sometimes, SelectFile does not bring to focus the Select file dialog box under Windows 7. Add this key in Registry if you notice this behavior when using SelectFile:
HKEY_CURRENT_USER\Control Panel\Desktop\ForegroundLockTimeout
Dword with the value 30d40

Example

file_name$ is the LONG name of the selected file.

ret=SelectFile("Select the file", "c:\worddocs","*.txt;text files (*.txt);*.doc;documents (*.doc)",file_name$,offset_name,offset_ext)