LabTalk Object Type:
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
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.
0 = filters for ASCII data 1 = filter for Binary data 2 = user defined filters -1 = all filters (default)
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:
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. |
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] wks.addcol(); //add a column to the worksheet %(%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; } }