These notes pertain to changes and improvements made to the LabTalk scripting language in Origin version 8.0. If you have script code developed in older versions such as 7.5, you may want to update your code to take advantage of the new features, as well as fix any compatibility issues with your script in later versions of Origin.
Many LabTalk commands act on an 'active' object such as a Worksheet, plotted data or column. This often required scripts to manage windows by remembering which window is a Worksheet and which is a Graph (or second Worksheet) and switch back and forth between these windows using the "window -a" command.
Variables were undeclared and global in scope.
Some Commands also can be destructive of data and require working on a copy if you need the original data.
Declared variables have context only in the procedure in which they are declared.
Range Variables can point to various Origin objects and eliminate the need for an object being active.
X-Functions can accept range variables as Input and Output and separate data from analysis results as well as providing additional features such as automatic update and a higher level of program function.
Suppose we want to look at Line graphs of the derivatives of data in multiple files.
In Origin 7.5, you could import multiple ASCII files into New sheets, New Columns or New Rows. These options can be manipulated by reading and writing a special structure in the worksheet, but Since the latter two would create a management headache, we will stick with New Sheets (the default). Since it would be difficult to know which sheets get created, we will delete the empty worksheet in a new Origin project before we begin.
To plot our data, we could create a graph window, remember it's name, loop over all worksheets (again), get the name of the data we want to add to the plot and temporarily switch to the graph to add the data.
Instead, I'll use a variable (count) so I know when I'm in the first pass of my Worksheet loop to create my first plot, then in subsequent loops, I will just note the name of the derivative data so I can temporarily switch to the graph (assuming I remembered its name) to add the data to my plot.
An understanding of this sequence was a requirement to writing the code.
Now let's make use of ranges and X-Functions and see how newer versions of Origin complete our task.
We begin with two X-Functions. The first prompts for the files to be imported, while the second directs how to import those files.
It seems our old "run.section(file,MultiImportToolbar);" has been split in two, but the "dlgfile" function can be used in many other cases where we need to prompt for a file or files. The "impasc" X-Function now incorporates various options as part of its arguments, replacing many lines when options need to be modified.
which the plotxy X-Function interprets as a multiple XY range to create the final plot with one command.
Some changes to the language accommodate new features or fix a problem can cause old scripts to break.
When assigning values to a string variable,there should be no space between the variable name and '$'.
%D used to contain the name of the last Set Dataset. It now contains the Current Working Directory when executing commands in the Command or Script Window.
The property "wks.col#.justify" used to control left-center-right justification.