Open the File selection dialog
X-Function not designed for Auto GetN Dialog.
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*;"
Please refer to the page for additional option switches when accessing the x-function from script
Display Name |
Variable Name |
I/O and Type |
Default Value |
Description |
---|---|---|---|---|
fname |
Output string |
|
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 |
|
used to determine the dialog if support multi files selection or not |
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.
The following example shows:
[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;