OriginLab Corporation - Data Analysis and Graphing Software - 2D graphs, 3D graphs, Contour Plots, Statistical Charts, Data Exploration, Statistics, Curve Fitting, Signal Processing, and Peak Analysis     
 
Skip Navigation Links
All BooksExpand All Books
Code BuilderExpand Code Builder

6 Running and Debugging LabTalk Scripts

In Code Builder, the way to run an OGS file is through the LabTalk console. Whereas, to run and or/store LabTalk scripts, Origin provides in total 11 ways. For further information about running LabTalk scripts in Origin, please refer to LT Running Script. The debugging procedure for LabTalk scripts is the same as debugging Origin C code except for two additional features: Execute Current Section and Execute Selected Lines.

Running LabTalk Scripts in Code Builder

A LabTalk script usually consists of many sections which are declared by placing the desired section name in square brackets [] on its own line.

Running LabTalk Scripts 91 01.png

Note: If the section declaration did not start from the beginning of the script, the whole part above the first section will be treated as the main section.

To run an OGS file, select View:LabTalk Console to open LabTalk Console window. Type the following script into that window and press ENTER:

run.file(FileName)

It will execute all lines outside the declared sections, which is by default termed as our main section.

Running LabTalk Scripts 91 02.png

If you want to run a single section in the script, you can use the command below:

run.section(FileName,SectionName)

Or you can firstly identify that section as current section by highlighting the section name or by placing the cursor of the Code Builder text editor within the section name. Then click the Execute Current Section button Button Execute Current Section 02.png to run that section.

Running LabTalk Scripts 91 03.png

Debugging LabTalk Scripts in Code Builder

Most Code Builder debugging features of LabTalk scripts work the same as they do for Origin C code, with the condition that the script be saved in a text file of type *.ogs. Breakpoints can be set and cleared in LabTalk scripts and all Origin C code. Debug toolbar buttons work identically. In addition, the Debug toolbar has two buttons that only work for LabTalk script saved in text files of type *.ogs.

  • The Execute Current Section button Button Execute Current Section 02.png executes the current section of a script file. To start debugging with a specific section, first you have to identify that section as current section by highlighting the section name or by placing the cursor of the Code Builder text editor within the section name. After setting breakpoints in the current section, debugging mode will be enabled once you clicked Button Execute Current Section 02.png icon or selected Debug:Execute Current Section.


Debugging Lab Talk Script 91 01.png

  • The Execute Selected Lines button Button Execute Selected Lines 02.png executes selected (highlighted) lines in a LabTalk script file but will not enter debug mode even if a breakpoint is encountered.


The Code Builder Local Variables window does not display LabTalk variables (LabTalk variables have global scope, not local).

Debugging Lab Talk Script 91 02.png

However, the Watch window does display the values of all entered LabTalk variables including numeric, string, and system variables, section/macro arguments (e.g. %1), and even object properties.

Debugging Lab Talk Script 91 03.png

Finally, the Code Builder Call Stack places and displays called script sections on the call stack along with Origin C function calls. The Code Builder Debugger seamlessly steps from sections of LabTalk script into Origin C code and back again.

Debugging Lab Talk Script 91 04.png

 

© OriginLab Corporation. All rights reserved.