2.14.1.2 dlgFile


Brief Information

Open the File selection dialog

Additional Information

X-Function not designed for Auto GetN Dialog.

Command Line Usage

1. dlgFile;//result in fname$

2. dlgFile fname:=strMyFile;

3. dlgFile fname:=strMyFile title:=Save;

4. dlgFile group:=ascii init:="C:\Documents and Settings\Administrator\Desktop";

5. dlgfile group:=f*.txt;

6. dlgfile group:="*.txt; *.dat; *.p*;"

X-Function Execution Options

Please refer to the page for additional option switches when accessing the x-function from script

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
fname

Output

string

fname$

The string that will receive path and name of the user's chosen file.

group

Input

string

Optional string to specify file extension group. Supported group names can be found in File.ogs, look for [FileExt] section and search using "_NAME=". You can also directly specify the wildcard pattern.

init

Input

string

Optional string used to initialize the file path (for opening, saving, etc.) in the dialog.

title

Input

string

Optional string used to set the dialog's title.

multi

Input

int

0

used to determine the dialog if support multi files selection or not

Description

This X-Function opens a dialog to enable you to select one or multiple files and store the selected file path into a string variable.

Examples

The following example shows:

  1. Selecting multiple files and getting each file name. You can use GetToken to separate the file names using CRLF as separator.
  2. Handling of Cancel by user to terminate. See this LT Scripting Guide topic on using braces "{ }" to protect a break.
  3. Use of the CRLF separator.
[Main]
for(i=1;i<5;i++)
{ 
	if(run.section(,askfile)==0)
		break 1;
	type "Files $(i):%(CRLF)%(fname$)";
}

[askfile]
fname$="";//empty it so later can test length

//select some image files, allow user to cancel
//dlgfile cancel will trigger error to stop script, 
//so enclosed in { } will let script continue
string strInitPath$=system.path.program$+"Samples\Image Processing and Analysis";
{dlgfile g:="*.png;*.jpg" m:=1 init:=strInitPath$;}
int nn=fname.GetLength();
if (nn==0)
{
	type "User Cancel";
	return 0;
}
nn = fname.GetNumTokens(CRLF);//number of files
nn=;//dump to script window for checking
return nn;

Related X-Functions

dlgPath, dlgPickFiles