# 3.7.5.14 Fdlog

LabTalk Object Type:

Utility

The fdlog object provides for script access to Origin's Open and Save As dialog boxes. These dialog boxes are a modification of the standard Windows dialog box that allows for a line of comments to be stored with Origin project files. The 32 bit version of Origin running under Windows 95 allows you to choose this dialog box (@X = 0 or system.explorer = 0) or the standard Explorer dialog box (@X = 1 or system.explorer = 1).

Note on Extension

The portion of text in the file name that follows the last period. For example, BMP is the extension of the file named "MyImage.BMP".

Note on Extension Description

The text that appears in the Files of Type combination box in the Open and Save As dialog box. This text is used to describe or identify the files that are named with a specific Extension. Example: Windows Bitmap (*.BMP)

Note on Extension Group

A list of Extension Descriptions. Example: Images

 Please see the dlgFile, dlgSave, dlgPath X-Function.

## Properties:

Property Access Description
numeric

This property is used to get the check state of the "Open as read-only" check box. The check box only appears on the dialog box displayed by the fdlog.open() method. The "Open as read-only" check box will be enabled when the Files of Type is for Origin projects (.OPJ or .ORG). When the "Files of type" is not set for Origin projects this check box will be unavailable (gray).

fdlog.checkName$Read/write, string This property is used to show and hide an optional check box on the dialog box. Set this property to any string to show the check box or to an empty string ("") to hide the check box. Use the fdlog.checkStatus property to get and set the state of the optional check box. fdlog.checkStatus Read/write, numeric Get and set the state of the optional check box. Zero indicates not selected and non-zero indicates selected. Use the fdlog.checkName$ property to show and hide the optional check box.

numeric

Get the index (starting with one) of the file type selected when the dialog box is closed. Note: It is recommended that the new property fdlog.defType be used instead of fdlog.choice.

fdlog.control --

Not currently implemented.

fdlog.default$Read/write, string This property is used to get and set the contents of the File Name text box in the dialog boxes displayed by the fdlog.open() and fdlog.saveAs() method. Set this property to have a default file name appear when the dialog box opens and get this property after the dialog box closes for the name of the selected file. This string may contain a path and a file name. If a path is specified, then the fdlog.path$ property is set. The File Name text box will not show the path. Only the file name is shown.

numeric

This property is used to get the selected file type and set the default file type for the Files of Type combination box. Valid values are in the range [0, fdlog.numTypes]. The value determines which fdlog.type$is displayed in the Files of Type combination box. There is currently a limit of 25 file types. fdlog.defTypeExt$ Read/write,
string

Same as fdlog.defType except that it holds the extension of the type selected.

fdlog.dlgName$Read/write, string Use this property to get and set the name of the dialog box. Set to an empty string ("") to use the default names. fdlog.expASCII -- Not currently implemented fdlog.ext -- This property is obsolete. fdlog.message$ Read/write,
string

Set the text in the static control of the Multi-open dialog box. It does not show a check box. If fdlog.checkName$is also set, it will supercede fdlog.message$.

numeric

The MultiOpen dialog box contains a list of the user's selected files. By default, this list contains only the file's path and name. With this property you can display additional file information and even enable a way for the user to specify the column designation (how to import the file) for a selected file. This property is bit oriented and the following bits are used:
0 / 1 Show the Column Designation column.
1 / 2 Show the Template column.
2 / 4 Show the file's size.
3 / 8 Show the file's date of last modification.

fdlog.multiOpen.comboList$Read/write, string Contents of the combo box. Each item is separated with a . fdlog.multiOpen.comboName$ Read/write,
string

If empty, then hide the combo box. Otherwise, show the combo box and the label will equal the string.

numeric

The default and the user selection from the combo box.

numeric

After a MultiOpen dialog box closes, this property is set to the number of files selected. This property replaces the count variable that was previously being set.

numeric

Set fdlog.multiOpen.sort to n to control sorting behavior in the MultiOpen dialog box:
0 = no sorting.
1 = sort the entire list after inserting selected files into the list.
2 = sort the selected files and then insert them at the end of the list.
This setting does not affect the sort behavior when clicking on the column headings. It only affects what happens prior to, and after, adding selected files to the list.

numeric

When fdlog.checkName$is set, this property will toggle list box columns in the MultiOpen dialog box based on the state of the check box. It uses the same bits as fdlog.multiOpen.colView. For example: fdlog.multiOpen.colToggle = 6 will toggle the template and the size columns. If these columns were shown when opening the dialog box, then the first click on the check box will toggle them to not show, the next click will show them. For example, if the template column was shown and the size column was hidden when opening the dialog box, then the first click on the check box will hide the template column and show the size column, and the next click will show the template and hide the size. fdlog.numTypes Read/write, numeric The number of extension types to appear in the Files of Type combination box. You can set this value to decrease or increase the number of types in the active group. This value must be in the range [0,25]. There is currently a limit of 25 file types. fdlog.optionDlg$ Read/write,
string

This property is used to show and hide an Option button on the dialog box. Currently, this is only used for the ASCII Import Options button when importing an ASCII file. Set this property to "IMPASCII" to show the button or to an empty string ("") to hide the button.

fdlog.path$Read/write, string This property is used to set the default path for when the dialog box opens and to get the path of the file selected when the dialog box closed. fdlog.showComment Read/write, numeric For the Open dialog box, this property is used to show and hide the Show Info check box. The state of the Show Info check box determines if the Comments edit box is shown or hidden. For the SaveAs dialog box, this property is used to show and hide the Comments edit box. In both cases, the value 1 indicates show and the value 0 indicates hide. fdlog.typen$ Read/write,
string

Get and set the nth file type. These are the strings that appear in the Files of Type combination box. The index must be in the range [1, NumTypes]. The strings must be entered in the format "[description] extension". Example:

FDlog.Type1$= "[Windows Bitmap (*.BMP)] *.BMP"; FDlog.numtypes needs to be set first. There is currently a limit of 25 file types. The addtype method can be used instead and numtypes will automatically be set. ## Methods: Method Description fdlog.addType(extType) This method is used to create a new extension type. The extension type must be in the format "[description] *.extension" where description is the text that appears in the Files of Type combination box and extension is the extension of the files to display. On success, this method increments the fdlog.numTypes property. A group can have a maximum of 25 file types. fdlog.addUserType(Filtertype, Wintype) This method is used to select an installed import filter and destination window type. • Note on Filtertype: 0 = filters for ASCII data 1 = filter for Binary data 2 = user defined filters -1 = all filters (default) • Note on Wintype: 0 = any window type (default) 2 = filters that support worksheets 5 = filters that support matrix fdlog.get(letter, n, part) This method is used to get the names of the files selected in the MultiOpen dialog box. The first argument is the string variable that will receive the name. The second argument is the index of the selected file you want to receive the name of. The first file has an index of one. The number of files selected with the MultiOpen dialog box is stored in the numeric variable count. Part specifies the portion of the filename you want to get and if not specified defaults to a value of 0. 0 = Full filename, 1 = file name only (no extension), 2 = file extension only. fdlog.get() returns 0 for failure and 1 for success. fdlog.getColStr(letter, n) This method is used to get the plot designation columns of the files selected in the MultiOpen dialog box. The first argument is the string variable that will receive the plot designation columns. The second argument is the index of the selected file you want to receive the plot designation columns of. The first file has an index of one. The number of files selected with the MultiOpen dialog box is stored in the numeric variable count. fdlog.getColStr() returns 0 for failure and 1 for success. fdlog.getTemplate(letter, n) This method is used to get the templates of the files selected in the MultiOpen dialog box. The first argument is the string variable that will receive the template name. The second argument is the index of the selected file you want to receive the template name of. The first file has an index of one. The number of files selected with the MultiOpen dialog box is stored in the numeric variable count. fdlog.getTemplate() returns 0 for failure and 1 for success. fdlog.gettypename(letter,n) The first argument is the variable that will receive the type information. The second argument is the index of the file you want to receive the type of. fdlog.multiOpen() Display the MuliOpen dialog box. This dialog box allows the user to select multiple files. The default path is the path specified in the fdlog.path$ property. The default file type is the type specified in the fdlog.defType property. The fdlog.get() method is used to get the names of the selected files. The number of files selected with the MultiOpen dialog box is stored in the numeric variable count.

fdlog.open(letter)

Display the Open dialog box. The default path is specified in the fdlog.path$property. The default file type is specified in the fdlog.defType property. This method returns zero for success or non-zero for failure. fdlog.reset() Resets all properties. fdlog.saveAs(letter) Display the Save As dialog box. The default path is specified in the fdlog.path$ property. The default file type is specified in the fdlog.defType property. This method returns zero for success or non-zero for failure.

fdlog.useGroup(groupName)

This method allows you to setup a dialog box using an Extension Group defined with the system.fileExt object. The argument is the name of the group. f successful, this method will have set the following properties: fdlog.defType, fdlog.numTypes, fdlog.path$, and fdlog.type$.

fdlog.useType(extensions)

This method should be used when you want to use a File Extension group, but not all the File Types in the group. You will still call UseGroup, but follow it with a call to UseType. The argument is the list of extensions for the File Types you want to appear in the File of Type combination box. All other file types will be removed. For example: If you have a group named Origin and this group contained the following types:

• [Project (*.OPJ)] *.OPJ
• [Old version (*.ORG)] *.ORG
• [Worksheets (*.OGW)] *.OGW
• [Graphs (*.OGG)] *.OGG
• [Matrix (*.OGM)] *.OGM

The command fdlog.useGroup(Origin) will setup the fdlog object with the above types. If you then call the command fdlog.useType("OPJ ORG") the last three types will be removed. The benefit gained from this method is that tracking will still occur.

## Examples:

This script reads in data, performs calculations, and creates plots. The script is divided into three sections. The first section, the main section, handles the import as well as makes calls to the next two sections - calculate and createplot. Open the LabTalk Editor, enter this script into the editor, and then save it as a script file in your Origin folder. For example, you could save it as MYOGSFILE.ogs.

[main]
fdlog.reset();
fdlog.usegroup(ASCII);
fdlog.multiopen();
loop (ii ,1 , FDlog.MultiOpen.Count)
{
Fdlog.Get(A, ii);  //get the first selected filename
win -t data;  //open a new worksheet
open -w %A;  //import the first file into the worksheet
run.section( , calculate);
run.section( , createplot, %H);
}
[calculate]
%(%H,wks.ncols) = %(%H,1) + %(%H,2);  //perform a calculation
[createplot]
%B=%H;
win -t plot line;  //open the line.otp graph template
layer -i %(%B,2);  //plot the second column in the worksheet
layer -a;  //rescale to show all

To run this script, execute the following line of script (for example, in the Script window):

run.section(MYOGSFILE,main);

This script opens the Open dialog box with *.OTP selected in the File Name text box and opens the selected graph template.

fdlog.reset();
fdlog.ShowComment = 0;
fdlog.UseGroup(Template);
fdlog.UseType(OTP);
if (fdlog.Open(A))
return 1;
%B = fdlog.Path\$;
doc -t %B%A;

This script opens the Open Multiple Files dialog box with *.DAT selected in the File Name text box and opens the selected ASCII files in new worksheets.

fdlog.reset();
fdlog.ShowComment = 0;
fdlog.UseGroup(Ascii);
fdlog.UseType(DAT);
if (fdlog.MultiOpen() != 0/0)
{
loop (ii, 1, fdlog.MultiOpen.Count)
{
win -t data Origin;
FDlog.Get(A, ii);
open -w %A;
}
}