Overview of the LabTalk Language

Introduction

Identifiers

Data Types

Operators

Performing Calculations

Substitution Notation

Keywords

Programming Syntax and Structure

Calling Origin C Functions from LabTalk


Introduction

Prior to Origin 7, LabTalk was the language for programming Origin. However, Origin 7 offers a new and improved programming language called Origin C.

LabTalk is OriginLab’s proprietary programming language. LabTalk scripts are interpreted during execution by Origin.

Origin C supports a nearly complete ANSI C language syntax as well as a subset of C++ features including internal and DLL-extended classes. Furthermore, Origin C code is compiled to byte code form and therefore executes much faster than LabTalk.

  • If you are just getting started programming in Origin, you should think about using the Origin C programming language. To learn more about programming with Origin C, see the Introduction to Origin C.

  • If you have programmed with LabTalk in a previous version of Origin, your LabTalk scripts will work in Origin 7. However, you should consider upgrading your scripts to Origin C, particularly if you are performing numerical computational loops. In this case, Origin C code can be up to a factor of 20 times faster than LabTalk. For instance, if you have defined a fitting function using the Y-script form and the function includes computational loops, you will notice a significant improvement in speed if you re-write your function in Origin C and compile it.

To learn more about the LabTalk changes in version 7, review the product Release Notes.


Identifiers

Variable, dataset, command, and macro names are known as identifiers. Identifiers are composed of any combination of letters and numbers, but cannot be more than 25 characters in length. In addition, the first character cannot be a number.

Use the exist( identifier) function to check if an identifier is being used to name a window, macro, tool, dataset, or variable.

Note 1: Certain identifiers are reserved for system use by Origin.

Note 2: The underscore character "_" has a special meaning in dataset names and should be avoided.


Data Types

Data objects represent values that can be combined into mathematical expressions. Origin recognizes four classes of data objects:

  • numeric variables

  • string variables

  • datasets

  • functions


Numeric Variables

A variable is a space set aside for data in the computer’s memory. Each variable is given a name, or identifier, with which its data can be assigned or accessed. LabTalk numeric variables hold double precision real numbers which can accurately represent the standard variable types: integer, long, and float.

A LabTalk variable CANNOT:

  • Start with a number.

  • Start with an operator.

  • Contain a period (.).

The assignment operator "=" is used to simultaneously create a variable (if it does not already exist) and assign to it a value. For example, entering the following assignment statement in the Script window:

A = 52

creates the variable A, and sets A equal to 52.

To see the value of a variable, type the variable in the Script window, followed by an equal sign:

A =

Press ENTER and Origin responds with:

A = 52


String Variables

  • String variables are named spaces in computer memory which hold strings, which are one-dimensional arrays of characters.

  • String variables are used to store text.

  • String variable names are comprised of a % character followed by a single alphabetic character (a letter from A to Z).

To learn more, see:

Assigning Values to a String Variable

Expressing the Variable Before Assignment

String Comparison

Substring Notation


Assigning Values to a String Variable

Entering the following assignment statement in the Script window:

%A = John

defines the contents of the string variable %A to be John.

String variables can also be used in substitution notation. Using substitution notation, enter the following assignment statement in the Script window:

%B = %A F Smith

This sets %B equal to John F Smith.

Thus, the string variable to the right of the assignment operator is expressed, and the result is assigned to the identifier on the left of the assignment operator.

As with numeric variables, if you enter the following assignment statement in the Script window:

%B =

Origin returns the value of the variable:

John F Smith


Expressing the Variable Before Assignment

By using parentheses, the string variable on the left of the assignment operator can be expressed before the assignment is made.

For example, enter the following assignment statement in the Script window:

%B = Data1_A

This statement assigns the string variable the value Data1_A. If Data1_A is a dataset name, then entering the following assignment statement in the Script window:

(%B) = 2*%B

results in the dataset being multiplied by 2. %B, however, still contains the string Data1_A.


String Comparison

aaa = 4;

bbb = 4;

%A = aaa;

%B = bbb;

if ("%A" == "%B")

type "YES";

else

type "NO";

The result will be NO, because in this case aaa != bbb.

aaa = 4;

bbb = 4;

%A = aaa;

%B = bbb;

if (%A == %B)

type "YES";

else

type "NO"

The result will be YES, because in this case the values of the strings (rather than the characters) are compared, and aaa == bbb == 4.

String Comparison

When comparing string variables, use the "equal to" operator (==).

  • If string variables are surrounded by quotation marks (as in, "%a"), Origin compares the string characters (example).

  • If string variables are not surrounded by quotation marks (as in, %a), Origin compares the values of the string variables (example).


Substring Notation

Enter:

%B = %[%A, ’_’]; %B =

Return value: Results from Data2

Enter:

%B = %[%A, >‘_’]; %B =

Return value: Test

Enter:

%B = %[%A, 8]; %B =

Return value: Results

Enter:

%B = %[%A, 14:18]; %B =

Return value: Data2

Enter:

%B = %[%A, #2]; %B =

Return value: from

Enter:

ii = %[%A]; ii =

Return value: ii = 23

Script:

%A = 123 342 456;

for (ii = 1; ii <= 3; ii+ = 1)

{

data1_a[ii] = %[%A, #ii,\t]

};

Return value: Places the value 123 in data1_a[1], 342 in data1_a[2], and 456 in data1_a[3].

Script:

%Z = “First line

second line”;

%A = %[%Z, @2];

Return value: Places the second line of the %Z string into %A. To verify this, type %A = in the Script window.

  • Space characters are not ignored.

  • String length notation includes space characters.

For example, to set %A equal to <space>5<space>, type the following in the Script window:

%A = " 5 " (ENTER)

To find the length of %A, type the following in the Script window:

ii = %[%A]; ii= (ENTER)

Origin returns: ii = 3

A token can be a word surrounded by white space (spaces or TABS), or a group of words enclosed in any kind of brackets. For example, if:

%A = These (are all) “different tokens”

then entering the following in the Script window:

%B = %[%A, #1]; %B =

returns: These

%B = %[%A, #2]; %B =

returns: are all

%B = %[%A, #3]; %B =

returns: different tokens

Substring Notation

Substring notation returns the specified portion of a string. The general form of this notation is:

%[string,argument];

where string contains the string, and argument specifies which portion of the string to return.

For the examples which follow, enter this assignment statement in the Script window:

%A = “Results from Data2_Test”

The following examples illustrate the use of argument in substring notation:

  • Search for a character and return all text to the left of the character:

  • Search for a character and return all text to the right of the character:

  • Return all text to the left of the specified character position:

  • Return all text between two specified character positions (inclusive):

  • Return the #n token, counting from the left:

  • Return the length of the string:

Other examples of substring notation:

  • Return the ith token separated by a specified separator (in this case, a tab):

  • Return the @n line:

For more information on typing script on multiple lines in the Script window, see Using Semicolons in LabTalk.

When using quotation marks in substring or substitution notation:

A Note on Tokens


Datasets

  • A dataset is an object consisting of a one-dimensional array that can contain numeric and/or text values.

  • The individual values in a dataset are called elements.

  • Each element in a dataset is associated with an index number, by which individual elements can be accessed. In a worksheet, the index number corresponds to the row number. Note that in contrast to Origin C convention, the LabTalk index number starts at 1.

A dataset is often associated with a worksheet column and/or one or more data plots. Datasets are defined such that, when a dataset is deleted, associated worksheet columns and data plots are also deleted.

To learn more, see:

Creating a Dataset

Dataset and Worksheet Names

Assigning Values to a Dataset

Accessing Dataset Elements

Accessing Interpolated or Extrapolated Points

Accessing Matrix Elements

Working with Excel Workbook Datasets in Origin


Creating a Dataset

Entering the following script in the Script window

Sample1 = data(100,800,3)

creates the dataset Sample1, with values that begin at 100, end at 799 (802 exceeds 800), and increment by three. To display the dataset in the Sample1 worksheet, enter the following script in the Script window:

edit Sample1

If the data1_a dataset already exists but the data1_c dataset does not, entering the following script in the Script window

data1_c = data1_a

creates the data1_c dataset and assigns it the values (row by row) from data1_a. To display the data1_c in the Data1 worksheet, enter the following script in the Script window:

edit data1_c

Creating a Dataset

When a worksheet is created Origin creates one dataset object for each worksheet column. The datasets take their names from the worksheet name followed by an underscore character and the column name (e.g., data1_b).

There are several ways to create datasets:

  • A worksheet with an X and Y dataset can be created with the window command. Use

window -t data template [winName]

to create a worksheet named winName based on the template template.

  • Datasets can be created using the create command. By default, the create command creates a numeric dataset. To create a dataset that can store strings, use create -s.

  • Datasets can be created using the data() function. See example

  • Datasets can be created during a dataset assignment operation. If the dataset on the left side of the assignment operator does not exist, Origin creates it. See example

To change a column's plot designation (X, Y, and Y error) in a worksheet, use the worksheet -t command.

For information on performing calculations with datasets, see Vector Calculations.


Entering the following command in the Script window:

create ExperimentalData_Series1 1000

creates a dataset named ExperimentalData_Series1, which has 1000 values. By default, the dataset values are zero. When you associate a worksheet with this dataset, for example, by entering the following command in the Script window:

edit ExperimentalData_Series1

Origin creates a worksheet named ExperimentalData containing an A(X)and a Series1 column. The data markers for the worksheet are set to display 1000 values.

Dataset and Worksheet Names

Every dataset is associated with a unique name, which follows the naming conventions for identifiers. For information on identifier naming conventions, see Identifiers.

  • If the dataset name contains an underscore character " _ ", the portion of the name preceding the underscore becomes the worksheet name, while the part that follows the underscore becomes the column name.

  • If there is no underscore, the column is not named.

For example:

For more information on data markers, see the Origin Help file.


Assigning Values to a Dataset

Use the following syntax:

dataset = {v1, v2,...vn};

where v1, v2, ... vn are literal values, meaning the actual values are entered. For example:

data1_a = {2, 5, 9, 17, 32}

Use the following (general) syntax:

dataset = scalar;

Before assigning values to a dataset using this notation, you must set the end of the dataset display range using the set command. For example, to set the end of the display range to 20 for the data1_a dataset, type the following in the Script window:

set data1_a -e 20

Once you've set the display range, you can then assign a scalar to each element in the range. For example, enter the following script in the Script window:

data1_a = 9

to set every value in data1_a to 9.

For more information on scalar notation, see Scalar Calculations.

Assign the values from one dataset to another dataset using the following syntax:

dataset1 = dataset2;

Unlike scalar assignment, you do not need to set the display range prior to assignment. For example, entering the following assignment statement in the Script window:

data1_b = data1_a

sets every value in data1_b equal to the value at the corresponding index number in data1_a.

You can also use datasets in expressions in an assignment statement using the following (general) notation:

dataset1 = dataset2 operator dataset3;

For example, entering the following assignment statement in the Script window:

data1_a = data1_a * data1_b

sets every value in data1_a equal to the product of data1_a and data1_b.

For more information on vector notation, including using interpolation to set values, see Vector Calculations.

Origin supports direct arithmetic operations on datasets from the Script window. (You cannot use this feature from any location but the Script window.)

For example, to add 5 to all highlighted cells in a worksheet column, enter the following in the Script window:

+5

Origin applies this arithmetic operation to the active dataset.

Note: The %C string system variable holds the name of the active dataset.

The data(x1, x2, inc) function fills the specified dataset with an initial value of x1, a final value of x2, and an increment equal to inc. If x1 is set equal to x2, inc number of points with values equal to x1 are returned. If inc is omitted, inc = 1 is assumed.

For example, the following script fills the first five rows of column A with the number 10:

col(A) = data(10, 10, 5);

The next script fills column A with 100 values from 1 to 100, with an increment of one.

col(A) = data(1, 100);

The col(colname) function can also be used to assign values to a dataset. Colname is the name or numerical position of a worksheet column. To use the col(colname) function:

  • the dataset must be associated with a worksheet

  • the worksheet must be the active window.

For example, if the data1 worksheet is active, entering the following assignment statement in the Script window:

col(a) = col(b)

is identical to entering:

data1_a = data1_b

If column a and column b are the first two columns in the worksheet, the following assignment statement can be entered in the Script window:

col(1) = col(2)

The following example creates the dataset NewData_B (if necessary) containing the sum of the values in columns 2 and 3 in the active worksheet:

NewData_B = col(2) + col(3);

In addition to referencing a column, the col() function can use brackets to access a specific worksheet element. For example, entering the following script in the Script window:

n = col(A)[2]; n =

returns the element in row 2 of column A (in the active worksheet).

The next example fills each cell (from ii = 1 to ii = 109) in column A of the active worksheet with the square of the row number:

for (ii = 1; ii < 110; ii + 1)

{col(a)[ii] = ii^2};

Assigning Values to a Dataset

To import data into a worksheet using LabTalk, see the getfile and open commands, and the db object (ODBC).

To copy data to a worksheet using LabTalk, see the copy command.

There are a number of LabTalk methods for assigning values to a dataset:

  • Create a Dataset with Multiple Known Values

  • Assign a Scalar Value to Each Element of a Dataset

  • Vector Notation

  • Performing Direct Arithmetic from the Script Window

  • Using the data() Function

  • Using the col() Function


Accessing Dataset Elements

When using this notation, you must include the row number in the brackets [i].

To assign value to the ith element in the dataset, use the following notation:

datasetname[i] = value;

For example, enter the following assignment statement in the Script window:

data1_a[3] = 9

to set the element at index number (row number) 3 in data1_a to 9.

In this case, you must include the $ character after the brackets.

To set the third cell in column A of the active worksheet to "any text", enter the following script in the Script window:

col(A)[3]$ = “any text”

Additional script examples follow:

%A = “any text”; col(A)[i]$ = %A;

Data1_A[i]$ = “any text”;

%A = col(A)[i]$;

%A = Data1_A[i]$;

%(WorksheetName, ColumnNumber, RowNumber) = value;

If the third cell in the fourth column in the data1 worksheet contains the value 25, then the following script:

A = %(data1, 4, 3);

sets the variable A equal to 25.

For more information, see %( ) Substitution.

cell(rowNumber, colNumber)

To specify a worksheet other than the active worksheet, use the notation:

wksName!cell(rowNumber, colNumber)

For example, to assign the value in column 3, row 50 to the %W string variable, type the following script in the Script window:

%W = cell(50, 3)$

To assign the value 100 to column 2, row 5 of the Data3 worksheet, type the following script in the Script window:

Data3!cell(5, 2) = 100

Accessing Dataset Elements

  • You can use brackets [] to access elements in a dataset.

  • You can also use the bracket [] notation to access text dataset elements.

  • You can use %() substitution notation to access a dataset element.

  • You can use the cell() function to get or set a cell in the worksheet.


Accessing Interpolated or Extrapolated Points

and you enter the following script in the Script window:

data1_b[2] =

Origin returns:

DATA1_B[2] = 4

The bracket [] notation instructs Origin to return the cell value of a specified dataset at a specified row number.

yDataset(interpolatedXValue) =

yDataset(extrapolatedXValue) =

This notation returns the corresponding interpolated (or extrapolated) Y value in yDataset.

In the case of the previous example, you could instruct Origin to use linear interpolation to find the corresponding Y value at an X value equal to 2.5. To do this, enter the following script in the Script window:

data1_b(2.5) =

Origin returns:

DATA1_B(2.5) = 5

destinationDataset = yDataset(xDataset);

This notation can be illustrated with an example. Suppose you have columns of data containing capacitance vs. pressure and capacitance vs. voltage and the capacitance columns do not contain the same values.

You can use linear interpolation to find the relationship between pressure and voltage. To do this, first add two columns to the worksheet as follows (note that A is designated as X):

Then enter the following script in the Script window pressing ENTER after each line:

data1_a = data1_Pressure

data1_b = data1_Voltage(data1_Capac1)

The first line of script copies the data1_Pressure dataset as the new X variables. The second line of script computes the values of the data1_Voltage dataset using the X values of data1_Capac1. The last two columns will have the relationship between pressure and voltage.

Accessing Interpolated or Extrapolated Points

When you use the datasetName[i] notation to access an element in a dataset, i must be an index number (row number) within the range of the dataset. For example, if the following worksheet is active

You can also use linear interpolation or extrapolation on a specified X dataset to find the corresponding interpolated or extrapolated value in a Y dataset. This requires using a new notation with parentheses () instead of brackets [].

In addition to finding one interpolated Y value at a specified interpolated X value, you can find all the values for a Y dataset using a specified X dataset. The notation for this follows:


Accessing Matrix Elements

cellValue = MatrixName[N*(i - 1) + j]

where:

N = the number of columns in the matrix.

i = the row number in the matrix.

j = the column number in the matrix.

For example, if Matrix1 has the following values:

If you enter the following script in the Script window:

Matrix1[7] =

Origin will return:

MATRIX1[7] = 14

cell(rowNumber, colNumber)

where rowNumber is the numeric value of the row and colNumber is the numeric value of the column.

Thus, with the previous matrix, if you enter the following script in the Script window:

cell(2, 3) =

Origin will return:

cell(2, 3) = 14

To specify a matrix other than the active matrix, use the notation:

matrixName!cell(rowNumber, colNumber)

Accessing Matrix Elements

A matrix is stored as a single-dimensional array using row major ordering. You can access a matrix value using the following syntax:

You can also use the cell() function to access a matrix value. The notation is:


Working with Excel Workbook Datasets in Origin

layer -s

This command makes the hidden Origin worksheet layer (that is associated with the currently active sheet) active and receptive to LabTalk commands.

The layer -s command must also be executed if you add a sheet to your workbook. After executing the command, Origin creates a hidden Origin worksheet layer that is associated with the new workbook sheet.

set WorkbookName -ui

For example, to update the hidden Origin worksheet layer for the active sheet of the Book1 workbook, enter the following command in the Script window:

set Book1 -ui

To update a specific column (dataset), without updating the entire sheet, use the following syntax:

set WorkbookName_ColumnName -ui

set WorkbookName -ue

To update a specific column (dataset), without updating the entire sheet, use the following syntax:

set WorkbookName_ColumnName -ue

WorkbookName_ColumnName@SheetNumber

Where WorkbookName is the workbook name, ColumnName is the workbook column name, and SheetNumber is the numeric value reflecting the order in which data was plotted from the sheets in the workbook. (Do not include @1 for datasets from the first plotted sheet.)

%(WorkbookName,@DN,ColumnName)

%(WorkbookName,@DN,ColumnName,RowNumber)

Where WorkbookName is the workbook name, ColumnName is the workbook column name, and RowNumber is the row index number. Type @DN literally.

To set a workbook cell value in the active workbook sheet, use the following syntax:

WorkbookName_ColumnName@SheetNumber[RowNumber] = value

or

%(WorkbookName,@DN,ColumnName,RowNumber) = value

To set the value of the fourth cell in column C of the first sheet (from which data was plotted) in the Book1 workbook to 245, enter the following in the Script window:

Book1_C[4] = 245

or

%(Book1,@DN,C,4) = 245

Note that in the first script example, the @1 is not included.

If you change the active sheet from Sheet1 to another sheet, you must update Origin with this sheet change before setting a cell value. To update Origin with the sheet change, enter the following in the Script window:

layer -s

To set the value of the third cell in column D of the currently active sheet in the Book1 workbook to 579, enter the following in the Script window:

%(Book1,@DN,D,3) = 579

Alternatively, if we assume that the currently active sheet is the second sheet from which data was plotted, you could also enter the following in the Script window:

Book1_D@2[3] = 579

The first script example is preferred, as this syntax does not require knowledge of the order in which data was plotted from the sheets. The second script example requires that you know that the currently active sheet is the second sheet from which data was plotted.

Before you can plot the data values added using script, you must update the hidden Origin worksheet layer with the new cell values. To do this, use the following syntax:

Set WorkbookName -ui

For example, enter the following in the Script window:

Set Book1 -ui

To read a workbook cell value in the active workbook sheet, use the following syntax:

WorkbookName_ColumnName@SheetNumber[RowNumber] =

or

%(WorkbookName, @DN, ColumnName, RowNumber) =

To read the value of the fourth cell in column C of the first sheet (from which data was plotted) in the Book1 workbook, enter the following in the Script window:

Book1_C[4] =

or

%(Book1,@DN,C,4) =

Note that in the first script example, the @1 is not included.

If you change the active sheet from Sheet1 to another sheet, you must update Origin with this sheet change before reading a cell value. To update Origin with the sheet change, enter the following in the Script window:

layer -s

To read the value of the third cell in column D of the currently active sheet in the Book1 workbook, type the following in the Script window:

%(Book1,@DN,D,3) =

Alternatively, if we assume that the currently active sheet is the second sheet from which data was plotted, you could also enter the following in the Script window:

Book1_D@2[3] =

Working with Excel Workbook Datasets in Origin

Datasets in the Excel workbook can be accessed using LabTalk. However, accessing workbook datasets differs from accessing Origin worksheet datasets.

When a workbook contains multiple sheets, each workbook sheet has an associated hidden Origin worksheet layer in the workbook window. If you change the active workbook sheet, you must update Origin regarding the sheet change before issuing a LabTalk command to access a dataset on the newly active workbook sheet.

To update Origin after changing sheets, enter the following command in the Script window:

When data is typed or pasted into a workbook sheet, you must update the hidden Origin worksheet layer before you can read cell values using LabTalk. To update the hidden Origin worksheet layer associated with a workbook, use the following syntax:

When plotted workbook data is modified, for example, by an analysis option, you must update the data in the workbook. To update the workbook, use the following syntax:

Excel workbook datasets are named using the following syntax:

In addition to referencing Excel workbook datasets using the WorkbookName_ColumnName@SheetNumber syntax, you can reference workbook datasets using substitution notation. Substitution notation is the preferred syntax for referencing workbook datasets. When you use this syntax, you do not have to keep track of the order in which you plotted data from the workbook sheets. Origin executes the command for the active sheet.

  • To reference a workbook dataset, use the following substitution notation syntax:

  • To reference a workbook dataset cell, use the following substitution notation syntax:

  • Setting a Workbook Cell Value:

  • Setting a Cell Value in the First Workbook Sheet from which Data was Plotted:

  • Setting a Cell Value in Another Workbook Sheet:

  • Reading a Workbook Cell Value:

  • Reading a Cell Value in the First Workbook Sheet from which Data was Plotted:

  • Reading a Cell Value in Another Workbook Sheet:


Functions

Origin provides the function graph template FUNCTION.OTP to define and plot new functions and to make datasets based on the functions.

To access the Function graph template:

  1. Click the New Function [image] button on the Standard toolbar. This action opens the Function tab of the Plot Details dialog box. A Function graph window based on the Function graph template also opens.

  2. Enter the desired function in the F1(x)= text box of the Plot Details dialog box. You can use any LabTalk operator or built-in function in your function definition.

  3. Click OK to close the dialog box and include the function in the graph window.

A function can be defined whenever a graph window is active. With the graph window active, select Graph:Add Function Graph. This menu command also opens the Function tab of the Plot Details dialog box.

You can also define a function in the Script window. To do this, type the following line in the Script window and press ENTER:

funcname(x) = expression

where funcname is the new function name and expression is a function of x. For example, enter the following script in the Script window:

Salary(x) = 52 * x

Once you have defined a function, it can be referred to by name and used as you would a built-in LabTalk function (for example, the function can be used in mathematical expressions in the Set Column Values dialog box, the Extract Worksheet Data dialog box, and the Script window).

In addition, a dataset is associated with each user-defined function and can be plotted like any other dataset. As with other datasets, user-defined functions are listed in the Available Data list in the Layer n dialog box.

User-defined functions are saved with the Origin project. To access a particular function that you have saved with another project, do one of the following:

  • Append the Origin project which contains the function to your current project. To append an Origin project file, select File:Append from the Origin menu.

  • Open your original project and save your function graph as an .OGG file (File:Save Window As), then open the .OGG file in the current project.

Functions

Origin allows you to define your own LabTalk functions of the following form:

y = f(x)

You can define LabTalk functions using:

  • The Function graph template.

  • The Graph:Add Function Graph menu command.

  • The Script window.

Using User-defined Functions

Saving and Accessing User-defined Functions


Operators

LabTalk supports assignment, arithmetic, logical, relational, and conditional operators. These operations can be performed on scalars and in many cases they can also be performed on vectors (datasets). For more information on scalar and vector calculations, see Performing Calculations.

Origin also provides a variety of built-in numeric, trigonometric, and statistical functions which can act on datasets.

When evaluating an expression, Origin observes the following precedence rules:

  1. Exposed assignment operators (not within brackets) are evaluated.

  2. Operations within brackets are evaluated before those outside brackets.

  3. Multiplication and division are performed before addition and subtraction.

  4. The (>, >=, <, <=) relational operators are evaluated, then the (== and !=) operators.

  5. The logical operators && and || are evaluated in the order listed.

  6. Conditional expressions (?:) are evaluated.


Arithmetic Operators

Enter the following script in the Script window:

1.3 ^ 4.7 =

After pressing ENTER, 3.43189 is printed in the Script window.

Enter the following script in the Script window:

if (27&41 == 9)

{type "Yes!"}

After pressing ENTER, Yes! is typed to the Script window.

Note:

27&41 == 9

because

27 = 0000000000011011

41 = 0000000000101001

with bitwise & yields:

0000000000001001 (which does equal 9)

Note: Multiplication must be explicitly included in an expression (for example, 2*X rather than 2X to indicate the multiplication of the variable X by the constant 2).

Arithmetic Operators

Origin recognizes the following arithmetic operators:

Operator | Use
+ | Addition
- | Subtraction
* | Multiplication
/ | Division
^ | Exponentiate (X^Y raises X to the Yth power)*
& | Bitwise And operator. Acts on the binary bits of a number.
| | Bitwise Or operator. Acts on the binary bits of a number.

*Important note: For 0 raised to the power n (0^n): If n > 0, 0 is returned. If n < 0, a missing value is returned. If n = 0, then 1 is returned (if @ZZ = 1) or a missing value is returned (if @ZZ = 0).

These operations can be performed on scalars and on vectors (datasets). For more information on scalar and vector calculations, see Performing Calculations.

The following example illustrates the use of the exponentiate operator:

The next example illustrates the use of the ‘bitwise and’ operator:


A Note about Logarithmic Conversion

  • To convert a dataset to a logarithmic scale, use the following syntax:

col(c) = log(col(c));

  • To convert a dataset back to a linear scale, use the following syntax:

col(c) = 10^(col(c));


In this example, 5 is subtracted from the value of A and the result is assigned to A:

A -= 5;

Data1_B /= Data1_A;

The script types the first ten values in the second column of the Data1 worksheet to the Script window: (For information on %( ) substitution notation, see $( ) Substitution.)

for (ii = 1; ii <= 10; ii += 1)

{type "%(Data1, 2, ii)"; }

Assignment Operators

Origin recognizes the following assignment operators:

Operator | Use
= | Simple assignment.
+= | Addition assignment.
-= | Subtraction assignment.
*= | Multiplication assignment.
/= | Division assignment.
^= | Exponential assignment.

These operations can be performed on scalars and on vectors (datasets). For more information on scalar and vector calculations, see Performing Calculations.

The following example illustrates the use of the -= operator.

In the next example, each value in Data1_B is divided by the corresponding value in Data1_A, and the resulting values are assigned to Data1_B.

In addition to these assignment operators, LabTalk also supports the increment and decrement operators for scalar calculations (not vector).

  • ++ Add 1 to the variable contents and assign to the variable.

  • -- Subtract 1 from the variable contents and assign to the variable.

This for loop expression illustrates a common use of the increment operator:


Logical and Relational Operators

if (%A == ""){type "empty"};

x = 1; // variable x is set to 1

%a = x; // string a is set to "x"

if (%a == 1);

type "yes";

else

type "no";

The result will be yes, because Origin looks for the value of %a (the value of x), which is 1.

In the following script:

x = 1; // variable x is set to 1

%a = x; // string a is set to "x"

if ("%a" == 1)

type "yes";

else

type "no";

The result will be no, because Origin finds the quotation marks around %a, and therefore treats it as a string, which has a character x, rather than the value 1.

Logical and Relational Operators

Origin recognizes the following logical and relational operators:

Operator | Use
> | Greater than.
>= | Greater than or equal to.
< | Less than.
<= | Less than or equal to.
== | Equal to.
!= | Not equal to.
&& | And.
|| | Or

An expression involving logical or relational operators evaluates to either true (non-zero) or false (zero).

You can use the == and != operators to compare two strings. String comparison (rather than numeric comparison) is indicated by open and close double quotations (" ") either before, or after, the operator.

The following script determines if the %A string is empty:

The following examples illustrates the use of the == operator:


Conditional Operators

The ternary operator ?: can be used in the form:

Expression1 ? Expression2 : Expression3

This expression first evaluates Expression1. If Expression1 is true (non-zero), Expression2 is evaluated. The value of Expression2 becomes the value for the conditional expression. If Expression1 is false (zero), then Expression3 is evaluated and Expression3 becomes the value for the entire conditional expression.

Note that Expressions1 and Expressions2 can themselves be conditional operators.

The following example assigns the value which is greater (m or n), to variable:

In this example, the script replaces all column A values between 5.5 and 5.9 with 5.6:

Note: A Threshold Replace function treplace(dataset, value1, value2 [, condition]) is also available for reviewing values in a dataset and replacing them with other values based on a condition. In the treplace(dataset, value1, value2 [, condition]) function, each value in dataset is compared to value1 according to the condition. When the comparison is true, the value may be replaced with Value2 or -Value2 depending on the value of condition. When the comparison is false, the value is retained or replaced with a missing value depending on the value of condition. The treplace() function is much faster than the ternary operator.


Performing Calculations

You can use LabTalk to perform both

  • scalar (e.g., performing a calculation and store the result in a numeric variable).

and

  • vector operations (e.g., performing a calculation between datasets).

Scalar Calculations

Vector Calculations


Scalar Calculations

You can use LabTalk to express a calculation and store the result in a numeric variable. For example, consider the following script:

inputVal = 21;

myResult = 4 * 32 * inputVal;

The second line of this example performs a calculation and creates the variable, myResult. The value of the calculation is stored in myResult.

When a variable is used as an operand, and will store a result, shorthand notation can be used. For example, the following script:

B = B * 3;

could also be written:

B *= 3;

In this example, multiplication is performed with the result assigned to the variable B. Similarly, you can use +=, -=, /=, and ^=. Using shorthand notation produces script that executes faster.


Vector Calculations

In addition to performing calculations and storing the result in a variable (scalar calculation), you can use LabTalk to perform calculations on datasets.

Vector calculations can be performed row by row, or linear interpolation can be used if the datasets have different numbers of elements.


Row by Row Calculations

Start with the following worksheet:

Execute the following script:

data1_C = data1_A * data1_B;

The elements of data1_A are multiplied by the corresponding elements of data1_B and the product of each multiplication is put in the corresponding rows of the data1_C dataset.

The resultant worksheet displays as follows:

data1_b = 3 * data1_a;

In this example, every element of the data1_a dataset is multiplied by 3. The results are put into the corresponding rows of the data1_b dataset.

If you were to instead execute the following script (assuming newData does not previously exist):

newData = 3 * data1_A;

then a temporary dataset called newData is created and assigned the result of the vector operation. Elements of the temporary dataset can be accessed in the same way you would access an element of a dataset contained in a worksheet.

Row by Row Calculations

Vector calculations are always performed row by row when you use the general notation:

dataset = scalar operator dataset

or

dataset = dataset operator dataset

This is the case even if the datasets have different numbers of elements (for example).

An example of a vector calculation involving a scalar:


Calculations Using Interpolation

Consider the following two dependent datasets, each with its own set of independent data:

If you subtract baseline_b from signal_b by entering the following script in the Script window:

signal_b -= baseline_b

then the subtraction is performed row by row (with no linear interpolation):

However, if you use a dataset operator dataset assignment-operation statement (starting with the initial worksheet values) in the Script window:

signal_b - baseline_b

then linear interpolation of the second dataset (baseline_b) within the domain of the first dataset (signal_b) is used to carry out the subtraction. The results are stored in the first dataset (signal_b). The following figure shows the results of this calculation, when starting with the initial worksheet values.

dataset operator-O dataset

Thus, in this example, you would enter the following script in the Script window:

signal_b --O baseline_b

The following figure shows the results of this calculation, when starting with the initial worksheet values.

In this example, the option switch caused linear interpolation of baseline_b to be used within and outside of its domain in order to perform the calculation for the entire domain of signal_b.

In addition to using the subtraction operator with the -O option, you can use the addition (+), multiplication (*), division (/), and exponentiate (^) operators with -O.

Calculations Using Interpolation

When you use one of the following notations to perform vector operations:

dataset = scaler operator dataset

or

dataset = dataset operator dataset

row by row calculations are performed even if the datasets have different numbers of elements. There may be situations when you want to use linear interpolation when performing calculations on datasets of different sizes (for example).

In the previous example, interpolation was used to find the Y values of baseline_b using the X values given by signal_a within the X domain of baseline_b. In order to have Origin perform the interpolation outside the domain of the second dataset (in this case, baseline_b) for all X values of the first dataset, you need to specify an option switch (-O). The syntax using this option switch is:

Note: Unsorted data or duplicate Y values for any given X value will affect linear interpolation results.


Substitution Notation

When a script is executed, it is sent to the LabTalk interpreter. Among other tasks, the interpreter searches for two types of special substitution notation which are identified by their initial characters, % or $. When a substitution notation is found, it is sent to the substitution processor, which replaces the original string with another string, as described in the following section. The value of the substituted string is unknown until the statement is actually executed. Thus, this procedure is called a run-time string substitution.

Note: Both %() and $() substitution notation are always substitution-processed, even when enclosed in quotes as part of a text string.

%( ) Substitution

$( ) Substitution


%( ) Substitution

%(worksheetName, columnNumber, rowNumber);

For example, if the third cell in the fourth column in the data1 worksheet contains the value 25, then entering the following statement in the Script window:

A = %(data1, 4, 3)

sets A equal to 25.

The %() substitution notation can be combined with system variables. For example, entering the following script in the Script window:

%(%H, selc1, selr1) =

returns the element in the top left cell of the current selection range.

To return the contents of a text cell, use a string variable:

%A = %(data1, 4, 3); %A =

%(worksheetName,columnNumber);

For example, enter the following assignment statement in the Script window:

%B = %(%H, 1); %B =

In this example, the name of the dataset in column 1 in the active worksheet is substituted for the expression on the right, and then assigned to %B.

Note: If the assignment is made to a dataset, rather than a dataset name, LabTalk assigns the data, rather than the name of the dataset.

%(columnNumber, @L);

For example, the following script returns the column label for the first column in the active worksheet:

%N = %(1, @L); %N =;

%(worksheetName, @option, columnNumber);

where option is one of the following:

Option | Return Value
@# | Returns the total number of worksheet columns. ColumnNumber can be omitted.
@C | Returns the column name.
@D | Returns the dataset name.
@DZ | Remove trailing zeros when Set Decimal Places or Significant Digits is chosen in Numeric Display drop down list of the Worksheet Column Format dialog box. 0 = display trailing zeros. 1 = remove trailing zeros for Set Decimal Places =. 2 = remove trailing zeros for Significant Digits =. 3 = remove for both.
@E# | If columnNumber = 1, returns the number of Y error columns in the worksheet. If columnNumber = 2, returns the number of Y error columns in the current selection range. If columnNumber is omitted, LabTalk defaults to columnNumber = 1.
@H# | If columnNumber = 1, returns the number of X error columns in the worksheet. If columnNumber = 2, returns the number of X error columns in the current selection range. If columnNumber is omitted, LabTalk defaults to columnNumber = 1.
@Y | Returns the offset from the left-most selected column to the columnNumber column in the current selection.
@OY | Returns the offset from the left-most selected Y column to the columnNumber column in the current selection.
@OYX | Returns the offset from the left-most selected Y column to the columnNumber Y column counting on Y columns in the current selection.
@OYY | Returns the offset from the left-most selected Y column to the columnNumber X column counting on X columns in the current selection.
@T | Returns the column type. 1 = Y , 2 = disregarded, 3 = Y error, 4 = X , 5 = label, 6 = Z, and 7 = X error.
@X | Returns the number of the worksheet’s X column. Columns are enumerated from left to right, starting at 1. Use the syntax: %(worksheetName, @X);
@Xn | Returns the name of the worksheet’s X column. Use the syntax: %(worksheetName, @Xn);
@Y- | Returns the column number of the first Y column to the left. Returns columnNumber if the column is a Y column, or returns 0 when the Y column doesn't exist. Use the syntax: %(worksheetName, @Y-, ColumnNumber);
@Y# | If columnNumber = 1, returns the number of Y columns in the worksheet. If columnNumber = 2, returns the number of Y columns in the current selection range. If columnNumber is omitted, LabTalk defaults to columnNumber = 1.
@Y+ | Returns the column number of the first Y column to the right. Returns columnNumber if the column is a Y column, or returns 0 when the Y column doesn't exist. Use the syntax: %(worksheetName, @Y+, ColumnNumber);
@YS | Returns the number of the first selected Y column to the right of (and including) the columnNumber column.
@Z# | If columnNumber = 1, returns the number of Z columns in the worksheet. If columnNumber = 2, returns the number of Z columns in the current selection range. If columnNumber is omitted, LabTalk defaults to columnNumber = 1.

Note: To return more information on X values, use the xindex() and xvalue() built-in functions.

This script returns the column name of the first column in the current selection range: (For information on the selc1 numeric system variable, see Numeric System Variables.)

%N = %(%H, @col, selc1); %N =;

The next script returns the column type for the first column in the current selection range:

%N = %(%H, @type, selc1); %N =;

The next script returns the column number of the worksheet X column:

%N = %(%H, @X, selc1); %N =;

If the currently active worksheet window has six columns (XYYYYY) and columns 2, 4, and 5 are selected, then the following script returns the number of the first selected Y column to the right of (and including) the columnNumber column (third argument):

%(%H, @YS, 1) = 2

%(%H, @YS, 2) = 2

%(%H, @YS, 3) = 4

%(%H, @YS, 4) = 4

%(%H, @YS, 5) = 5

%(%H, @YS, 6) = 0

Note: You can now add strings to worksheet cells set to Text and Numeric by enclosing the string in quotation marks. For example %(Data1, 1, 1) = "string" will place string in the first row of the first column of Data1.

%( ) Substitution

During script execution, a ‘worksheet information expression’ surrounded by %() is evaluated and replaced with the worksheet information it represents.

  • To return individual cell contents, use the following syntax:

  • To return a dataset name, use the following syntax:

  • To return a column label, use the following syntax:

  • To return other information about worksheet columns, use the following syntax:

Examples:


The $( ) Notation and C Formatting Conversion Specifications

For example in the command:

type "x = $(x, *2)";

x is followed by *2, which sets x to display two significant digits.

If x equals 1.23456, the output result is:

x = 1.2

For example in the command:

type "x = $(x, .2)";

x is followed by .2, which sets x to display two decimal places.

If x equals 1.23456, the output result is:

x = 1.23

The E notation follows the variable it modifies, like the * notation.

For example, if you define x:

x = 1e6;

then the result of the following command:

type "x = $(x, E%4.2f)";

is:

x = 1.00M

where % indicates the start of the substitution notation, 4 specifies the total number of digits, .2 specifies 2 decimal places, and f is an indicator for floating notation.

where n specifies the total number of digits.

For example, if x = 1.23456, the following command:

type "x = $(x,S*3)";

returns:

x = 1.23E0

The following example illustrates this notation:

type "$(@D, D10)";

returns the current date and time. For example:

5/6/99 10:50:27

The number after the D character is the index entry (from 0) in the Date Format drop down list of the Worksheet Column Format dialog box. (Note: The "D" in Dn must be uppercase.)

The $( ) Notation and C Formatting Conversion Specifications

The $() notation can be used together with C-like formatting conversion specifications - like the %f conversion specifier and the . decimal place modifier - to format output.

These options are available:

Option | Output | Input Range | Example | Value
d or i | SIGNED, Integer values (of decimal or integer value) | -2^31 to 2^31 -1 | n = -247.56; type "Value: $(n,%d)"; | -247
f, e or E, g or G | SIGNED, decimal, scientific, decimal or scientific | ±1e290 to ±1e-290 | n = 1.23456e5; type "Values: $(n, %9.4f), $(n, %9.4E), $(n, %g)"; | 123456.0000, 1.2346E+005, 123456
 |  |  | n = 1.23456e6; type "Values: $(n, %9.4f), $(n, %9.4E), $(n, %g)"; | 1234560.0000, 1.2346E+006, 1.23456e+006
o, u, x, X | UNSIGNED, Octal, Integer, hexadecimal, HEXADECIMAL | -2^31 to 2^32 -1 | n = 65551; type "Values: $(n, %o), $(n, %u), $(n, %X)"; | 200017, 65551, 1000F (Negative values expressed as twos complements.)

Note: The *, E, S, and D conversion specifiers must directly follow the comma, with no intervening white space.

Use the * notation to set significant digits:

Use the . notation to set decimal places:

Use E notation to change the variable to engineering format:

Use the $(x, S*n) notation to convert from engineering to scientific notation:

Use the D notation to convert a numeric date value into a date time string:


Keywords

LabTalk reserves certain identifiers for its own use. These reserved identifiers are called keywords. All LabTalk command names are keywords. LabTalk also includes a number of macros and variables which have a special meaning in Origin. These system macros and system variables also use keyword identifiers.

LabTalk provides no protection against using keywords as user-defined identifiers. Using a keyword to name a variable or dataset will not create a conflict. However, using a LabTalk command or system macro identifier to name a new macro overrides the original macro or command.

Commands

System Macros

Numeric System Variables

String System Variables


Commands

LabTalk command names are keywords. Using any of these keywords to name your own macro overwrites the Origin command.


System Macros

A number of macros are pre-defined in Origin. To view a list of these macros, see the list command. To see the script associated with a defined macro, use the following syntax in the Script window:

define MacroName


Numeric System Variables

Changing these values resets the X, Y, or Z scale. For example:

When a worksheet or matrix is active, these variables indicate which columns and rows are in view in the workspace. X1 and X2 contain the index numbers of the first and last columns in view. X1 defaults to 0. Y1 and Y2 contain the index numbers of the first and last rows in view. Y1 defaults to 0. Thus, to specify the column and row index number to display in the upper-left corner of the worksheet or matrix, assign the desired values to X1 and Y1.

After importing image data into a matrix, the Z1 and Z2 system variables hold the lowest and highest matrix values. You can modify these values to fine tune the image display. For example, if Z1 = 16 and Z2 = 255, and the Z2 value for the image above is changed to 100, all matrix cells with values of 100 to 255 will display with the last color in the palette.

Entering the following script in the Script window:

X1 = -3; X2 = 12; Y1 = 0.3

sets the 2D X axis scale range to plot from -3 to 12. The Y axis scale begins at 0.3.

When they are displayed, both variables equal -1.

To enable echo, type echo = Number in the Script window (where Number is one of the following):

Number | Action
1 | Display commands that generate an error.
2 | Display scripts that have been sent to the queue for delayed execution.
4 | Display scripts that involve commands.
8 | Display scripts that involve assignments.
16 | Display macros.

Note: These values are bits that can be combined to produce cumulative effects. For example, echo = 12 displays both command and assignment scripts. Echo = 7 (includes echo = 1, echo = 2, and echo = 4) is useful for following script execution during menu command selection. To disable echo, type echo = 0 in the Script window.

Each time you double-click the cursor or press ENTER when one of these tools is selected, Origin executes the PointProc macro. The following script defines PointProc such that double-clicking on the page sets X1 and Y1 equal to X and Y:

doToolbox 2; #Select the Screen Reader.

Def PointProc {X1 = x; Y1 = y; doToolbox 0};

i

The variable i is used to store the index number to a dataset. In most cases, this is also the row number of a worksheet.

If no range is selected, the values are set back to 0. (Note: These system variables are being phased out. Instead, use the wks.c1 and wks.c2 object properties to read the first and last selected columns. Use the wks.r1 and wks.r2 object properties to read the first and last selected rows.)

It can be the number of selected files in the Open Multiple Files dialog box, or the number of times the PointProc macro has been executed since the Screen Reader tool or the Data Reader tool has been selected.

Variable

Use

@A

Angular unit: 0 = radian, 1 = degree, 2 = gradian.

@B

Enables (1) and disables (0) debugging statements that start with #! in a script.

@D

Current date and time in numeric values (Julian days). Use the $(@D,Dn) notation to display the nth date and time format from the Date Format drop-down list in the Worksheet Column Format dialog box (numbered from zero).

For example, type $(@D,D10); returns the date format as MM/DD/YY HH:MM:SS in the Script window. (Note: The "D" in Dn must be uppercase.)

Origin supports the associated Julian day values for the range 1/1/0100 to 12/31/9999. Use the $(@D,Tn) notation to display the nth time format from the Time Format drop-down list in the Worksheet Column Format dialog box (numbered from zero). For example, type $(@D,T5) returns the time format as HH:mm PM (such as 07:23 PM) in the Script window.

Two additional time formats are supported:

$(@D,t5) - 07:23 pm

$(@D,t5*) - 7:23 pm

@G

Set @G = 0 to display the page color within the entire graph window (including beyond the page) in page view mode. Set @G = 1 to display the area outside the page as gray.

@L

The current menu level: 1 = full menus, 2 = short menus.

@LP

The maximum number of points used in the GDI call to draw line plots, 3D XYY plots, and some other plot types. Some video drivers cannot handle large numbers passed as arguments in the GDI call, so Origin breaks the drawing up into several sections that are each @LP points large.

The @LP value is saved between Origin sessions in the MaxPolyLinePoints keyword in the [Display] section of the ORIGIN.INI file.

@LW

Allows you to control the line width when adding a plot to a layer, independent of the style holder setting.

@LW = 0: the style holder setting is used to determine the line width. Otherwise, @LW = value is the line width, in points.

@MB

When opening a project that contains a Text & Numeric column with mixed text and numeric values that was saved in Origin 4.1, a dialog box will open asking if the project was saved in the 32 or 16 bit version. The 32 bit version incorrectly saved mixed Text & Numeric data.

If you specify 32 bit in the dialog box, Origin fixes the Save problem by resaving the project in Origin 6.1 and then reopening the project. @MB = 0 opens the dialog box (default), @MB = 16 always assumes the project was saved in Origin 4.1 16 bit and thus opens the file with no changes, @MB = 32 always assumes the project was saved in Origin 4.1 32 bit and thus resaves the project to correct the problem.

@MC

Mask color. Follows the colors in the color palette: 1 = black, 2 = red, 3 = green, 4 = blue, etc. Use mark -u to update all windows.

@MM

Enable or disable mask. 0 = enable (masked points are not included in analysis). 1 = disable (masked points are included in analysis). Use mark -u to update all windows.

@MP

Show or hide masked data points in graph. 0 = show. 1 = hide. Use mark -u to update all windows.

@NSV

For backwards compatibility, enable setting the count variable when fdlog.multiopen() is used. 1 = enable, 0 = disable.

@O

Set or get the current printer driver’s page orientation. @O = 1 for portrait. @O = 2 for landscape. Use the following page object method to update the printer setup: page.dimupdate();

@OC

Controls whether or not you can call Origin C functions from LabTalk. 1 = you can call Origin C functions (default), 0 = you cannot call Origin C functions. For more information, see Calling Origin C Functions from LabTalk.

@P

Page numbers in worksheet printing. @PC for current page number column-wise and @PR for current page number row-wise.

@PB

Set @PB = 1 to enable gray-scaling on a black and white printer. Set @PB = 0 to print all non-white colors as black when a black and white printer is selected.

@SD

Control the number of significant digits displayed when mathematical operations are performed in the Script window. This variable is defaulted to 7 and can be set to any integer between 1 and 15.

@SF

Scaling factor to control the legend symbol size.

@TM

Indicates whether or not the timer is running. 1 = timer is running, 0 = timer is not running.

@TS

Determines how ternary data are normalized.

@TS = 0 - auto determination of what the sum should be (1 or 100) based on the data.
@TS = 1 - the sum must be 1.
@TS = 2 - the sum must be 100.

@U

Set @U = 0 to align the fonts in a text label with the baseline.
Set @U = 1 to disable this option. @U is the same as the system.print.fontbaseline property.

@V

Origin version number.

@VDF

If you set @VDF = 0, when you open a project file (.OPJ), Origin will report the Origin version in which the file was saved.

@W

Font size scaling for display in Window view mode (which normally ignores font scaling). @W is the same as the system.winviewfsize property.

@WD

Controls Origin's behavior when you close the winName worksheet with the win -c command and then use this win -t command option to open a winName worksheet (where winName is the same with both command options).

When @wd = 1, Origin deletes the datasets that remain from the win -c command and then opens the winName window. When @wd = 0, a #Command Error! prints to the Script window. Origin does not delete the datasets that remain from the win -c command. Additionally, Origin does not open the winName window.

@ZZ

Controls the return value when zero is raised to the zero power (0^0).
If @ZZ = 1, Origin returns 1.
If @ZZ = 0 (default), Origin returns a missing value.

Numeric System Variables

The following variables are restricted for internal use by Origin. These variables are in frequent use; using them in your script can cause it to fail.

X1, X2, Y1, Y2, Z1, Z2 -- When a graph window is active, these variables contain the initial and final X, Y, and Z axis scale values for the active layer.

MKS1, MKS2 -- When data markers are displayed in the graph window, MKS1 and MKS2 are set to the first and second data markers respectively.

Echo -- This variable prints scripts or error messages to the Script window.

X, Y, Z -- These variables contain the current X, Y, and Z coordinates of the Screen Reader, Data Reader, or Data Selector tools.

SELC1, SELC2, SELR1, SELR2 -- These variables contain the column and row numbers that delineate the current worksheet selection range.

COUNT -- This variable is used by different Origin routines.

Click here for a list of @Letter Variables:


String System Variables

The following string variables are system variables that have a special meaning for Origin.

String Variable | Description
%A | Used extensively by Origin, and is commonly used in development scripts.
%B | Used extensively by Origin, and is commonly used in development scripts.
%C | The name of the current active dataset.
%D | The name of the last dataset set as active with the set command.
%E | The name of the window containing the latest worksheet selection.
%F | The name of the dataset currently in the fitting session.
%G | The current project name.
%H | The current active window title.
%I | The current baseline dataset.
%X | The DRIVE:PATH of the current project. The ‘\’ character can be displayed from the %X or %Y system string variable. For example, if the following text is typed in the Text Control dialog box (with Link to Variables enabled in the Label Control dialog box): The file path for this document is \v(%X). Origin displays: The file path for this document is C:\MyDir\MyFile.
%Y | The full path name to the "User Files" folder. This can be different for each user depending on the location they selected when Origin was started for the first time. This location contains the Origin.ini file as well as other files. To display the ‘\’ character, see %X.
%Z | A long string for temporary storage.

These string variables can be used anywhere a name can be used, as in the following example:

del %C;

which deletes the current active dataset.


Programming Syntax and Structure

Origin’s LabTalk language has a C-like structure, comprised of loops and decision structures. To automate and customize Origin, you can make use of a combination of mathematical operations, commands, macros, object properties, and object methods. This section reviews LabTalk syntax, and helps you gain proficiency writing your own scripts.

Syntax

Structure


Syntax

A script is a single block of LabTalk text that is received by the LabTalk interpreter. A LabTalk script is composed of one or more statements. A statement is a complete programming statement which performs an action. Each statement in a script should end with a semicolon, which separates it from other statements. However, single statements typed into the Script window for execution should not end with a semicolon.

Each statement in a script is composed of words. Words are any group of text separated by white space. Text enclosed in parentheses is treated as a single word, regardless of white space. For example:

This is a statement; //is a single LabTalk statement

statement 1; statement 2; statement 3 //represents three statements

Parentheses are used to create long words containing white space. For example, in the script:

menu 3 (Long Menu Name);

the open parenthesis signifies the beginning of a single word, and the close parenthesis signifies the end of the word.


Statement Types

LabTalk supports five types of statements:

  • assignment

  • macro

  • command

  • arithmetic

  • function


Assignment Statements

  • A string variable if dataObjectName is %A - %Z.

  • A variable if expression evaluates to a scalar.

  • A dataset if expression evaluates to a range.

  • If dataObjectName is a dataset and expression is a scalar, every value in dataObjectName is set equal to expression.

  • If dataObjectName is a variable, then expression must evaluate into a scalar. If expression is a dataset, dataObjectName retrieves the first element of the dataset.

  • If both dataObjectName and expression represent datasets, each value in dataObjectName is set equal to the corresponding value in expression.

ObjectName.property = expression;

To read an object property in the Script window, use the syntax:

ObjectName.property =

Assign the variable B equal to the value 2.

B = 2;

Assign Test equal to 8.

Test = B^3;

Assign %A equal to Austin TX.

%A = Austin TX;

Assign every value in Data1_B to 4.

Data1_B = 4;

Assign each value in Data2_B to the corresponding position in Data1_B.

Data1_B = Data2_B;

Sets the row heading width for the Data1 worksheet to 100, using the worksheet object’s rhw property. doc -uw refreshes the window.

Data1!wks.rhw = 100; doc -uw;

The calculation is carried out for the values at the corresponding index numbers in more and yetmore. The result is put into myData at the same index number.

myData = 3 * more + yetmore;

%B = DataSet;

(%B) = 2 * %B;

The values in DataSet are multiplied by 2 and put back into DataSet. %B still holds the string “DataSet”.

Assignment Statements

The assignment statement takes the general form:

dataObjectName = expression;

expression is evaluated and put into dataObjectName. If dataObjectName does not exist, it is created.

When a new data object is created with an assignment statement, the object created is:

When new values are assigned to an existing data object, the following conventions apply:

One special case of the assignment statement is the object.property notation. This notation is used to read or set object properties, such as the number of rows in a worksheet. To set object properties, use the following syntax:

Examples of assignment statements:

Note: If a string variable to the left of the assignment operator is enclosed in parentheses, the string variable is substitution processed before assignment. For example:


Macro Statements

Macros provide a way to alias a script, that is, to associate a given script with a specific name. This name can then be used as a command that invokes the script.

The define command is used to create macros. This command takes the general form:

define macroName {script};

This command creates the macro macroName that invokes the script script. A statement beginning with macroName is called a macro statement. A macro statement precedes command statements in recognition order. Otherwise, the macro statement is like any other command statement.

For information on passing arguments to a macro, see Passing Arguments.


Command Statements

The following script adds a column named new to the active worksheet and refreshes the window:

wks.addcol(new);

doc -uw;

Integrate the dataset myData from zero.

integ myData;

Adding the -r option and its argument, baseline, causes myData to be integrated from a reference curve named baseline.

integ -r baseline myData;

The repeat command takes two arguments to execute: number of times and a script. This command statement prints "Hello World" in a dialog box three times.

repeat 3 {type -b "Hello World"};

Command Statements

The third statement type is the command statement. LabTalk offers commands to control or modify most program functions.

Each command statement begins with the command itself, which is a unique identifier that can be abbreviated to as little as two letters (as long as the abbreviation remains unique, which is true in most cases). Most commands can take options, which are single letters that modify the operation of the command. Options are always preceded by the dash "-" character. Commands can also take arguments. Arguments are either a script or a data object. In many cases, options can also take their own arguments.

Command statements take the general form:

command [option] [argument(s)];

The brackets [] indicate that the enclosed component is optional; not all commands take both options and arguments. The brackets are not typed with the command statement (they merely denote an optional component).

Object methods are another form of command statement. They execute immediate actions relating to the named object. Object method statements use the following syntax:

ObjectName.Method([options]);

For example:

The following examples illustrate different forms of command statements:


If myData is a dataset, this divides each value in myData by 10.

myData / 10;

Subtract otherData from myData, and put the result into myData. Both datasets must be Y or Z datasets (see Note).

myData - otherData;

If A is a variable, increment A by 1. If A is a dataset, increment each value in A by 1.

A + 1;

Arithmetic Statement

The arithmetic statement takes the general form:

dataObject1 operator dataObject2;

where

  • dataObject1 is a dataset or a numeric variable.

  • dataObject2 is a dataset, variable, or a constant. operator can be +, -, *, /, or ^.

The result of the calculation is put into dataObject1. Note that dataObject1 cannot be a function. For example, col(3) + 25 is an illegal usage of this statement form.

The following examples illustrate different forms of arithmetic statements:

Note: There is a difference between using datasets in arithmetic statements versus using datasets in assignment statements. For example, data1_b + data2_b is computed quite differently from data1_b = data1_b + data2_b. The later case yields the exact result no matter how the two datasets are associated with the X datasets, but the former arithmetic statement depends on the interpolation based on the first dataset's X dataset.


Function Statements

The function statement begins with the characteristics of a function -- an identifier -- followed by a quantity, enclosed by parentheses, upon which the function acts.

An example of a function statement is:

sum(dataset);


Using Semicolons in LabTalk

if (m>2)

{type "hello"};

is correct syntax.

if (counter > 200)

{

counter = 0;

type "Resetting the counter";

};

is also correct syntax.

Using Semicolons in LabTalk

Like the C programming language, LabTalk uses semicolons to separate statements. In general, every statement should end with a semicolon. However, the following rules clarify semicolon usage:

  • Do not use a semicolon when executing a single statement script in the Script window. An example of the proper syntax is: type "hello" (ENTER). The interpreter places a semicolon after the statement to indicate that it has been executed.

  • To enter multiple line script in the Script window, include a semicolon after every statement. To execute the script, select the entire script with the mouse and press ENTER.

Note that pressing ENTER before typing the statement-ending semicolon causes immediate execution of the specific line. To avoid accidental script execution, turn off Script Execution by selecting Edit:Script Execution from the Script window menu bar. After typing the script, turn Script Execution back on again by selecting Edit:Script Execution, then highlight the script and press ENTER.

  • Use a semicolon at the end of each statement when writing a script for an object, menu command, or script file.

  • Some commands take a script as an argument, including if, for, and define. Do NOT use a semicolon between the command and the script argument. The command is not a complete statement without the script. For example:

  • Semicolons should be used within the script argument and after the last bracket of the statement. For example:


Extending a Statement over Multiple Lines

There are times when, for the sake of readability, you want to extend a single statement over several lines. One way to do this is with braces {}. When an "open brace" is encountered in a script file, Origin searches for a "close brace" and executes the entire block of text as one statement. For example, the following macro statement:

def openDialog {layer -s 1; axis x;};

can also be written:

def openDialog {

layer -s 1;

axis x;

};

Both scripts are executed as a single statement, even though the second statement extends over four lines.

Note: There is a limit to the number of tokens that can be included between a set of braces {}. The tokens between the {} in a LabTalk script are translated internally and the translated tokens must be less than 1140 bytes (after substitution). In place of long blocks of LabTalk code, programmers can use LabTalk macros or the run.section() and run.file() object methods. To learn more, see Passing Arguments.


Comments

Use the “ # “ or “//” character to ignore all text from # or // to the end of the line. For example, # and // can be used as follows:

type "Hello World"; #Place comment text here.

type "Hello World"; //Place comment text here.

Note: Use the “#!” characters to begin debugging lines of script. The lines are only executed if system.debug = 1.


Order of Evaluation in Statements

Statements are identified as to type using the following recognition order: assignment, macro, command, arithmetic, and function. The interpreter first looks for an exposed (not hidden in parentheses or quotation marks) assignment operator. If none is found, it looks to see if the first word is a macro name. It then checks if the first word is a command name. The interpreter then looks for an arithmetic operation, and finally, the interpreter checks whether the statement is a function.

The recognition order can have significant effect on script function. For example, the following assignment statement:

type = 1;

assigns the value 1 to the variable type. This occurs even though type is (also) a LabTalk command, since assignment comes before commands in recognition order. However, since commands precede arithmetic expressions in recognition order, in the following statement:

type + 1;

the command is carried out first, and the string, + 1, prints out.

  1. Assignment statements: String variables to the left of the assignment operator are not expressed unless enclosed by parentheses. Otherwise, all string variables are expressed, and all special notation (%() and $()) is substitution processed.

  2. Macro statements: Macro arguments are substitution processed and passed.

  3. Command statements: If a command is a raw string, it is not sent to the substitution processor. Otherwise, all special notation is substitution processed.

  4. Arithmetic statements: All expressions are substitution processed and expressed.

Order of Evaluation in Statements

When a script is executed, it is sent to the LabTalk interpreter and evaluated as follows:

  1. The script is broken down into its component statements.

  2. The statements are executed in the order received, using the following evaluation priority:


Passing Arguments

Suppose a TEST.OGS file includes the following section:

[output]

type "%1 %2 %3";

and you execute the following script:

run.section(test.ogs, output, "Hello World" "from" "LabTalk");

Here, %1 holds "Hello World", %2 holds "from", and %3 holds "LabTalk". After string substitution, Origin outputs

Hello World from LabTalk

to the Script window. If you had omitted the quotation marks from the script file section call, then %1 would hold "Hello", %2 would hold "World", and %3 would hold "from". Origin would then output

Hello World from

Passing Arguments

When you use the run.section() object method (to call a script file section) or when you call a macro, you can pass arguments to the script file section or to the macro. Arguments can be literal text, numbers, numeric variables, or string variables.

When passing arguments to script file sections or to macros:

  • The section call or the macro call must include a space between each argument being passed.

  • When you pass literal text or string variables as arguments, each argument must be surrounded by quotation marks (in case the argument contains more than one word, or is a negative value). Passing numbers or numeric variables doesn't require quotation mark protection, except when passing negative values.

  • You can pass up to five arguments to script file sections or macros. In the script file section or macro definition, argument placeholders receive the passed arguments. These placeholders are %1, %2, %3, %4, and %5. The placeholder for the first passed argument is %1, the second is %2, etc. These placeholders work like string variables in that they are substituted prior to execution of the command in which they are embedded.

As an example of passing literal text as an argument that is received by %1, %2, etc.,

Related Topics:

Passing Numeric Variables by Reference

Passing Numeric Variables by Value


Passing Numeric Variables by Reference

If a TEST.OGS file includes the following section:

[adddata]

loop (n, 1, 5)

{

data1_b[%1 + n] = 100;

};

%1 = %1 + (n - 1);

return 0;

And you execute the following script:

data1_b = data(1, 10); //fill data1_b with values

get data1_b -e lastrow; //store last row of values in lastrow

run.section(test.ogs, adddata, lastrow);

Then LastRow is passed by reference and then updated to hold the value 15.

Passing Numeric Variables by Reference

Passing numeric variable arguments by reference allows the code in the script file section or macro to change the value of the variable.

For example, suppose your application used the variable LastRow to hold the row number of the last row in the data1_b column that contains a value. Furthermore, suppose that the current value of LastRow is 10. If you pass the variable LastRow to a script file section whose code appends five values to data1_b (starting at the current last row), after appending the values, the script file section could increment the value of the LastRow variable so that the updated value of LastRow is 15.

See example:


Passing Numeric Variables by Value

[main]

%A = "degrees Celsius";

//Define string variable

run.section(, Part1, var1 $(var1) "%A");

//Pass 1st argument by reference, 2nd by value, 3rd as a string variable

delete -v var1;

return 0;

[Part1]

//Assumed Input: 1st Arg=Variable, 2nd Arg=Value

type -b "The value of %1 = %2 %3";

//Example output: The value of var1 = 22 degrees Celsius

return 0;

Passing Numeric Variables by Value

Passing numeric variable arguments by value is accomplished by using the $() substitution notation. This notation forces the interpreter to evaluate the argument before sending it to the script file section or macro. This technique is useful for sending the value of a calculation for future use. If the calculation were sent by reference, the entire expression would require calculation each time it was interpreted.

In the following script file example, the [main] section includes a call to the [Part1] section in which the numeric variable var1 is passed by reference and by value; %1 will hold the argument that is passed by reference and %2 will hold the argument that is passed by value. Additionally, a string variable (%A) consisting of two words is sent by value as a single argument to %3.

See example:


Structure

The structure of the LabTalk language is similar to C. LabTalk supports:

  • Loops, which allow the program to repetitively perform a set of actions.

  • Decision structures, which allow the program to perform different sets of actions depending on the circumstances.

Also see:

Bracketing and Indentation Conventions in LabTalk


Loops

All LabTalk loops take a script as an argument. These scripts are executed repetitively under specified circumstances. LabTalk provides four loop commands: repeat, loop, for, and doc -e. The LabTalk for loop is similar to the for loop in other languages. The repeat, loop, and doc -e loops are less familiar, but are easy to use.

  • The repeat loop is used when a set of actions must be repeated without any alterations.

  • The loop loop is used when a single variable is being incremented with each successive loop.

  • The doc -e loop is used when a script is being executed to affect objects of a specific type, such as graph windows.

  • The for loop is used for all other situations.

LabTalk provides a break command. When executed, this causes an exit from the loop and, optionally, the script. This is often used with a decision structure inside a loop. It is used to protect against conditions which would invalidate the loop test conditions.

The exit command prompts an exit from Origin unless a flag is set to restrict the exit.

The continue command can be used within the loop script. When executed, the remainder of the loop script is ignored and the interpreter jumps to the next iteration of the loop. This is often used with a decision structure inside a loop and can exclude illegal values from being processed by the loop script.


Decision Structures

LabTalk has three decision-making structures: if, if-else, and switch.

  • The if command is used when a script should be executed in a particular situation.

  • The if-else command is used when one script must be executed if a condition is true (non-zero), while another script is executed if the condition is false (zero).

  • The switch command is used when more than two possibilities are included in a script.


Bracketing and Indentation Conventions in LabTalk

if (a < b) {type "$(a) is less than $(b)"; "type hi";};

if (a < b) {

type "$(a) < $(b)";

type "hi";

};

if (a < b)

{

type "$(a) < $(b)";

type "hi";

};

Bracketing and Indentation Conventions in LabTalk

In the examples of loop and decision structures in the Origin product documentation, three different styles of bracketing and indentation are used.

These three examples are functionally identical. Most programmers prefer the second or third style because indenting a loop or decision script adds clarity. This is important when working with nested loop and decision structures.

  • one style

  • a second style

  • a third style


Calling Origin C Functions from LabTalk

  • A return type is string, requires that you terminate the function call with a dollar sign $. For example:

  • A return type of vector can only be used in LabTalk vector notation.

%A = myOCfuncWithStringReturn(arg)$;

If your Origin C function header is:

void doc(string str, int nn)

You could call this compiled function using the following LabTalk statement:

doc(%H, 3);

In addition to using this general syntax, you can also call your function using the following LabTalk syntax (omitting the parentheses):

funcName arguments;

For example, you could call the example doc function using the following LabTalk statement:

doc %H 3;

@OC = 1 (default), you can call Origin C functions from LabTalk.

@OC = 0, you cannot call Origin C functions from LabTalk.

list f; // list all Origin C functions that can be called from LabTalk

list fs; // only those returning string

list fv; // only those returning vector

list fn; // only those returning numeric

list fo; // only those returning void

To show the function prototype in the listing, use 'cf' in place of 'f'. For example, list cf, cfs, cfv, cfn, cfo;

Calling Origin C Functions from LabTalk

You can call Origin C functions from LabTalk if the following conditions are met:

  • The function has been defined and compiled. (Note: Global Origin C functions that are prototyped but have no function body, cannot be called. NAG functions can only be called from Origin C -- not from LabTalk).

  • All arguments must be numeric or string. This restricts argument types to the following: char, short, WORD, int, DWORD, float, double, and string.

  • The return type is numeric, string , or vector.

Once these conditions are met, you can access an Origin C function by executing a LabTalk statement that calls your function. The general syntax for this function call is:

funcName(arguments);

or if the Origin C function returns a value, then the syntax is:

varName = funcName(arguments);

When "funcName(arguments);" is passed to the LabTalk interpreter, the interpreter will check if funcName is a compiled Origin C function. If it is, the Origin C function will be executed. For example:

When you call an Origin C function from LabTalk, if the Origin C function name is the same as a LabTalk built-in function, then the Origin C function is given precedence, except when using LabTalk vector notation. Thus, LabTalk functions like Normal and Data (which return a range of values and are thus used in vector notation) are given higher precedence than Origin C functions of the same name. In all other cases, the Origin C function is called.

If you want to restrict LabTalk function calls to only LabTalk functions (excluding Origin C functions), you can modify the value of the @OC system variable:

To list the Origin C functions that can be called from LabTalk, use the LabTalk list command as follows: (The @OC system variable affects this listing.)


Introduction to the LabTalk Commands

The general form of a command statement is:

command [option] [argument(s)];

  • Spaces separate the command, option, and argument(s).

  • An option is usually a letter preceded by a dash. Options affect the operation of a command.

  • Arguments are passed to, and may be modified by, the command.

  • Braces [] indicate an optional argument.

  • Where a command takes options, the options often take their own argument(s). The syntax and effect of each option is described individually beneath the general command description and syntax.

  • Use of some options precludes use of the command arguments. Where this is the case, the argument is surrounded by angle brackets <> in the syntax description.

  • Multiple options and arguments can be included with a command for a cumulative affect. See the draw and label commands for examples.

Command Reference by Category

Alphabetical Listing of Commands


Command Reference by Category

Data Manipulation and Calculation

Display Control

Control Flow

Input/Output

External Access

Time


Data Manipulation and Calculation

Command | Description
average | Replace a dataset with a running average.
copy | Copy one dataset to another.
create | Create a dataset, worksheet, or function.
delete | Delete a dataset, function, macro, or variable.
derivative | Take the derivative of a dataset.
edit | Open the worksheet for a dataset.
integrate | Integrate a dataset.
limit | Find the minimum and maximum X and Y values for a dataset.
lr | Perform linear regression on a dataset.
mark | Delete or mask data points in a dataset.
math | Perform mathematical operations on or between datasets.
matrix | Set the dimensions and values of a matrix. Transpose a matrix.
nlsf | Perform nonlinear least squares fitting.
plot | Append values to a dataset.
sort | Sort worksheet data.
undo | Undo various procedures.


Display Control

Command | Description
axis | Open the Axis dialog box. Edit the axis scale type, grid display, tick, and tick label display. Display additional axes in a layer.
document -t | Open a window based on a template.
dotoolbox | Select or block selection of a Tools toolbar tool. Hide the Tools toolbar. Display a picture of a worksheet or graph window in a layout page window.
draw | Draw a line and edit its properties. Hide an object. Update an object. Edit the location of an object. Read a metafile, bitmap, or object from a file into an object. Update an object's numeric or text fields.
edit | Open the worksheet for a dataset. Open the Color Palette dialog box.
get | Read the display properties of a dataset or data plot.
label | Create and edit a text label, including axis titles.
layer | Edit the properties of a layer. Add data to a layer. Add layers to a graph page. Open layer-related dialog boxes including the Plot Details dialog box. Extract multiple data plots to separate layers.
legend | Display or update the legend for a graph layer.
page | Edit the properties of a page. Add data to separate layers of a graph page. Open page-related dialog boxes including the Plot Details dialog box. Extract multiple layers to separate graph pages.
plot | Update the layer or the page.
select | Edit the display of the selected objects including alignment and grouping.
set | Edit the display properties of a dataset or data plot. Open the Plot Details dialog box.
type | Hide the Script window or the status bar.
undo | Undo various procedures.
window | Open, close, hide, minimize, maximize, rename, and activate a window. Merge graph windows.
worksheet | Edit the properties of a worksheet. Duplicate a worksheet. Open worksheet-related dialog boxes. Plot worksheet data. Run a worksheet's script.


Project Management

Command | Description
document | Append projects. Close the current project. Open a project. Rename the current project. Count the number of layers in a graph window. Count the number of object types in a project.
file | Copy one file to another.
list | List all datasets, macros, system variables, or data plot style holders.


Control Flow

Command | Description
break | Exit from a loop, a script, or a progress dialog box.
continue | Skip to the next iteration of the current loop.
document -e (-ef) | Loop to execute a script that affects every object of the specified kind (-ef => the active Project Explorer folder).
exit | Exit from Origin.
for | Loop for repeated operation.
if [else] | Test a condition and branch accordingly.
layer -o | Execute a script for the specified layer.
loop | Loop while incrementing a variable.
repeat | Execute the same script multiple times.
return | Return a value from a script and exit the script.
switch | Test an expression against a series of constant values and branch accordingly.
win -o | Execute a script for the specified window.


Input/Output

Command | Description
clipboard | Copy the current page to the Clipboard.
copy | Copy one dataset to another.
draw -fb, -fm | Read a bitmap or metafile from a file into an object.
getfilename | Open the Open or Import Multiple ASCII dialog boxes.
getnumber | Get input of up to six numbers or strings.
getpts | Graphically get points or screen coordinates from a data plot.
getsavename | Open the Save As dialog box.
getstring | Get a user-supplied text string.
getyesno | Open a Yes/No/Cancel dialog box.
open | Import a data file.
print | Print the active (or specified) page. Open the Print or Page Setup dialog boxes.
save | Save the project or save a window in the project. Export worksheet data.
type | Output text to the Script window, status bar, or various dialog boxes.
win -aw | Go to the specified URL. Open the specified HTML on the local computer.


Script Management

Command | Description
define | Define a macro.
draw | Run an object's Label Control dialog box script.
menu | Manipulate menus, submenus, and menu commands.
queue | Place a script at the end of the window update queue.
run | Execute a script file or run a Windows program.


External Access

Command | Description
dde | Client DDE support.
dll | Execute a function from a user-supplied DLL.


Time

Command | Description
second | Elapsed time counter. Perform timer-related operations.
timer | Execute the TimerProc macro script periodically.


Alphabetical Listing of Commands

A complete listing of all LabTalk commands is provided in subsequent Help topics.

Two general points to remember:

  • While the complete command name is provided for each command, command names can be abbreviated down to two letters as long as the abbreviation is unique. For example, instead of using the print command in your script, you could use pr.

  • LabTalk commands are case-insensitive.

Average | Derivative | GetFileName | Legend | Open | Selection
Axis | DLL | GetNumber | Limit | Page | Set
Break | Document | GetPts | List | Plot | Sort
Clipboard | DoToolbox | GetSaveName | Loop | Print | Switch
Continue | Draw | GetString | LR | Queue | Timer
Copy | Edit | GetYesNo | Mark | Repeat | Type
Create | Exit | If | Math | Return | Undo
DDE | File | Integrate | Matrix | Run | Window
Define | For | Label | Menu | Save | Worksheet
Delete | Get | Layer | NLSF | Second |


Average

[range] appears in the command syntax line of commands that take a dataset as an argument. It indicates that the range modification options can be used to set the active range of the dataset. The command affects only the active range of the dataset.

There are three range modification options: -b, -e, and -t. They offer two methods of implementation:

  • Set the beginning and final index numbers of the active range:

-b firstPoint -e endPoint

  • Set the total number of points in the active range, beginning at firstPoint:

-b firstPoint -t totalPoints

  • Each value is the average of three values, the averaged value and its two neighboring values.

  • Find the average of the first two points in dataset and last two points in dataset.

  • Each value is the average of N points before and N points after.

no option

-l dataset [range]

If the intervening points (third point through the n-2 point) fall outside the range defined by these two average values, then replace the intervening points with the closer of these two averages. If an intervening point does not fall outside the range defined by these two averages, then leave the value unchanged (see the Examples).

-n N dataset [range]

ave -n 1 data1_B;

is equivalent to...

ave data1_B;

  • The following script uses the six neighboring values plus itself (2*3+1) to find the average for each value in data1_b.

ave -n 3 data1_b;

  • The next script uses the four neighboring values plus itself (2*2+1) to find the average for each value in data1_b over the range of row index 10 to row index 20.

ave -n 2 data1_b -b 10 -e 20;

  • The last script calculates the averages of the first two points and last two points in data1_b. It then replaces the intervening points that are outside the range of average values with the closer of these two averages.

ave -l data1_b;

Average

Operates on the given dataset to find a running average. This command alters the dataset on which it operates.

To find averages for a dataset without altering the original data, use the ave() function.

Usage:

average [option] dataset [range]

A Note about [range]:

Options (ordered alphabetically):

Examples:


Axis

  • Open the Scale tab of the Axis dialog box.

  • Open the Title & Format tab of the Axis dialog box for axis.

  • Open the Break tab of the Axis dialog box for axis.

  • Open the Grid Lines tab of the Axis dialog box for axis.

  • Open the Tick Labels tab of the Axis dialog box for axis.

  • Open the Custom Tick Labels tab of the Axis dialog box for axis.

  • Get parameters for the specified axis (X or Y) and place the value into varName.

  • Set parameters for the specified axis (X or Y) to value.

  • Scroll the indicated axis (X or Y) by the specified increment inc.

no option xyzdialog

Open the Scale tab of the Axis dialog box with the X axis selected when xyzdialog is X. Open the Scale tab of the Axis dialog box with the Y axis selected when xyzdialog is Y. If xyzdialog is not included, open the Scale tab of the Axis dialog box with the Z axis selected.

-a axis

X1 = bottom X, X2 = top X, Y1 = left Y, Y2 = right Y, Z1 = front, and Z2 = back.

-b axis

X1 = bottom X, X2 = top X, Y1 = left Y, Y2 = right Y.

Note: axis = Z1 or Z2 is not supported for this option.

-g axis

X1 = bottom X, X2 = top X, Y1 = left Y, Y2 = right Y, Z1 = front, and Z2 = back.

-l axis

X1 = bottom X, X2 = top X, Y1 = left Y, Y2 = right Y, Z1 = front, and Z2 = back.

-m axis

X1 = bottom X, X2 = top X, Y1 = left Y, Y2 = right Y, Z1 = front, and Z2 = back.

-pg axis type varName

type of parameter is either:

S (scale type: 0 = linear, 1 = log, etc.)

G (grids displayed: 1 = major, 2 = minor, 3 = both)

A (axis display: 1 = first, 2 = second, 3 = both)

L (axis tick label display: 1 = first, 2 = second, 3 = both)

R (rescale margin: in % of axis scale)

M (number of minor ticks)

-ps axis type value

Valid parameters are as described for the previous (-pg) option. This option also includes type:

T (set tick labels from dataset where value specifies a dataset).

-s axis inc

inc is given in major tick units, so:

axis -s x 3;

scrolls the X axis by three major ticks.

  • The following script sets the X axis to show both major and minor grids.

axis -ps X G 3;

  • The next script sets the X axis to a log scale.

axis -ps X S 1;

Axis

Provides access to tabs in the Axis dialog box. Get and set various axis style parameters.

Usage:

axis [option] [xyzdialog]

Options (ordered alphabetically):

Examples:


Break

  • Unconditional exit from any loop.

  • Open the progress status dialog box with the caption caption. This dialog box includes a Cancel button.

  • Open the progress status dialog box with the caption caption. This dialog box includes an End button.

  • Open the progress status dialog box with the caption caption. All other controls in the dialog box are hidden.

  • Close the progress status dialog box.

  • This command option updates the progress status dialog box with the value of variable.

  • Set the range of values used in the percentage completion display in the progress status dialog box.

no option [argument]

If argument = 1, also exit from the current script.

-b caption

This dialog box includes a Cancel button. Click Cancel to break from the entire script.

-be caption

Click on the End button to break from the loop and continue the script after the loop.

-bm caption

Use this option to display the caption only.

-e

-p variable

The value of variable is converted to a percent using the min and max range set with the -r option. Before using this option, you must use either the -b or -be option to open the progress status dialog box. You must also use the -r option before using this option.

This command option updates the progress status dialog box with the value of variable converted to a percent using the min and max range set with the -r option. For example, if min = 0 and max = 100 and the initial value of variable is 10, the percent completion display will start at 10%. In general, variable is initialized and incremented in the loop.

For an example using the -p and -r options, see the Examples section.)

-r min max

Before using this option, you must use either the -b or -be option to open the progress status dialog box. Use this option before the -p option.

  • In the following script, if a zero value is encountered in the data1_a dataset, the script displays an error message and breaks out of both the loop and the script. If a negative value is encountered, the script breaks out of the loop.

myvar=0;

loop (ii, 1, 10)

{

if (data1_a[ii] == 0) {

type -b “error”;

break 1;

}

if (data1_a[ii] < 0) break;

myvar+=(1/data1_a[ii]);

}

  • The next script utilizes the progress status dialog box.

break -b This is the caption for the dialog box;

break -r 500 1000; // the range of values will be 500 - 1000

for (ii = 500; ii <= 1000; ii++)

{

break -p ii; // the current value is ii

// perform other tasks here

};

break -end; // done, close the dialog box

Break

Provides a visual interface to view the progress of a script that includes a loop.

Usage:

break [option] argument

Options (ordered alphabetically):

Examples:


Clipboard

Copy to the clipboard the page in the winName graph window.

Usage:

clipboard winName

Options:

no option winName


Continue

  • In the following for loop, continue skips the type statement when ii is less than zero.

for (ii = -10; ii <= 10; ii += 2)

{

if (ii < 0) {continue;};

type “$(sqrt(ii))”;

};

  • The next script adds a Real column to the Test1 worksheet. It tests each value in the Test1_B dataset and adds the values that are not null to the Test1_Real dataset.

Test1!wks.addCol(Real); //Add col name Real to end of Test1

get Test1_B -e EndIndex; //EndIndex is # of last value in Test1

for (ii = 1, jj = 1; ii < EndIndex; ii++)

{

if (Test1_B[ii] == 0/0) //If ii index number value is null

{

continue; //Skip the rest of this iteration of the loop

};

Test1_Real[jj] = Test1_B[ii];

jj++; //Iterate Real index # after value has been added

};

Continue

Jump to the next iteration of a loop or for structure.

Usage:

continue

Examples:


Copy

  • Copy the contents of dataset1 into dataset2.

  • Append contents of dataset1 to the end of dataset2.

  • Copy from rowIndex# of dataset1 to dataset2, beginning at the dataset2 start# and ending at end#.

  • Copy dataset1 to dataset2 but remove the first point and swap the two halves of dataset2.

  • Copy the odd entries of dataset1 to dataset2 and the even entries to dataset3.

  • Set dataset2 to a size of npts. Copy dataset1 into dataset2 such that the entire range of dataset1 is interpolated to fit into dataset2 with npts.

  • Split (unzip) dataset1 into dataset2 and dataset3 so that the first point in dataset1 becomes the first point in dataset2, the second point in dataset1 becomes the first point in dataset3, etc.

  • Copy dataset1 to dataset2 where dataset2 is in a different worksheet. Copy the corresponding X dataset if it exists.

  • Combine (zip) dataset1 and dataset2 and copy into dataset3 such that the first point in dataset3 is the first point in dataset1, the second point in dataset3 is the first point in dataset2, etc.

no option dataset1 dataset2

-a dataset1 dataset2

-b rowIndex# dataset1 dataset2 -b start# -e end#

The destination range must be within the existing range of dataset2, and the source range must not go outside the existing range of dataset1.

-f dataset1 dataset2

This option reverses the effects of the -m option if applied to each of the new datasets.

-m dataset1 dataset2 dataset3

To use this command, there should be a multiple of 4 points in dataset1, the source dataset. If n is the number of rows in dataset1, take the cell value in row index n/2+1 in dataset1 and copy this value to row index n/2+1 in dataset2. Take the cell value in row index n/2+2 in dataset1 and copy this value to row index n/2+1 in dataset3. Dataset2 and dataset3 now have n/2+1 points. Excluding the last row in dataset2 and dataset3 (row index n/2+1), move the first half of each dataset to the end (n/2) of the dataset.

-s npts dataset1 dataset2

For example, if data1_a contains the integers from 1 to 10, then copy -s 5 data1_a temp; copies the values 1, 3.25, 5.5, 7.75, and 10 into temp. To view the results of this script:

  1. Open the Script window.

  2. Type

edit temp

and press ENTER

Note: This command works only when the destination dataset does not have an associated X column.

-u dataset1 dataset2 dataset3

Reverse of the -z option.

-x dataset1 dataset2

-z dataset1 dataset2 dataset3

Reverse of the -u option.

  • The following script copies Data1_B to Data2_D and copies the X column of Data1_B to the X column of Data2_D.

copy -x Data1_B Data2_D;

  • The next script copies 20 points from Data1_B (74-55+1), beginning at the 13th point, to Data1_F beginning at the 55th cell.

copy -b 13 Data1_B Data1_F -b 55 -e 74;

  • The last script creates odd and even ‘folded’ datasets (data1_b and data1_c), then ‘unfolds’ them (data1_d and data1_e) and combines these to re-create the original dataset (data1_f = data1_a). The number of rows in data1_a should be a multiple of four.

copy -m data1_a data1_b data1_c;

copy -f data1_b data1_d;

copy -f data1_c data1_e;

copy -z data1_d data1_e data1_f;

Copy

Copy one dataset into another. Increase the size of the destination dataset as necessary. To determine the number of elements copied with the copy command, use the copy.n object property.

The copy command should not be used to move data within the same dataset. Instead, create a duplicate of the worksheet and use that as the source dataset.

Usage:

copy [option] dataset1 dataset2 [dataset3]

Options (ordered alphabetically):

Examples:


Create

  • Create a Y dataset and associated X dataset containing all zero values.

  • Create a dataset and an associated X dataset named name_A. Plot the datasets into the active graph layer as a scatter data plot.

  • Create a function.

  • Create a dataset associated with a double-headed vertical arrow as the data point symbol type.

  • Create an empty Y dataset with no associated X values. When plotting, assume an initial X value of 1 and an increment of 1.

  • Create a string dataset.

  • Create a dataset that is not associated with a worksheet and that cannot be plotted.

  • Create a worksheet.

  • Create the datasets but not the worksheet. Format datasets as Text & Numeric.

  • Create the datasets but not the worksheet. Format datasets as Numeric.

  • Create a minimized worksheet. Format datasets as Text & Numeric.

  • Create a minimized worksheet with the datasets set to Numeric.

  • Create a worksheet with the datasets set to Numeric.

  • Create a dataset associated with a vertical line as the data point symbol type.

-c numRows

To plot this data you must specify values for both X and Y. The Y dataset is called name. The X dataset is called name_A.

Note: If name contains an underscore " _ ", it and subsequent characters are ignored when naming the X dataset. So, if name is data1_test, X is called data1_A.

-d numRows

-f

While you can use this notation to create a function, a simpler method is:

myFunc(x)=3+3*sin(x);

-m numRows

Otherwise, same as -c above.

-n numRows

Use the set command to change these X attributes. To view the dataset, use the edit datasetname command.

-s

-t numRows

-w numRows [colName(s)]

You can specify column names after numRows. If you specify column names, you must specify at least two.

Use the window command to open a worksheet created from a specific template.

-wd numRows [colName(s)]

-wdn numRows [colName(s)]

-wh numRows [colName(s)]

To view the worksheet, use the edit datasetname command.

-whn numRows [colName(s)]

To view the worksheet, use the edit datasetname command.

-wn numRows [colName(s)]

-x numRows

Otherwise, same as -c above.

  • The following script creates an empty dataset named data which is set to hold 1000 points.

create data -n 1000;

  • The next script creates an invisible worksheet named Hidden having four columns named aa, bb, cc, dd, with 117 rows each.

create Hidden -wd 117 aa bb cc dd;

  • This script creates a string dataset and demonstrates writing to and reading from the dataset.

create mystrings -s 10;

MyStrings[1]$=Hello;

MyStrings[10]$=Goodbye;

for(ii = 1;ii <= 10;ii++) {

%A=MyStrings[ii]$;

%A=;

};

Create

Creates a dataset or worksheet of name with the number of rows numRows. NumRows should be the maximum number of rows you anticipate requiring. If you specify a numRows value less than 30, name will automatically have 30 rows.

Each dataset is associated with values and attributes.

  • To change the values and attributes of a dataset, use the set command.

  • To view the worksheet for a dataset, use the edit dataset command.

Datasets can also be created with the data() function.

Usage:

create name [option] [numRows]

Options (ordered alphabetically):

Examples:


DDE

  • Connect to the specified application with the specified topic.

  • Disconnect the specified conversation.

  • Execute the specified command string string in the server application specified by varID.

  • Find the conversation ID for the specified application with the specified topic.

  • List all DDE conversations and display them in the Script window.

  • List all DDE conversations and put the result into the %Z string; result is searchable with substring commands.

  • Poke string to the server application as specified by the varID, under the specified item.

  • Poke in column order the data from wksItem to the ServerItem with the specified varID.

  • Ignore escape sequences and send untranslated text.

  • Quiet Origin use of DDE warning message boxes.

  • Request the item item from the server application specified by varID. The result is placed in the %Z string if the operation is successful.

  • Receive in column order the ServerItem with the specified varID into the specified wksItem.

  • Receive in row order (transpose rows and columns) the ServerItem with the specified varID into the specified wksItem.

-c application|topic [varID]

The Application|Topic string should have the application name and topic connected with a “|” character. If the connection is successful, an ID (>= 0) is assigned to the connection and is stored in the specified variable varID. If varID is not specified, the system variable v1 is used. If the connection is not successful, (-1) is stored in the variable.

-d varID

-e varID string

-i application|topic [varID]

The application|Topic string must have the application name and topic connected with a “|” character. If the specified conversation is found, its ID is stored in the specified variable varID. If varID is not specified, the system variable v1 is used. If the conversation cannot be found, (-1) is stored in the variable.

-l [application]

If application is specified, only those conversations with the specified application are listed.

-lz [application]

If application is specified, only those conversations with the specified application are listed.

-p varID item string

-pc varID ServerItem wksItem

The ServerItem should specify a range large enough to hold the data range specified by the wksItem.

-pv varID item string

When using the DDE -p command to send strings, Origin will translate certain sequences of characters beginning with '\' as escape sequences, resulting in the loss of information. For example, a '\t' sequence would translate to a tab character with the result that:

dde -p "My files can be found in C:\temp";

would be received as

"My files can be found in C: emp"

by the DDE Server Application. The -pv command option will cause Origin to ignore these sequences and send untranslated text.

-q n

If n = 1, no warning message boxes are displayed. If n = 0, Origin is reset to its normal state.

-r varID item

-rc varID ServerItem wksItem

Column type should match the type of data being received. If the wksItem is the dataset name, then data is appended to the first empty row. If you specify a cell with Dataset!RiCj, then data replaces existing data. Data above the replacement point is retained, data below is removed. If you specify a range with Dataset!RiCj:RkCl, then data replaces the existing block of data without removing data below.

-rr varID ServerItem wksItem

See the -rc option for additional information.

For the following examples, Excel needs to be running. Either launch Excel manually or use the run -e command.

  • The following script connects to application Excel and topic Sheet1 and remembers the connection as idExcel.

dde -c excel|sheet1 idExcel;

  • The next script pokes the slope value (LR.B) of the most recent linear regression to Excel row 1, column 1.

dde -p idExcel R1C1 $(LR.B);

  • The last script requests the cell value of row 2, column 1 in Excel and assigns it to the variable value.

dde -r idExcel R2C1;value=%Z;

DDE

The dde command provides Dynamic Data Exchange support with Origin as the client application.

Usage:

dde [option] argument

Options (ordered alphabetically):

Examples:


Define

define macroName {script}

  • The following script defines the autoexec macro to create a new Origin worksheet from the ORIGIN.OTW template.

def autoexec { window -T Data Origin; };

  • The next script defines a macro that uses a loop to print a text string three times.

def hello

{

loop (ii, 1, 3)

{ type “$(ii). Hello World”; };

};

Once the hello macro is defined, typing the word hello in the Script window results in the printout:

1. Hello World

2. Hello World

3. Hello World

  • The following script defines a macro named double that expects a single argument. The given argument is then multiplied by 2, and the result is printed.

def double { type “$(%1 * 2)”; };

If you define this double macro (previous example) and then type the following in the Script window:

double 5

Origin responds: 10

You could modify the double macro (previous example) to take two arguments:

def double { type “$(%1 * %2)”; };

Now, if you type the following in the Script window:

double 5 4

Origin responds: 20

Define

This command defines a macro called macroName, and associates it with the given script. MacroName can then be used like a command, and invokes the given script.

To see the script associated with a defined macro, use:

define macroName;

Macros can take up to five arguments. Use the %1, %2, %3, etc., notation within the script to indicate that the macro expects one or more arguments. A macro can accept a number, string, variable, dataset, function, or script as an argument. These are similar to MS-DOS batch command arguments.

If arguments are passed to a macro, the macro can report the number of arguments using the macro.nArg object property.

Usage (ordered alphabetically):

Examples:


Delete

  • Delete the given dataset or function.

  • Delete all the temporary datasets, including all the axes datasets.

  • Delete all datasets that are not in any worksheet and not used in any graphs.

  • Delete the macro macroName.

  • Delete the numeric variable variableName.

no option name

-a

-as

-m macroName

-v variableName

  • The following script deletes all variables that begin with “ex”.

del -v ex*;

Delete

Delete the specified object.

Usage:

delete [option] <name>

Options (ordered alphabetically):

Examples:


  • Take the derivative.

  • Locating peaks in a dataset.

no option dataset [range]

-p dataset [range]

If either slope value is zero, or if the two have opposite signs, the resulting derivative is considered to be zero.

The following script takes the derivative of Data1_B within the range of row index 2 to row index 10.

der Data1_b -b 2 -e 10;

Derivative

Takes the derivative of dataset. Make a copy of dataset before using this command if you do not want to lose the original data. The derivative is calculated by averaging the slopes to neighboring points. Range allows you to specify that the derivative should be performed on a subset of the dataset.

Usage:

derivative [option] dataset [range]

Options (ordered alphabetically):

Examples:


DLL

  • Execute a function called dllFunctionName from a user-provided Dynamic Link Library named dllName.

  • Add the dllName DLL to the LabTalk command list as a new command object named objectName.

  • Add the dllName DLL to the LabTalk command list as a new command object named objectName; reads objectName from the DLL's resource.

  • List all current objects and the DLL that each is mapped to in the Script window.

  • Remove an added object (unload the DLL).

no option dllName dllFunctionName dllString

The dllString is passed to the DLL, which uses the string to perform necessary tasks.

-a objectName dllName

Do not reference a variable or DLL already in use by Origin. This DLL must have been created using information provided by OriginLab and conform to Origin’s external DLL convention. The DLL can also be added to Origin through the [AddOn] section in the ORIGIN.INI file.

Note: A much more flexible DLL calling mechanism is available and described in OriginPro. For information on OriginPro, contact OriginLab or your Origin distributor.

-a dllName

Same as -a objectName dllName, except that Origin reads the objectName from the DLL's resource. The name must be in the string table with an ID value of 1.

-l

-r objectName

A command error will occur if objectName is not mapped to a DLL. This command error causes later script to not get executed. To get around this problem, enclose the DLL -r command in braces.

For example:

script1;

{dll -r objectName}

script2;

In this case the dll -r command is run after script1 and script2 are executed.

DLL

Usage:

dll [options] dllName <dllFunctionName dllString>

Options (ordered alphabetically):


Document

  • Append the contents of fileName to the current project.

  • Append the contents of fileName to the current project. Look first in current directory, then software directory.

  • Count layers in the active graph window.

  • Count all graph windows in the current project that match exactly or begin with name.

  • Count all datasets in the current project that match exactly or begin with name.

  • Count all worksheets in the current project that match exactly or begin with name.

  • Count all worksheets and all datasets in the current project that match exactly or begin with name.

  • Close the current project. Execute the DocEnd macro. Do not exit Origin.

  • Execute the given script for all objects of the specified kind.

  • Execute the given script for all objects of the specified kind in the current Project Explorer folder.

  • Send an update message to all windows.

  • Execute the DocEnd macro. Close the current project. Read the ORGSYS.CNF file. Open a new project.

  • Execute the DocEnd macro. Close the current project. Read the ORGSYS.CNF file. Execute the DocBegin macro. Open the named project.

  • Execute the DocEnd macro. Close the current project. Read the ORGSYS.CNF file. Execute the DocBegin macro. Open the named project. Look first in the current directory, then in the software directory.

  • Rename the current project to newName.

  • Turn off the save flag so that no save prompt appears on exit.

  • Open the template file templateFilename.

  • Set update flags for all layers in all windows.

  • Set update flags for all layers in the current window only.

-a fileName

fileName must be a full path description, including the file extension. fileName can be a project file or child window file.

-af fileName

fileName can be a project file or child window file.

-cl

Assign the result to the variable count.

-cp [name]

Assign the result to the variable count.

-cs [name]

Assign the result to the variable count. A matrix is also counted as a dataset.

-cw [name]

Assign the result to the variable count.

-cws [name]

Assign the result to the variable count.

-d

-e object {script}

This command makes an object active and executes the associated script, looping until each object of the specified type has been active. Most LabTalk commands, methods, and properties act on the active window. Use system variables when a name is required so that the loop script affects the active object.

object can be one of the following:

D If a graph window is active, execute for all data plots in the active layer. If a worksheet is active, execute for all datasets in the active worksheet. (If a matrix is active, there is only one iteration.) %H contains the window name and %C the dataset name in each iteration.

DY If a graph window is active, execute for all data plots in the active layer excluding error bars and labels. If a worksheet is active, execute for all Y datasets (only) in the active worksheet. (If a matrix is active, there is only one iteration.) %H contains the window name and %C the dataset name in each iteration.

G Execute for all labels and other named objects in the active graph layer, the active worksheet, or the active layout page. %B contains the object name in each iteration.

L Execute for all layers in the project. Note that a worksheet, matrix, and layout page each have one layer - and a graph can have multiple layers. %H contains the window name in each iteration. Page.active holds the active layer number. To express page.active, for example, in a type statement, use $(page.active).

LP Execute for all layers in all graph windows (only) in the project. %H contains the window name in each iteration. Page.active holds the active layer number.

LW Execute for all layers in the current window only. Note that a worksheet, matrix, and layout page each have one layer - and a graph can have multiple layers. %H contains the window name in each iteration. Page.active holds the active layer number.

M Execute for all matrices in the project. %H contains the matrix name in each iteration.

O Execute for all non-minimized windows in the project. %H contains the window name in each iteration.

P Execute for all graph windows in the project. %H contains the window name in each iteration.

S Execute for all datasets in the project. %C contains the dataset name in each iteration.

W Execute for all worksheets in the project. %H contains the window name in each iteration.

-ef

Same as the -e option, but only the current Project Explorer folder will be considered.

Note: This assumes that the Project Explorer view mode is set to View Windows in Active Folder. If the view mode is set to View Windows in Active Folder & Subfolders, then this command will consider the active folder and subfolders.

-l

-n

The new project does not contain any child windows.

-o projectName

projectName must be a full path description, including the file extension.

-of projectName

projectName must be a full path description, including the file extension. Look for projectName first in the current directory and then in the software directory.

-r newName

-s

-t path templateFilename

Use this command to open a template from any directory. You must specify a full path description, including the file extension. Similar to the window -t command and page -t command, except you must use a full path description.

-u

-uw

  • The following script prints the contents of all graph windows in the project.

doc -e P print;

  • The next script rescales all layers in the project to show all data, sets each initial X axis scale value to zero, and types the window name and layer number of each to the Script window.

doc -e L

{

layer -a;

x1 = 0;

type “Window: %H, layer number: $(page.active)”;

};

  • The following script puts the name of the first worksheet into %A.

doc -e W

{

%A = %H;

break;

};

  • The last script refreshes the active window.

doc -uw; clr;

Document

Performs various operations on projects. Special counting and looping options are available.

Usage:

document option argument

Options (ordered alphabetically):

Examples:

See also: DocEnd and DocBegin


DoToolbox

  • Select the tool toolNumber from the Tools toolbar.

  • Equivalent to pressing the ALT key.

  • Block the Tools toolbar tool toolNumber.

  • Equivalent to pressing the CTRL key.

  • Make a single mouse click equivalent to a double-click.

  • Open the toolNumber tool from the Tools toolbar but do not open the Data Display tool.

  • Append message to the end of the list of Tools toolbar status bar help messages for the selected tool.

  • When the Data Reader tool is active, disables movement of the cursor with the left and right arrow keys.

  • Restrict use of a Tools toolbar tool to the active layer.

  • Advance to the next defined help message and display the text in the status bar.

  • Select a graph or worksheet window to be pasted to the layout page window.

  • Select a worksheet window to be pasted to the layout page window.

  • Select a graph window to be pasted to the layout page window.

  • Quit the Tools toolbar.

  • When using the Data Selector or Data Reader tools, this option restricts the cursor to only select within dataset.

  • Equivalent to pressing the SHIFT key.

  • Show or hide the Tools toolbar.

  • Unblock the tool toolnumber.

  • When using the Screen Reader tool, this option restricts the cursor to horizontal-only movement at the current Y value.

  • When using the Screen Reader tool, this option restricts the cursor to vertical-only movement at the current X value.

  • Activates the Zoom tool while the current tool is still active.

no option toolNumber [message1 message2 message3 ...]

ToolNumber must be a value from 0 (selects the Pointer tool) to 11 (selects the Circle tool). Each message defines a line of help text for the tool toolNumber that can be displayed in the status bar. Dotoolbox automatically displays message1 if specified.

-a

The function for this switch is not defined.

-b toolNumber

This option makes the tool unavailable for selection.

-c

Allows you to click-and-drag to move data points (the data must be movable - either drawn with the Draw Data tool, or set as movable with the set command). This option has an effect only when the Data Reader tool is active.

-d

-dh toolNumber

ToolNumber values are: Screen Reader = 2, Data Reader = 3, and Data Selector = 4.

-h message

The list is first-in-last-out.

Note: dotool -h and dotool -n are intended to be used sequentially (-h first).

-k

After selecting the Data Reader tool and executing dotool -k, the cursor does not move with the current data point selection when using the left and right arrows on the keyboard.

-l

-n

Note: dotool -h and dotool -n are intended to be used sequentially (-h first).

-p [WindowName]

If WindowName is specified, that window is used. If no window is specified, the Select Worksheet Object dialog box opens. Once the window is selected, click-and-drag an area within the layout page window for the object.

-pw [WindowName]

If WindowName is specified, that window is used. If no window is specified, the Select Worksheet Object dialog box opens. Once the window is selected, click-and-drag an area within the layout page window for the object.

-pg [WindowName]

If WindowName is specified, that window is used. If no window is specified, the Select Graph Object dialog box opens. Once the window is selected, click-and-drag an area within the layout page window for the object.

-q

De-select the current tool and select the Pointer tool.

-r dataset [index]

If index is included, the Data Selector or Data Reader tool moves to position index + 1.

-s

Multiplies the cursor movement speed by 10.

-t show

Show can be the following values: 1 = show and 0 = hide.

-u toolNumber

If toolNumber is not specified, unblock all tools.

-x

-y

-z

  • The following script displays a message in the status bar and uses the Screen Reader tool with restrictions to the current layer.

dotool 2 (Click a location to read X and Y values);

dotool -l;

  • The next script displays a message in the status bar and uses the Data Reader tool with (single) clicks causing double-clicks. After a 5 second delay, another message displays and the tool reverts back to the Pointer tool.

dotool 3 (Select a point by clicking on it) (Time is up);

dotool -d;

sec -p 5;

dotool -n;

dotool 0;

The Screen Reader [image] and Data Reader [image] tools are programmable. If you double-click or press ENTER when one of these tools is active, the PointProc macro is executed. You can define this macro to perform any function.

When you select one of these tools, information is read into the following variables:

X, Y -- The X and Y coordinate values of the current cursor position. The values update each time you click the cursor.

px, py -- The physical position of X and Y on the page, measured in pixels from the top left corner of the page. The values update when you double-click or press ENTER.

%C -- Name of the dataset the Data Reader tool is currently reading (case sensitive). The value updates when you double-click or press ENTER.

index -- Index number for the data point currently selected by the Data Reader tool. The value updates when you double-click or press ENTER.

When you use the Data Selector [image] tool to set the beginning and ending data markers, the internal variables mks1 and mks2 are set and can then be used in script. When programmatically accessing the Data Selector, it is convenient to re-program the PointProc macro to automatically execute a script after you double-click or press ENTER to set the markers.

This script reports the row index and the X and Y values for each marker:

dotool 4;

def pointproc {

py = %C[mks1];

%A = xof(%C);

px = %A[mks1];

type -a Left marker is at index $(mks1), X is $(px),Y is $(py);

py = %C[mks2];

%A = xof(%C);

px = %A[mks2];

type -a Right marker is at index $(mks2), X is $(px),Y is $(py);

dotool 0;

};

DoToolbox

Use this command for management of the Tools toolbar tools. Most of these options perform their functions on the currently selected tool, so you may need to first select a tool before specifying an option for that tool.

Usage:

dotoolbox [option] < toolNumber [message1 message2 ...] >

Options (ordered alphabetically):

Examples:

Programming the Screen Reader and Data Reader Tools

Programming the Data Selector Tool


Draw

Create a line or alter a named line. To create an arbitrary line, value should specify the beginning and ending X and Y values, as follows: {X1,Y1,X2,Y2}.

If -h is specified, a horizontal line is created at the Y position of value. If -v is specified, a vertical line is created at the X position specified by value.

Usage:

draw [option(s)] -l [-h / -v] value

Note 1: To create a movable line, use -lm instead of -l.

Note 2: By default, lines and arrows are attached to the Layer and Scales. To disable this, set @AR = 0.

Any of the following options can be used to set line characteristics. Options are cumulative.

Options (ordered alphabetically):

  • Create a line with default color, dash, and width settings

  • Set line color

  • Set dash pattern

  • Assign a name to a line being created, or alter the existing named line

  • Set line width

no option

The line will not have a name. To alter an unnamed line:

  1. Double-click on the line to open the Arrow Control dialog box.

or

  1. ALT+double-click to open the Label Control dialog box.

-c #

# equals the numeric position in the color list starting with zero (black = 0, red = 1, green = 2, etc.).

-d #

# equals the numeric position in the dash pattern list starting with zero (Solid = 0, dash = 1, dot = 2, etc.).

-n LineName

Only lines with names can be altered through script commands, including the draw command, object options, and object properties and methods. The -n option must directly follow the draw command.

-w #

# equals point size.

Alter an existing named object as specified by the options. Options are cumulative. Only named objects can be altered by LabTalk script.

Usage:

draw -n objectName [option(s)]

To create an object:

    1. Select a tool from the Tools toolbar (such as the Arrow or Text tool).

    2. Click in an open area within an Origin window and create the object.

A text label can also be created from script with the label command.

To name an object:

    1. Hold down the ALT key and double-click on the object. This action opens the Label Control dialog box.

    2. Enter a name in the Object Name text box.

    3. Click OK.

Options (ordered alphabetically):

Examples:

  • Save objectName to a fileName.OGO file

  • Read objects from a file and paste them into the current layer

  • Save objectName to a file when it is a bitmap

  • Read a bitmap from a file into the named object objectName

  • R ead a metafile from a file into the named object objectName

  • Set the objectName object to the inverse of the editing state if inverse is 1

  • Run the named object’s script

  • Show or hide the objectName object

  • Update objectName

  • Update objectName. Only parts of the object that support this option are redrawn

  • Set all numeric fields in the objectName's content to values in variables v1, v2, v3, etc.

  • Assign the values in all numeric fields in the objectName's content to variables v1, v2, v3, etc.

  • Set objectName's X position to the specified value in the current X axis scale

  • Set objectName's Y position to the specified value in the current Y axis scale

  • Copy the message of the objectName text label into the %Z string variable

  • Copy the message of the %Z string variable to the objectName text label's content

-f save fileName

fileName can contain the DRIVE:PATH specification. When used on an object with script in the Label Control dialog box, this command copies the object’s script and all settings along with the object.

-f read fileName

If objectName has been specified with the -n option, the name of the new object is set to objectName.

-fb save fileName

fileName can contain the DRIVE:PATH specification.

-fb read fileName

The objectName object must be a bitmap object. fileName can contain the DRIVE:PATH specification.

Note: This option allows you to import bitmaps of up to 64K.

-fm read fileName

The objectName object must be a metafile object. fileName can contain the DRIVE:PATH specification.

-i inverse

Editing state refers to the Button Edit Mode. When the objectName object is set to the inverse of the editing state (inverse is 1), the object is in Button Edit Mode when the system is not in Button Edit Mode (and vice versa).

-r

The objectName.run() method can also be used to execute an object’s script.

-s value

value = 1 to show, 0 to hide.

-u

The object is redrawn without redrawing the entire graph. The objectName.draw() method can also be used to update a named object.

-uf

The object is redrawn without redrawing the entire graph.

-v set

Numeric fields must be proceeded by an “=“ sign.

-v get

The reverse of -v set.

-x value

-y value

-z get

The specified object must be a text label or the command returns an error.

-z set

The specified object must be a text label or the command returns an error. The reverse of -z get.

  • The following script creates a dashed vertical line that runs the height of the layer frame.

draw -d 2 -l -v X;

  • The next script creates a horizontal line at the center of the graph, with the name YLine.

draw -n YLine -L -h [(y1+y2)/2];

  • The next script moves YLine (previous example) to the top of the graph.

draw -n YLine -L -h y2;

  • The following script creates a green, 4-point-wide line that runs from coordinates X1, Y1 to X4, Y6.

draw -c 2 -w 4 -l {1, 1, 4, 6};

  • The next script copies the metafile MYFILE.WMF into the named metafile object MyObject.

draw -n MyObject -fm read C:\MYDIR\MYFILE.WMF;

  • In the following script, assume myText is a named text label with the original content: mean = 8.2 and sd = 1.2.

The script redraws the object to become: mean = 10.3 and sd = 2.5.

v1 = 10.3;

v2 = 2.5;

draw -n myText -v set -u;

doc -uw; // refresh the window

Draw

This command supports two groups of options:

  • options to draw and set formatting for lines:

  • options to perform various operations on named objects:


Open the worksheet for the dataset datasetName.

O pen the Color Palette dialog box, allowing you to edit the color palette.

no option

Use this command to view a worksheet created with the create -w command.

-c

  • The following script opens the worksheet for the active dataset.

edit %C;

Edit

Usage:

edit [options] <datasetName>

Options (ordered alphabetically):

Examples:


Exit

Usage:

exit

Exit from Origin. Prompts you to save changes before closing. You can disable the save prompt with the doc -s command.


  • Copy FileName1 to FileName2.

-c Path\FileName1 Path\FileName2

If no path is specified, the default Origin path is used.

File

Usage:

file option Path\FileName1 Path\FileName2

Options (ordered alphabetically):


For

  • The following for loop:

for (ii = 1; ii <= 4;ii ++)

{

type "ii = $(ii)";

};

Produces the output:

ii = 1

ii = 2

ii = 3

ii = 4

  • The next for loop:

for (ii = 1, jj = 4; ii <= 4; ii++, jj--)

{

type "ii = $(ii), jj = $(jj)";

};

Produces the output:

ii = 1, jj = 4

ii = 2, jj = 3

ii = 3, jj = 2

ii = 4, jj = 1

LabTalk does not have a While command. However, the While command can be easily simulated with the for loop.

The While loop would look like this:

expression1;

while (expression2) {

statement

expression3;

};

The equivalent for loop syntax is:

for (expression1; expression2; expression3)

statement

Example:

This for loop script simulates a While loop. This script continues to prompt for new values until you enter zero or a negative number.

p = 1;

for ( ;p > 0; )

{

getn -s (Enter 0 to quit) p (Next value);

};

For

The for command is identical to the C For loop.

Usage:

for (expression1; expression2; expression3) {script}

First, expression1 is evaluated. This specifies initialization for the loop. Second, expression2 is evaluated and if true, then script is executed. (If no conditional operator is used in expression2, any non-zero value is accepted as true.) Third, expression3, often an incrementation, is executed. The process repeats at the second step. The loop terminates when expression2 is found to be false. Any expression can consist of multiple statements, each separated by a comma.

Note: If your script loops endlessly, you can interrupt the script by pressing ESC.

Examples:

While Loop Simulation


Get

  • Get the beginning of the display range.

  • Get the line color and the symbol edge color for plots with lines and/or symbols.

  • Get the fill color (for fill area graphs).

  • Get the Line plot line color.

  • Get the color for level n in a color-mapped data plot.

  • Get the symbol edge color for plots with symbols.

  • Get the symbol fill color, for plots with symbols.

  • Get the color value for Z level n in a color-mapped data plot.

  • Get the line style index number.

  • Get the end of the display range.

  • Get the corresponding X value for the first data point when X values are from an initial value and an increment.

  • Get the histogram lower bin value.

  • Get the histogram upper bin value.

  • Get the histogram bin size.

  • Get the X increment for the name dataset when X values are from an initial value and an increment.

  • Get the internal data type for the name dataset or matrix and place this value in variableName.

  • Get the symbol shape, for plots with symbols.

  • For graphs with data labels, determine whether the data labels display in bold font style.

  • Get the symbol interior, for plots with symbols.

  • For graphs with data labels, determine whether the data labels display in italic font style.

  • For graphs with alphanumeric symbols (set DatasetName -k 12 or set DatasetName -k 13), get the font index.

  • For graphs with data labels, determine whether the data labels display with an underline.

  • Get the line connection method (Connect drop-down on Line tab).

  • Determine whether horizontal drop lines are displayed.

  • Get the horizontal drop line color following the color palette.

  • Get the horizontal drop line style.

  • Get the horizontal drop line width.

  • Determine whether vertical drop lines are displayed.

  • Get the vertical drop line color.

  • Get the vertical drop line style.

  • Get the vertical drop line width.

-b [variableName]

The value of variableName equals the first index number.

-c [variableName]

Following the Origin color palette (Format:Color Palette): 1 = black, 2 = red, 3 = green, 4 = blue, etc.

-cf [variableName]

Following the Origin color palette (Format:Color Palette): 1 = black, 2 = red, 3 = green, 4 = blue, etc.

-cl [variableName]

Following the Origin color palette (Format:Color Palette): 1 = black, 2 = red, 3 = green, 4 = blue, etc.

-cmn [variableName]

Following the Origin color palette (Format:Color Palette): 1 = black, 2 = red, 3 = green, 4 = blue, etc.

-cse [variableName]

Following the Origin color palette (Format:Color Palette): 1 = black, 2 = red, 3 = green, 4 = blue, etc.

-csf [variableName]

Follows the Origin color palette (Format:Color Palette): 1 = black, 2 = red, 3 = green, 4 = blue, etc.

-czn [variableName]

Value for Z level n in a color mapped data plot.

-d [variableName]

By the order in the Style drop-down list on the Line tab of the Plot Details dialog box: 0 = solid, 1 = dash, etc. as in the line style list.

-e [variableName]

The value of variableName equals the last index number.

-f [variableName]

-hbb [variableName]

Get the lower limit of the binned data.

-hbe [variableName]

Get the upper limit of the binned data.

-hbs [variableName]

-i [variableName]

-it variableName

For example, to get the internal data type of the active dataset held in %C and assign this value to a variable named v, use: get %C -it v;

Possible return values are the same as the constants defined in the oc_const.h Origin C header file (located in the \OriginC\system subfolder):

FSI_DOUBLE = 0

FSI_REAL = 1

FSI_SHORT = 2

FSI_LONG = 3

FSI_CHAR = 4

FSI_TEXT = 5

FSI_MIXED = 6

FSI_BYTE = 7

FSI_USHORT = 8

FSI_ULONG = 9

If %C is a column in a worksheet, then only a Numeric column is supported and only types FSI_DOUBLE, FSI_REAL, FSI_SHORT, and FSI_LONG are supported.

If %C is a matrix, then all these constants are supported. However, FSI_TEXT and FSI_MIXED should be avoided.

-k [variableName]

0 = no symbol, 1 = square, 2 = circle, 3 = up triangle, 4 = down triangle, 5 = diamond, 6 = cross (+), 7 = cross (x), 8 = star (*), 9 = bar (-), 10 = bar (|), 11 = number, 12 = LETTER, 13 = letter, 14 = right arrow, 15 = left triangle, 16 = right triangle, 17 = hexagon, 18 = star, 19 = pentagon, 20 = sphere.

The numeric values of 56 and 58 display special symbol types: 56 = data markers and 58 = vertical lines that mark the X position of the data point.

-kb [variableName]

1 = bold on, 0 = bold off.

-kf [variableName]

0 = solid, 1 = open, 2 = dot center, 3 = hollow, 4 = + center, 5 = x center, 6 = - center, 7 = | center, 8 = half up, 9 = half right, 10 = half down, 11 = half left.

-ki [variableName]

1 = italic on, 0 = italic off.

-kn [variableName]

Use get DatasetName -kn variableName. For example:

get data1_b -kn fontVariable;

-ku [variableName]

1 = underline on, 0 = underline off.

-l [variableName]

0 = no line, 1 = straight, 2 = 2 pt. segment, 3 = 3 pt. segment, 8 = Bspline, 9 = spline, 11 = step horz, 12 = step vert, 13 = step center, 15 = Bezier.

-lh [variableName]

1 = show drop lines, 0 = hide drop lines.

-lhc [variableName]

1 = black, 2 = red, 3 = green, 4 = blue, etc.

-lhs [variableName]

0 = solid, 1 = dash, etc. as in the line style list.

-lhw [variableName]

500 = 1 point.

-lv [variableName]

1 = show drop lines, 0 = hide drop lines.

-lvc [variableName]

Follows the Origin color palette: 1 = black, 2 = red, 3 = green, 4 = blue, etc.

-lvs [variableName]

0 = solid, 1 = dash, etc. as in the line style list.

-lvw [variableName]

500 = 1 point.

  • Get dataset movability with the cursor.

  • Get the histogram bin worksheet name.

  • Create the histogram bin worksheet.

  • Get the bar or column border color.

  • Get the bar or column border line style.

  • Get the bar or column border width.

  • Determine whether vertical drop lines are displayed.

  • Determine whether the fill area option is enabled.

  • Get the bar or column background color.

  • Get the bar or column fill pattern color.

  • Get the bar or column fill pattern.

  • Get the area plot fill-area-under-curve setting.

  • Get the fill pattern line width (data plots with bars or columns).

  • Get the data plot ID.

  • Determine whether the data plot is hidden.

  • Get the skip value (if used) for a dataset.

  • Get the data label font.

  • Get the data label justification.

  • Get the data label text rotation angle.

  • Get the data label font size.

  • Get the Y offset for the data label.

  • Get the X offset for the data label.

  • Get the width of connecting lines.

  • Get the data point symbol size (measured in pts).

-m [variableName]

1 = movable, 0 = not movable (default).

-nhw [variableName]

-nhwc [variableName]

-pbc [variableName]

1 = black, 2 = red, 3 = green, 4 = blue, etc.

-pbs [variableName]

0 = solid, 1 = dash, etc. as in the line style list.

-pbw [variableName]

500 = 1 point.

-pd [variableName]

1 = show drop lines, 0 = hide drop lines. (See also the -lh (horizontal drop lines) and -lv (vertical drop lines) options.)

-pf [variableName]

1 = fill area on, 2 = fill area off.

-pfb [variableName]

1 = black, 2 = red, 3 = green, 4 = blue, etc.

-pfc [variableName]

For data plots with bars or columns, following the color palette: 1 = black, 2 = red, 3 = green, 4 = blue, etc.

-pfp [variableName]

0 = none, 1 = dense, 2 = medium, etc.

-pfv fillAreaSetting

1 = normal, 2 = inclusive broken by missing values, and 3 = exclusive broken by missing values.

-pfw [variableName]

500 = 1 point.

-pt [variableName]

For example, 200 = line and 201 = scatter. For a complete list of plot IDs, see the worksheet -p command.

-s [variableName]

1 = shown, 0 = hidden.

-skip [variableName]

-tf [variableName]

Font is the index number in the current font list.

-tj [variableName]

0 for left, 1 for center.

-tr [variableName]

-ts [variableName]

-tx [variableName]

Y offset is in percent of label text height.

-ty [variableName]

X offset is in percent of label text height.

-w [variableName]

500 = 1 point.

-z [variableName]

One point= 1/72 inch.

  • The following script creates the variable EndIndex (if it does not already exist) and sets it equal to the index number of the end index in the display range.

get data1_b -e EndIndex;

Get

Similar to the set command, this command gets (reads) the value of a certain attribute of the dataset, data plot, or worksheet specified by name, and places this value into variableName. If variableName is absent, the value is placed into the variable v1. The option switch determines what value is placed into variableName or v1.

Usage:

get name option [variableName]

Note: Some of these attributes can also be read or set using object properties.

Options a through l (ordered alphabetically):

Options m through z (ordered alphabetically):

Examples:


GetFileName

  • Open the Open dialog box, with file displayed in the Files of Type drop-down list.

  • Get the nth file name with full path into the %A string variable from the file list created by getfile -m.

  • Opens the Import Multiple ASCII dialog box. The number of files selected is stored in the variable count.

no option file

File is the default file type specification. After editing the dialog box, %A contains the file name and %B contains the full path to the file.

-g n

-m file

File is the default file specification and the default file type specification.

  • The following script prompts for a file name and imports ASCII data into the active worksheet.

getfile *.dat;open -w %A;

  • The next script prompts for a file name with multiple types (Lotus and DIF files) of files to import into the worksheet.

getfile *.WKS *.DIF;open -wf %A;

  • The following script (placed in a button on a worksheet) prompts the user to select multiple files and prints the file names to the Script window.

type -a; //open the Script window

getfile -m *.*; // prompt for multiple files

for (ii = 1; ii <= count; ii ++)

{

getfile -g ii; // get the iith file into %A

type "%A"; // print it out in the Script window

};

GetFileName

Usage:

getfilename [option] argument

Options (ordered alphabetically):

Examples:


GetNumber

  • Open a small dialog box having a single text box labeled text1. Numbers entered into Text1 are stored in variable1.

-s text1 variable1 [dialogboxtitle]

For getting a single value, this option opens a small dialog box displaying a single text box. This option is available for entering numbers only.

  • The following script illustrates the use of the getnumber command.

%A = enter name;

i = 1;

j = 1;

k = 0;

%B = "line1 line2 line3"; // drop down list with three entries

getn

(X Minimum) MyVar // a variable

(my boolean) k:2s // show remaining items if k = 1 (checked)

(my list) i:B // use %B as the list items

(Color) j:@C // color list, init j = 1

(Your Name) %%A // %% to preserve %A for holding the name

(Title of this dialog); // end of getnumber

  • The following example illustrates how you can detect when a user clicks CANCEL in the GetNumber dialog box.

When a user clicks CANCEL in a GetNumber dialog box, Origin generates a #Command Error! which will stop your script. If you need to continue processing and want to know which button in the dialog box was clicked, you can make use of the following general technique.

Use Notepad or another text editor to create a file called UTIL.OGS. Type the following text in your text editor and save the file.

// Beginning of sample code

[getnumber]

flag = 0;

var = %2;

getnumber (%1) var (%3);

flag = 1;

return;

// End of sample code

Note that a variable named flag is set to 0 before the GetNumber command and set to 1 after the GetNumber command. When this code is called via a run.section method, the two lines after the GetNumber command will execute only if the user clicks OK. Since this code is executing in an external file, the #Command Error! that is generated by clicking CANCEL stops the external script from completing, but allows the script that called it to continue. Your calling script can then check the value of the flag variable to determine what action the user took:

flag = 1 indicates the user clicked OK

flag = 0 indicates the user clicked CANCEL

Here is an example of how to call and use this routine:

sample = 10;

run.section(util,getnumber,"My Variable" sample "Enter your value");

if (flag == 1)

{

sample = var;

type -a "You clicked OK or Enter and the value of sample is now $(sample)";

}

else

{

type -a "You clicked Cancel. Value of sample will not be changed.";

}

This same technique can be applied with other 'GET...' dialog boxes.

GetNumber

Opens a dialog box that allows user input of up to six numbers or strings, which are placed into variables variable1 through variable6. Text1 through text6 are the dialog box text associated with each variable. Dialogboxtitle appears in the dialog box title bar.

Usage:

getnumber [options] (text1) variable1 (text2) variable2 [dialogboxtitle]

To specify a string variable, you must use the double % notation. For example: %%A. This is necessary to protect the integrity of the string variable.

To specify a binary variable with a check box instead of an edit box, insert “:2” after the name of the variable. You can also show or hide items below by specifying “:2s” or “:2h”. The former shows all items below if the check box is enabled, while the latter hides them.

A drop down list can also be specified and the variable will represent the selection index in the list. In this case, you must first put the list in a string variable, and specify the character for the string variable after the “:”.

Standard lists like the color list can also be specified. They are “:@C” for the color list, “:@D” for the dashed line list, “:@T” for the font list, “:@S” for the font size list, and “:@P” for the pattern list.

Note 1: In versions prior to 7.0, if a getnumber dialog prompted for a variable that was not defined or missing, the dialog would display the missing value notation : "--". Versions 7.0 and higher display an empty text box for variables that have not been assigned or have missing value.

Note 2: In addition to entering literal text for text1, text2... and dialogboxtitle, you can specify $[OMGfileName].Section.Title. This enables you to access a string title in a message file. The OMGfileName extension is assumed to be OMG. If OMGfileName is not specified, the ORIGIN.OMG file is assumed. For an example using this syntax, see the Type command.

Options (ordered alphabetically):

Examples:


GetPts

The getpts command behaves differently than the other 'get' commands. For example, with the getnumber command, first a dialog box opens and then the user makes a selection in that dialog box. Any script after the getnumber command is not executed until the user makes a selection. This allows your script to take different routes depending on the user's selection. However, after the getpts command is executed, the next LabTalk statements are executed without waiting for any user input.

The getpts command can be used in script when it is necessary for the user to pick points on their graph, and then perform some custom analysis. If you use the getpts command incorrectly, your script could complete before the user actually picks a point on their graph. To avoid this problem and to help you understand the getpts command, review the following information.

When using the getpts command, data is entered by:

  • Double-clicking on a data point in the graph.

  • Clicking on a data point in the graph and then pressing ENTER.

  • Use the Data Reader tool to get npts from the dataset the user clicks on.

  • Use the Screen Reader tool to get the XY coordinate value of points in a graph window.

  • Plot each point up to and including npts, and put each successive XY value into dataset.

  • Use the Screen Reader tool to get the XY coordinate value of points in a graph window. Restrict cursor movement to horizontal.

  • Use the Screen Reader tool to get the XY coordinate value of points in a graph window. Restrict cursor movement to vertical.

no option

Values are read into the following getpts object properties:

getpts.count -- Contains the number of selected points.

getpts.data$ -- Dataset name.

getpts.xdata -- Dataset that holds each successive X position value.

getpts.indexdata -- Dataset that holds the index value of each successive data point that is double-clicked.

-a npts [message]

Values are read into the getpts object properties.

-n dataset npts [message]

Dataset must already exist before you can use this option.

-x npts [message]

Values are read into the getpts object properties.

-y npts [message]

Values are read into the getpts object properties.

The getpts command works as follows:

First, the getpts.count object property is set to zero. Next, the getpts.max object property is set to the number of requested points. Lastly, the getpts command runs the script in the [GetPtsNoDraw] section of the ORIGIN.OGS file.

The [GetPtsNoDraw] section of the file performs the following:

  1. Sets the dataset name for X position to _xpos.

  2. Sets the dataset name for row index to _indx.

  3. Sets the dataset name for reading points to the active dataset.

  4. Creates the datasets (if needed) for X position and row index.

  5. Defines the pointproc macro as follows:

def PointProc

{

#!type click;

%B = getpts.xData$;

%B[getpts.count] = x;

%B = getpts.indexData$;

%B[getpts.count] = index;

if (getpts.count >= getpts.max)

{

type end toolbox;

{EndToolbox};

doTool 0;

}

else

doTool -next;

};

The pointproc macro executes each time the user selects a data point - either by double-clicking on the point, or single-clicking and pressing ENTER. Once the points are selected, Origin internally traps the selection, sets X to the selected X position and index to the row for this X value, and increments the getpts.count object property. Then, the pointproc macro executes. In this case, this causes the X value and row index to be added to the appropriate datasets. The macro then tests to see if the getpts.count object value is greater than or equal to getpts.max. If getpts.count is greater than getpts.max, then the endtoolbox macro executes and the cursor is switched back to a pointer (dotool 0).

The endtoolbox macro is normally not defined by Origin. It is available so that you can define it to perform a custom routine. For example, if your script prompts the user to pick points on the graph, and then the script performs some custom analysis, you could define the endtoolbox macro to set a data range for analysis using the Data Selector tool. This tool sets the mks1 and mks2 variables to a row index which defines a region for analysis routines. In such an example, you can define the endtoolbox macro to set these markers based on the information gathered by the getpts command, and then execute a command that both carries out an integration (or other analysis) and types the results to the Script window:

def EndToolBox {

mks1 = _indx[1];

mks2 = _indx[2];

integrate %C;

type -a "The Area under %C from $(_xpos[1]) to $(_xpos[2]) is $(INTEG.AREA).";

};

In this macro definition, the integrate command puts its results in the integ object. In particular, the calculated area is in the integ.area property. Note that %C contains the active dataset name and the $() notation is used to evaluate a variable or expression and interpret the result as a string.

To test the getpts command with the endtoolbox macro, perform the following:

  1. Plot some sample data.

  2. Open the Script window and turn off script execution (Edit:Script Execution).

  3. Type the endtoolbox macro definition into the Script window.

  4. Type the following in the Script window:

getpts 2;

  5. Turn script execution back on by reselecting Edit:Script Execution.

  6. Highlight all the lines of script and press ENTER to execute the entire script.

The endtoolbox macro gets defined and getpts begins - allowing you (or the user) to select two points on the graph to mark a particular region. The actual analysis is held off until getpts is done - which triggers the endtoolbox routine embedded in the pointproc macro. When the last point is selected, the endtoolbox macro finally runs and the area is calculated with the results typed to the Script window.

Redefining the Pointproc Macro

Because the pointproc macro executes whenever the user selects a data point or a screen location, you can customize the pointproc macro to meet your specific application needs. In the following script example, the user selects a data point on a graph, and then selects a location to display the X and Y coordinates of the selected data point. For this example, you must first plot some data. Then, with the graph window active, run the following script from the Script window:

def pointproc {

xx1=x;

yy1=y;

dotool 0;

def pointproc {

label -s -j 1 -a x y "($(xx1),$(yy1))";

dotool 0;

};

dotool 2;

};

dotool 3;

This script works as follows:

  1. First the pointproc macro is defined.

  2. After the macro definition (which includes a redefinition of pointproc), the Data Selector tool is activated (dotool 3).

  3. When the Data Selector tool is active, the user selects a data point (for example, a peak position).

  4. After selecting the data point, the pointproc macro runs (by default).

  5. The pointproc macro assigns the X and Y values of the selected data point to the two variables (xx1 and yy1).

  6. The pointproc macro temporarily makes the Pointer tool active, and then redefines the pointproc macro.

  7. The Screen Reader tool is activated (dotool 2).

  8. While the Screen Reader tool is active, the user selects a screen location for the data point label.

  9. After selecting the location, by default the pointproc macro runs again (the second definition of it). This results in a label displaying on the graph at the specified location.

  10. The Pointer tool is reactivated.

GetPts

This command uses a Tools toolbar tool to get dataset values of the active dataset from the current graph window.

Usage:

getpts [options] npts [(message)]

The option determines which tool is used. Variables are stored in properties of the getpts object. Once a tool is selected, the PointProc macro is executed when the user double-clicks or presses ENTER. When npts is reached, the EndToolbox macro is executed. If another Tools toolbar tool is selected before npts is reached, the QuitToolbox macro is executed.

The message help text appears in the status bar. Message is not sent to the substitution processor for string substitution until PointProc is executed. This means that your message text can contain real-time information.

For a detailed discussion of the getpts command, see the Notes and Examples sections that follow.

Notes:

Options (ordered alphabetically):

Examples:


GetSaveName

Opens the Save As dialog box.

Usage:

getsavename [fileName] *.extension

If fileName is specified, it is the default file name in the Save As dialog box. Extension is the default file extension. Although extension must be specified, * can be used to leave the choice open.

If you enter a file name and click OK, the file name and the selected path are saved into the string variable %A. If you click Cancel, %A is unchanged.

Examples:


GetString

Opens a dialog box in which the user can enter a text string.

Usage:

getstring (message) initialValue [(dialogTitle)]

Message is the dialog box message, initialValue is the initial text string value, and dialogTitle appears in the dialog box title bar. The user-entered string is put into the string variable %B.

Note: In addition to entering literal text for message, you can specify $[OMGfileName].Section.Title. This enables you to access a string title in a message file. The OMGfileName extension is assumed to be OMG. If OMGfileName is not specified, the ORIGIN.OMG file is assumed. For an example using this syntax, see the Type command.


GetYesNo

Opens a dialog box (whose title is dialogTitle) that displays Yes, No, and Cancel buttons and the text string message.

getyesno (message) variable [(dialogTitle)]

  • Variable becomes 1 if the user clicks Yes.

  • Variable becomes 0 if the user clicks No.

  • Variable remains unchanged if the user clicks Cancel. Additionally, a Command Error! is typed to the Script window when Cancel is clicked.

Note: In addition to entering literal text for message, you can specify $[OMGfileName].Section.Title. This enables you to access a string title in a message file. The OMGfileName extension is assumed to be OMG. If OMGfileName is not specified, the ORIGIN.OMG file is assumed. For an example using this syntax, see the Type command.

Examples:


If

  • The following script opens a message box displaying “Yes!”.

%M = test;

if (%M == “TEST”) type -b “Yes!”;

  • If a graph window is active, this script opens a message box displaying, "A graph is active"; if a worksheet is active, a message box opens with "A worksheet is active".

if(exist(%H)==3)

type -b "A graph is active";

else

if(exist(%H)==2)

type -b "A worksheet is active";

  • The next script finds the first point in data1_a that is greater than 100.

ii = 1;

{

if (data1_a[ii] > 100) break;

else ii++; // this semicolon ends the if-else statement

};

if (ii != $(numPoints + 1))

{

type -b “The index number of first value >100 is $(ii)”;

type “first value > 100 is $(data1_a[ii])” ;

}

If

Usage:

if (testCondition) sentence1; [else sentence2;]

if (testCondition) {script1} [else {script2}]

Evaluate testCondition and if true, execute script1. Expressions without conditional operators are considered true if the result of the expression is non-zero.

If the optional else is present and testCondition is false (zero), then execute script2. There should be a space after the else. Strings should be quoted and string comparisons are not case sensitive.

Single statement script arguments should end with a semicolon. Multiple statement script arguments must be surrounded by braces {}. Each statement within the braces should end with a semicolon. It is not necessary to follow the final brace of a script with a semicolon.

Examples:


Integrate

integ.area -- Area of the integration.

integ.y0 -- Maximum height (measured from the baseline if present, otherwise measured from zero).

integ.x0 -- X value of y0.

integ.dx -- Half width of the peak.

integ.x1 -- Beginning X.

integ.x2 -- Ending X.

  • Integrate dataset from zero.

  • Perform the integration without creating the (temporary) _integ_area dataset.

  • Integrate dataset from 0 but do not display the temporary shading of the integration area.

  • Integrate from the given baseline dataset.

no options dataset [range]

-a dataset [range]

-q dataset [range]

-r baseDataset dataset [range]

The Y values are calculated by interpolating the baseline. If the baseline is a spline, the spline interpolation values are used. Otherwise, the interpolation is linear.

  • The following script integrates the Data2_D dataset from row index 4 to row index 8.

integrate Data2_D -b 4 -e 8;

  • The next script integrates the Data2_D dataset using Data2_B as a baseline to subtract.

integ -r Data2_B Data2_D;

Integrate

This command integrates dataset using the trapezoidal rule.

Usage:

integrate [-r basedataset] dataset [range]

The integration results are placed into the following integ object properties:

A dataset named _integ_area is created to hold the integrated area data. The leading underscore indicates that this is a temporary dataset that is deleted when printing or saving (or overwritten if another integration is performed). You can save the contents of this dataset to a permanent dataset of your own naming. However, note that since Origin 7, this dataset is automatically saved to a hidden worksheet following the naming convention Integraln_columnName. To find out more, see the Origin Help file.

Options (ordered alphabetically):

Examples:


Label

You can use escape sequences in a string to customize the text display. These sequences begin with the backslash character (\). All text objects (those created with the label command or with the Text tool) as well as text plotted from a Label column will display according to the rules of these sequences.

The following text formatting commands are available:

\+(text): Format text as superscript.

\-(text): Format text as subscript.

\=(text1,text2): Format text1 as subscript, text2 as superscript.

\p%pointsize(text): Change the point size of text. 200 doubles the size, 100 results in no change, etc.

\i(text): Format text as italics.

\b(text): Format text as bold.

\g(text): Format text in Greek symbols.

\ab(text): Display a bar above text.

\ad(text): Display a short line - a dot - above text.

\(ASCII character code): Displays the specified ASCII symbol.

\f:fontname(text): Displays text using the fontname font. You can abbreviate fontname, as long as you use enough letters for the name to be unique.

\cnumber(text): Displays text in the color located at position number in the Color drop-down lists.

The following non-printable characters are supported:

\n New line.

\r Return.

\d Delete/backspace.

\t Tab.

\xhh Any characters, where hh are two hex digits.

  • Place an unnamed text label message in the default location on the page in the active window.

  • Place the label at coordinates xy, where x and y are Cartesian coordinate values.

  • Set the text label border style to the nth style in the Show Background drop down list of the Text Control dialog box.

  • Place the label at coordinates xy, as measured in screen pixels from the top left corner of the page.

  • Open the Text Control dialog box with message in the text box.

  • Change the label font type to fontName.

  • Justify the label message text.

  • Create a new, or replace the existing, message of the named label.

  • Determine the label offset (in percent).

  • Place the label at coordinates xy, where x and y represent the percent distance from the top left corner of the layer frame.

  • Place the label into one of the four active layer quadrants n.

  • Delete the label named labelName.

  • Delete all objects whose names start with labelNamePrefix.

  • Enable the use of substitution notation (% and $) in the argument string.

  • Enable conversion of \r\n\t type of notation.

  • Create a message label and select the Link to Variables check box in the Label Control dialog box.

  • Create a label with message and name the object TITLE.

  • Create a new, or replace the existing, bottom X axis title.

  • Create a new, or replace the existing, top X axis title.

  • Create a new, or replace the existing, left Y axis title.

  • Create a new, or replace the existing, right Y axis title.

  • Create a new, or replace the existing, back Z axis title.

  • Create a new, or replace the existing, front Z axis title.

no option message

-a x y message

-b n

-d x y message

-e message

Click OK to create a text label with the message.

-f fontName message

FontName can be abbreviated as long as the name remains unique. For multi-word font names, you must include quotations around fontName.

-j n message

n can be 0 (left), 1 (center), or 2 (right). Justification of axis titles is preset and cannot be altered.

-n labelName message

LabelName specifies the name of the label, which appears in the Label Control dialog box.

-o dx dy message

This option is only applicable for labels in which Layer and Scales is selected in the Attach To group of the label’s Label Control dialog box.

-o dx dy message

This option is only applicable for labels in which Layer and Scales is selected in the Attach To group of the label’s Label Control dialog box.

-p x y message

-q n message

The quadrants are numbered from 1 to 4, counterclockwise from the top right.

-r labelName

-ra labelNamePrefix

If labelNamePrefix is not included, then all labels on the page are deleted.

-s message

By default, the label command does not substitute the % and $ notation. This option allows you to insert numeric and string variables into the label message.

-sa message

Use this option to create multiple line text labels (\r\n) without adding new lines to the script. To also enable substitution, use -s -sa together.

-sl message

See Examples.

-t message

-xb message

-xt message

-yl message

-yr message

-zb message

-zf message

  • The following script creates a label that reads New Label Text which is center justified and named MYLABEL. It draws the label in quadrant 3 of the active layer of the active window.

label -q 3 -j 2 -n MYLABEL New Label Text;

  • The next script creates a bottom X axis label Maximum Current.

lab -xb (Maximum Current);

  • The next script updates the content of the label named myLabel with run time values. Note that you could also set up the label with the same text with the Link to Variables option enabled in the Label Control dialog box (see the next example).

%A = "position = $(x)";

label -s -n myLabel %A;

  • The next script creates a label named myLabel with the Link to Variables check box in the Label Control dialog box selected. The label displays the current value of the x system variable, which is the current X coordinate of the Screen Reader, Data Reader, or Data Selector tools.

label -sl -n mylabel "position = $(x)";

Label

Places a text label on the page.

Usage:

label [options] message

By adding one or more option switches you can modify the manner in which the label is created. The message to be displayed by the label is always the final argument. The label command allows multiple option switches. When -xb, -yl, -xt, -yr, -zf, or -zb are used, they must be the final option (immediately preceding the label message). Also, when -n is used, it must be the final option (immediately preceding the label message). Options can be combined only when it makes sense to do so and when they do not conflict with each other.

In addition to entering literal text for message, you can specify $[OMGfileName].Section.Title. This enables you to access a string title in a message file. The OMGfileName extension is assumed to be OMG. If OMGfileName is not specified, the ORIGIN.OMG file is assumed. For an example using this syntax, see the Type command.

Note -- Using Escape Sequences to Control Text Format:

Options (ordered alphabetically):

Examples:


Layer

  • Layer width, height, and horizontal and vertical position on the page.

  • Control of perspective, location of rotational axes, and plot relative to the layer frame (3D plots).

  • Set the 3D graph rotation.

  • Rescale the X and Y axes of the active layer to show all the data plotted in that layer.

  • Rescale the X and Y axes of the active layer to show all the data plotted in that layer, but ignore tick settings.

  • Rescale a 3D plot but do not rescale the Z axis.

  • Control availability of plotting parameters: exchange X/Y axes, stack plots, draw axes/grid lines on top of data, clip data, show frame.

  • Set graph display caching to none, raster, or vector.

  • Set worksheet as read-only.

  • Count datasets plotted in the active layer.

  • Save a color map.

  • Load a saved color map.

  • Delete the active layer.

  • Remove a dataset from the active layer but do not remove the data plot style holder.

  • Group all datasets in the active layer.

  • Ungroup all datasets in the active layer.

  • Hide or Show the layer.

  • Delete all data plot style holders in the active graph window layer. Resave the graph window as a template to update the template settings.

  • Add a dataset to the active layer.

  • Replot the data into the specified graph type.

  • Copy all data plots from the specified layer number of the specified graph window into the active graph layer.

  • Delete all data plot style holders that are not in use in the active graph window layer. Resave the graph window as a template to update the template settings.

  • Delete all data plot style holders that are in use in the active graph window layer. Resave the graph window as a template to update the template settings.

no option [width height xOffset yOffset]

Width, height, xOffset, and yOffset specify layer width, height, and horizontal and vertical position on the page (measured in the current units, from the top left corner of the page to the top left corner of the layer), respectively. A zero value for width or height retains the current setting.

A single zero argument (layer 0) fits the active layer to the page. If no arguments are issued, the Select Columns for Plotting dialog box opens.

-3d m value

Perform the following options on a 3D graph for values of value: P+1 = increase the perspective angle plus three units, P-1 = decrease the perspective angle minus three units, Rotation = reset the axes to their original rotational location, and Frame = fit the graph to the layer frame. If value equals P+1, P-1, Rotation, or Frame, execute doc -uw to update the graph.

-3d r %A x

%A is either the X, Y, or Z axis to be rotated. X is the number of degrees +/- to rotate the graph. After executing this command, execute doc -uw to update the graph.

-a

The range of the X axis includes the rescale margin and begins and ends on the nearest major or minor tick. To rescale only the X or Y axis, set the other axis as fixed (for example, using layer.axis.rescale = 1). You can then save the graph window as a template.

-at

The range of the X axis will be the data range plus the rescale margin.

-az

-b parameter value

Flag the given parameter as on or off for the active layer or toggle its state. Value must be 1 = on, 0 = off, or -1 = toggle. The possible parameters are: x = exchange X and Y axes, s = stack data plots, a = draw the axes after (on top of) the data, g = draw grid lines after (on top of) the data, c = clip data, and f = show the frame.

-b 3DB value

Value = 0 for no caching. Value = 1 for raster caching. Value = 2 for vector caching.

-b R value

Value = 0 for editing worksheet. Value = 1 for read-only worksheet.

-c

Put the result into the count variable, and concatenate the names of all datasets into %Z.

-cm s[r|p] fileName [index|name]

The optional r switch converts a palette index to RGB values. The optional p switch converts RGB values to a palette index. If the layer contains multiple data plots, use index or name to specify a data plot other than the active data plot. The string notation %(index, @D) returns the name of the index'th data plot.

-cm l[r|p] fileName [index|name]

The optional r switch converts a palette index to RGB values. The optional p switch converts RGB values to a palette index. If the layer contains multiple data plots, use index or name to specify a data plot other than the active data plot. The string notation %(index, @D) returns the name of the index'th data plot.

-d

-e dataset

You can also use this command option to remove multiple datasets from the layer. One way to do this is to list the datasets after the -e option. For example, the following command removes data1_b and data1_c from the layer:

layer -e data1_b data1_c;

You can also specify a string variable that holds the names of the datasets you want to remove. The following script performs the same action as the previous example:

%Z = "data1_b data1_c";

layer -e %Z;

Furthermore, because the -c option puts the names of the datasets in the active layer into the %Z variable, the following script removes all the datasets from the layer:

layer -c;

layer -e %Z;

-g

-gu

-h value

If value = 1, hide the layer. If value = 0, show the layer. This command does not automatically refresh the window display.

-i

For information on data plot style holders, see the Origin Help file.

-i dataset

Include dataset in the active layer, that is, add dataset to the Layer Contents list in the Layer n dialog box. This is the standard method for plotting a dataset. If dataset is omitted, this command removes all the data plot style templates within the layer.

You can also use this command option to add multiple datasets to the layer. One way to do this is to list the datasets after the -i option. For example, the following command adds data1_b and data1_c to the layer:

layer -i data1_b data1_c;

You can also specify a string variable that holds the names of the datasets you want to add. Thus, the following script performs the same action as the previous example:

%Z = "data1_b data1_c";

layer -i %Z;

-i# dataset

Replot into the graph type specified by #. Note that there is no space between the i and #. See the worksheet command for a listing of graph type numbers. If dataset is omitted, this command removes all the data plot style templates within the layer.

-ic sourceGraph sourceLayerNumber

-ie

To find out which style holders are in use, use list o;. This command returns three attributes of the objects (including data plot style holders) in the active graph window layer: index type* name

Type = 7 indicates a data plot style holder. The asterisk indicates the style holder is in use.

For information on data plot style holders, see the Origin Help file.

-iu

See the -ie option for more information.

For information on data plot style holders, see the Origin Help file.

  • Extract multiple data plots in a single layer into a multiple panel (layer) graph in which each data plot displays in its own layer.

  • Open the Plot Details or Layer n dialog box, depending upon the value specified.

  • Open the Layer Clipping Margins dialog box for the active layer.

  • Add a nonlinked layer to the active graph window displaying a bottom X and left Y axis.

  • Add a linked layer to the active graph window displaying a top X and right Y axis.

  • Add a linked layer to the active graph window displaying a top X axis.

  • Add a linked layer to the active graph window displaying a right Y axis.

  • Execute (operate) the specified script for the specified layer.

  • Apply the X or Y scale of the active layer to all other layers in the active window.

  • Reverse the order of the data plots in the active layer.

  • Update Origin when you change sheet activity in an Excel workbook.

  • Select the active layer in the active window.

  • Clear the effect of the -t nrow option (see next option).

  • Set the worksheet row that provides the axis title and the legend text for the data plot.

  • Change the units in which layer size and position are measured.

  • When no range is specified, plot the entire worksheet wks into the active layer. To select a worksheet range, specify the beginning and ending column and row numbers.

  • Get the layer frame dimensions into variables v1 (left), v2 (top), v3 (width), and v4 (height).

  • Query the waterfall graph in the active graph window and assign the values of the X offset and Y offset to variables X and Y.

  • Disable the X and Y offsets in the waterfall graph in the active graph window.

  • Set the X and Y offset to produce a waterfall effect for all the data plotted in the layer.

-j

-k value

If value = p, open the Plot Details dialog box for the active layer. If value = c, open the Layer n dialog box for the active layer. If value = d, open the Link Axes Scales tab of the Plot Details dialog box for the active layer. (Note: The active layer must be a linked layer to open this dialog box.)

-m

-n

-n Both

-n X

-n Y

-o layerNumber {script}

The layerNumber layer is temporarily set internally as the active layer, the script is executed, then the original active layer is restored.

-p axisScale

Set axisScale to X to apply the X scale, or to Y to apply the Y scale.

-r

-s

Execute after changing the active sheet, or after adding a new sheet to the workbook.

-s n

n specifies the layer number.

You can also set (and get) the active layer number using the page.active object property.

-t

-t nrow

The X cell value provides the X axis title. The Y cell value provides the legend text.

-u unit#

Unit# specifies the type of units in the order listed on the Size/Speed tab of the layer's Plot Details dialog box. 1 = % of page, 2 = inch, 3 = centimeters, etc.

-w wks [c1 r1 c2 r2][GraphType]

If c1 and c2 = 0, plot all columns. If r1 and r2 = 0, plot all rows. The graphType value determines graph type: line, symbol, scatter, etc. If a “?” is used, the graph type saved with the layer is used. See the graph type listing under the worksheet command.

-x

The values are in the current unit for the layer. To set the layer frame size, use the layer command without an option switch.

-y ?

The X and Y offset amount is expressed as a percentage.

-y !

-y x, y

The x and y offset amount is expressed as a percentage (you must include the comma between the x and y offset).

Note: To assign these offset values to variables X and Y, execute the layer -y ? command after setting the offsets.

  • The following script changes the units to pixels.

lay -u 5;

  • The next script exchanges the X and Y axes.

lay -b x 1;

  • The next script sets xOffset and yOffset to 45. It retains the current values for width and height.

lay 0 0 45 45;

  • Given three layers, the following script sizes each layer to 20% of the page width and 80% of the page height. It arranges the layers 10% from the top of the page, starting at 8% in from the left, and separated by 12% of the full page.

width = 20;

height = 80;

for (ii = 1; ii <= 3; ii++)

{

layer -s ii;

layer width height (8+(ii-1)*(width+12)) 10;

};

  • The following script creates a new graph window, adds data to the layer, and then creates a second graph window and adds data to that layer.

%A = data1; //assign worksheet name to %A

loop (ii, 2, 3)

{

win -t plot line; //open graph from line template

%B = data1!wks.col$(ii).name$; //assign column name to %B

layer -i %A_%B; //add data to layer

layer -a; //rescale axes to show all data

}

Layer

Performs various operations on existing layers. The layer command operates on the active layer, except where specified.

Usage:

layer [option] <width height xOffset yOffset>

Options a through i (ordered alphabetically):

Options j through z (ordered alphabetically):

Examples:


Legend

Creates a legend for the active graph window or updates the current legend if one exists.

Usage:

legend

This command takes no options and no arguments.


Limit

  • Find limiting values for dataset (number of points, min Y, index of min Y, etc.).

  • From the provided beginning beg, end, and number of points num values, calculate the appropriate inc value and adjust beg and end.

no option

Each value is placed into limit object properties. Use the limit command before checking the property values. The limit object properties are set and read in the same way as numeric variables. For example:

The limit object properties are as follows:

Note: If you execute the limit command while a graph with Speed Mode ON is active (on the Size/Speed tab of the layer's Plot Details dialog box), then the results will only include the actual displayed values.

limit.xmax=

returns:

limit.xmax = 120;

limit.size -- Total size (number of points) for dataset.

limit.ymin -- Minimum Y value.

limit.imin -- Corresponding index for minimum Y value.

limit.ymax -- Maximum Y value.

limit.imax -- Corresponding index for maximum Y value.

limit.xmin -- Minimum X value.

limit.xmax -- Maximum X value.

-r beg end num inc

This is the same mechanism used in automatic increment calculation and rescaling.

  • The following script finds the limits for data1_b from index number 10 to index number 30, inclusive. The properties contain information for this range only.

limit data1_b -b 10 -e 30;

  • The next script calculates a step value of 2 and sets start to -3 and stop to 16.

start = -2.786;

stop = 15.901;

ticks = 9;

step = 0;

limit -r start stop ticks step;

  • The last script returns the greatest value in the Data1_C dataset to the Script window.

limit Data1_C;

limit.ymax =;

Limit

Usage:

limit [option] dataset [range]

Options (ordered alphabetically):

Examples:


List

  • List the Origin C functions that can be called from LabTalk.

  • List all macros.

  • List all objects and labels in the current layer.

  • List all datasets (series).

  • List all variables.

f, fs, fv, fn, fo

Use this command as follows:

list f; // list all Origin C functions that can be called from LabTalk

list fs; // only those returning string

list fv; // only those returning vector

list fn; // only those returning numeric

list fo; // only those returning void

To show the function prototype in the listing, use 'cf' in place of 'f'. For example: list cf, cfs, cfv, cfn, cfo;

Note: The @OC system variable affects this listing. For more information on this command option and the @OC system variable, see Calling Origin C Functions from LabTalk.

macro

object

This command returns three attributes of the objects in the active graph window layer:

  • index

  • type*

  • name

Type = 7 indicates the object is a data plot style holder.

*The asterisk indicates the style holder is in use.

For information on data plot style holders, see the Origin Help file.

series

variable

  • The following script returns the names of all existing datasets to the Script window.

list s;

List

Lists various objects in the current project by typing the names of the objects to the Script window.

Usage:

list argument

The list depends on the argument supplied. You need only supply the first letter of the argument. Do not include a dash.

Note that there is also a list() function which finds the index number of a specified value in a dataset.

Arguments (ordered alphabetically):

Examples:


Loop

  • The following script:

loop (num, 1, 4) {type “$(num)”;};

Produces the following output to the Script window.

1

2

3

4

  • The next script prints the values of row index 20-35 in column 2 of the NewData worksheet in the form “Row 20 value is 547”.

loop (num, 20, 35)

{

data = %(NewData, 2, $(num));

type “Row $(num) value is $(data)”;

}

Loop

A simple increment loop structure.

Usage:

loop (variable, start, end) sentence;

loop (variable, start, end) {script}

Initializes variable with a value of start. It then compares variable with end. If it is greater, it ends the loop. Otherwise it executes script, then increments variable by one and tests if it is greater than end. If it is not, execute script and continue to loop. This is the equivalent of one of the most common for loops:

for (Variable = Start; Variable < End; Variable = Variable + 1) {script}

Single statement script arguments end with a semicolon. Multiple statement script arguments should be enclosed in braces {}. Each statement within the multiple statement script should end with a semicolon.

Note: If your script loops endlessly, you can interrupt the script by pressing ESC.

Examples:


LR

lr.property =

The value of the property is returned in the Script window.

The properties return a null value until the lr command has been executed. The lr object has the following properties:

lr.b -- Slope.

lr.a -- Intercept.

lr.sdB -- Standard deviation of slope.

lr.sdA -- Standard deviation of intercept.

lr.sd -- Standard deviation of the fit.

lr.r -- Correlation coefficient.

lr.n -- Number of points used in the fitting.

lr.chkLinearr -- Sets the amount of tolerance in the automatic determination of linear segments from the data. (See the -b and -e options.)

lr.maxLRange -- Specifies the percentage of the entire data range to be examined by the find linear segment routine. (See the -b and -e options.)

  • Perform a linear regression on dataset.

  • Perform a linear regression on the beginning or ending linear region of dataset.

  • Perform a linear regression on dataset but do not create a data plot of the fit line.

  • Use the axis scale function to transform the data before performing the linear regression.

  • Perform a linear regression on dataset, using the dataset xdataset to supply the X values (independent variables).

no option

-b dataset, -e dataset

Note: When you use the lr -b dataset or lr -e dataset commands to perform a linear regression on the beginning (b) or ending (e) linear region of dataset, the dataset is automatically searched for linearity, as determined by the following parameters that can be modified in the ORGSYS.CNF file:

lr.maxLRange: The percentage of the entire data range to perform a linear regression on. For example, when lr.maxLRange = 40 (default) and dataset has 20 points, lr -b dataset performs a linear regression on the first 8 points in dataset, if these points meet the requirements of the lr.chkLinearR parameter. Thus, if the fourth point is outside the tolerance set by lr.chkLinearR, then the lr -b dataset command would only perform a linear regression on the first three points in dataset.

lr.chkLinearR: Sets the amount of tolerance in the automatic determination of linear segments.

-n dataset [range]

-s dataset [range]

This allows you to do an apparent linear fit on data that is plotted against a nonlinear scale, for example, a Log 10 scale.

-x xdataset dataset [range]

  • The following script performs a linear fit of dataset Data1_B beginning at the first data point and continuing until the end of the linear region. It types the resulting slope and intercept to the Script window.

lr Data1_B;

type “Slope is $(lr.b)”;

type “Intercept is $(lr.a)”;

LR

This command performs a linear regression on dataset and its dependent X dataset.

Usage:

lr [option] dataset [range]

If the data is plotted in an active graph window, lr adds the data plot of the fitted curve to the graph window. If the Data Selector tool was used to set the range, then the fit is performed over the selected range and the resulting curve displayed for the full range.

LR Object Properties:

The fitting results are stored in lr object properties. To read the value of these properties, use the following syntax:

Options (ordered alphabetically):

Examples:


Mark

  • Delete elements from dataset.

  • Turn the dataset elements (cells) into missing values.

  • After a range of data has been masked in the graph using mark -w1, toggle the mask off and on for a range of dataset.

  • Swap masked and unmasked points in dataset.

  • Update all graphs with masked data.

  • Remove the mask from a selected range either in the worksheet or graph.

  • Mask a selected range either in the worksheet or graph.

  • Create an associated X dataset called dataset_X, which contains whatever X values are associated with the current worksheet.

-d dataset [range]

If dataset is in a worksheet, this command deletes the specified rows from the worksheet.

-m dataset [range]

-st dataset -b firstPoint -e endPoint

For example:

mark -st %C -b 1 -e 10;

-sw dataset

For example:

mark -sw %C;

-u

Use this command after changing one of the global mask properties with the following system variables:

@MC Mask color. Follows the colors in the color palette: 1 = black, 2 = red, 3 = green, 4 = blue, etc.

@MM Enable or disable mask. 0 = enable (masked points are not included in analysis). 1 = disable (masked points are included in analysis).

@MP Show or hide masked data points in graph. 0 = show. 1 = hide.

-wd

-w1

Masked data is excluded from analysis.

Note1: You must first specify the range using the worksheet -s c1 r1 c2 r2 command. For example:

Note2: To determine if a data point in a data plot is masked, use the following notation:

worksheet -s 1 2 1 4; //set range to rows 2 - 4 in column 1

mark -w1 Data1_A; //mask this range of data

datasetName<dataPointIndex> =

A return value of 0 indicates the point is not masked. 1 indicates the point is masked.

For example, to determine if the fourth data point in the data1_b data plot is masked, use:

ii = data1_b<4>;

ii =;

-x dataset [range]

  • The following script deletes row index 10 to row index 20 from the Data1 worksheet if Data1_B is a column in the Data1 worksheet. If the worksheet does not exist, only Data1_B’s elements are deleted.

mark -d Data1_B -b 10 -e 20;

Mark

Usage:

mark option dataset [range]

Options (ordered alphabetically):

Examples:


  • Open the Math on/between Dataset dialog box, with dataset1 selected as the Y1 dataset and dataset2 selected as the Y dataset.

  • Select an operator to display in the 'operator' text box of the Math on/between Dataset dialog box.

no option dataset1 dataset2 [dataset3]

If dataset3 is specified, it is selected as Y2. Otherwise, the Y2 dataset is blank.

-o operator [dataset1 dataset2 dataset3]

The possible operators are: +, -, *, /, and ^. Dataset1 is selected as the Y1 dataset and dataset2 is selected as the Y dataset. If dataset3 is specified, it is selected as Y2. Otherwise, the Y2 dataset is blank.

Math

Usage:

math [option] dataset1 dataset2

Options (ordered alphabetically):

Related Topics:

See the Origin Help file for information pertaining to math operations on datasets and the Math on/between Dataset dialog box.


Matrix

  • Rotate the matrix 90 degrees.

  • Flip the matrix horizontally.

  • Flip the matrix vertically.

  • Open the Set Matrix Values dialog box.

  • Open the Matrix Properties dialog box.

  • Open the Matrix Dimensions dialog box.

  • Convert matrix image to data with conformation prompt.

  • Check and convert view to Image Mode.

  • Convert matrix image to data without prompting.

  • Get the specified parameter, as described with the Set parameter to specified range of values option.

  • Set parameter to the specified range of values.

  • Transpose the active matrix.

  • Fill the matrix with values from the expression.

-c r

Imported Images must be converted to gray-scale. See the Convert matrix image to data without prompting option.

-c h

Imported images must be converted to gray-scale. See the Convert matrix image to data without prompting option.

-c v

Imported images must be converted to gray-scale. See the Convert matrix image to data without prompting option.

-e

-e d

-e m

-id

-ii

-in

-pg parameter varName1 varName2

-ps parameter value1 value2

Possible values for parameter, value1, and value2 are shown below. Only the first parameter letter is required.

DIM nCol nRow -- Sets the matrix column by row size.

X xMin xMax -- Sets the matrix X mapping range.

Y yMin yMax -- Sets the matrix Y mapping range.

-t

-v expression

The current XY mapping relation is used. You can use X and Y in the expression, as well as i and j (the row and column number value for any particular cell).

  • The following script puts the X minimum and X maximum values into xmin and xmax.

matrix -pg X xmin xmax;

  • The next script fills the matrix with the given expression.

matrix -v sin(x)+cos(y);

Matrix

Get values from, or set values for, a matrix window.

Usage:

matrix option arguments

Options (ordered alphabetically):

Examples:


Menu

To select the active menu bar, use the -g, -w, -p, or -m command options (see Options below).

Note: The window designations can be combined, so that:

menu -gp;

makes all subsequent menu modifications apply both to graph and layout page windows.

All subsequent commands operate on the active menu.

To select the active menu, do one of the following:

  • Reference the current position in the menu bar (see the “When No Option is Given” section).

  • Use tags. For example:

menu ?Ed; //makes the Edit menu active.

Only built-in menus can be referenced this way (for the user-defined menus, reference the position). Tags must have two characters. The following tags are used:

Menu | Tag
File | Fi
Edit | Ed
View | Vi
Plot | Pl
Data | Da
Analysis | An
Format | Fo
Layout | La
Matrix | Ma
Image | Im
Window | Wi
Statistics | St
Tools | To
Column | Co
Help | He

  • When no option is given, the menu command has four possible actions:

  • Delete the menu command at position position in the active menu (in the active menu bar).

  • Execute the menu command with the specified ID by running its script immediately.

  • Select the graph window menu bar for menu manipulation.

  • Insert into the active menu at position position, a new menu command called menuName.

  • Insert into the active menu at position position, a new menu command called menuName with the menu ID ID.

  • Construct a submenu at the end of the active menu.

  • Select the matrix window menu bar for menu manipulation.

  • Select the layout page window menu bar for menu manipulation.

  • Execute the menu command with the specified ID by queuing its script.

  • Remove the entire menu located at position position.

  • Select the menu bar when no window is active for menu manipulation.

  • Select the worksheet menu bar for menu manipulation.

  • If argumentList consists of only a number, the menu in the numbered location is set as the active menu. You must set a menu as active before it can be edited. Menus are numbered sequentially, where 1 = File, 2 = Edit, etc. A submenu can also be selected, such that 1.1 is the submenu from the first menu command of the File menu.

Example 1:

menu 2;

Sets as active the menu at position number 2 in the active menu bar.

Example 2:

menu 1.1;

Sets as active the submenu at position 1 of menu 1 in the active menu bar.

  • If argumentList is a number followed by a name, the named menu is created and inserted into the given position in the active menu bar, and set as the active menu.

When you add a new menu, Origin assigns an ID number, and stores the ID in the variable i. The ID can be assigned to another variable for later use. To find the value of i, type the following in the Script window: i = (ENTER)

Example:

menu 2 (My Menu);

Inserts My Menu into position 2 in the active menu bar. The “( )” ensure that My Menu is treated as a single word.

  • If argumentList does not start with a number, then it is taken to be the name of a new menu command, which is appended to the active menu (in the active menu bar). The new menu command executes the script script.

Example:

menu (Add Text) {label -e NewText;}

Adds a new text label to the active window.

  • If no argumentList is given, a menu command separator is appended to the active menu (in the active menu bar).

Example:

menu 6; menu;

Appends a menu command separator to menu 6.

-d position

-e ID

See the above heading Finding a Menu Command ID.

-g

-i position menuName {script}

MenuName is associated with the script script.

-i position menuName ID

This command option is used to create a menu command with a specific ID to link to a tool.

-l [-i position] (menuName) {script} ]

The menu -l command must be issued twice, first to name and initialize the submenu, and the second time to construct the submenu that has been described.

This protocol is:

menu -l (New Submenu); // begin submenu

menu (submenu 1) {type "this is submenu 1"};

menu (submenu 2) {type "sub menu 2"};

menu -l; // terminate submenu

This script creates a submenu named New Submenu. This submenu contains two menu commands.

Submenus can also be constructed at specific positions in the active menu if the -i position option is added between -l and menuName.

-m

-p

-q ID

See the above heading Finding a Menu Command ID.

-r position

-v

-w

  • Adding Menus and Submenus (without the -l option):

  • Adding Menus and Submenus (with the -l option):

  • Removing Menus:

  • Making Menus and Submenus Active:

  • Adding Menu Commands:

  • Removing Menu Commands:

  • Adding Menu Command Separators:

  • The following script inserts and makes active a NewDD menu at the third position in the active menu bar.

menu 3 (NewDD);

  • The next script inserts and makes active a Before Edit menu before the Edit menu in the active menu bar.

menu ?Ed (Before Edit);

  • The next script inserts a SubMenu submenu at the second position in the fourth menu and makes it active.

menu 4.2 (SubMenu);

  • The following script inserts a BeforeOpen submenu before the Open menu command in the active menu. It then adds a menu command to the BeforeOpen submenu.

menu ?Fi;

menu -l -i 2 (BeforeOpen);

menu (MyFiles) {type -b "MyFiles";};

menu -l;

  • The following script removes the fourth menu from the active menu bar.

menu -r 4;

  • The next script removes the Format menu from the active menu bar.

menu -r ?Fo;

  • The following script sets the graph window menu bar active. It then makes the fourth menu from the left active.

menu -g;

menu 4;

  • The next script makes the View menu active (in the active menu bar).

menu ?Vi;

  • The next script makes the submenu at the first position in the File menu active. This command fails if there is no submenu at the first position in the File menu.

menu ?Fi.1;

Menu commands can only be added to the active menu. Therefore, make the desired menu active before adding menu commands.

  • The following script appends the menu command labeled EndEdit to the Edit menu (in the active menu bar).

menu ?Ed; // Makes Edit active

menu (EndEdit) {type -b "EndEdit";};

  • The next script inserts the menu command labeled BeforePaste before the Paste menu command in the active menu (in the active menu bar).

menu -i 4 (BeforePaste) {type -b "!!!";};

  • The next script inserts the MyItem menu command at the (currently) fifth position in the active menu (of the active menu bar).

menu -i 5 (MyItem) {type -b "My item text.";};

  • The following script inserts the Open Template menu command in the second position of the Graph menu in the graph menu bar.

menu -g;

menu 4;

menu -i 2 (Open Template) {win -t plot line;};

To set the ID you must execute the new menu command by selecting it from the menu bar. Then type in the Script window:

MyID = i (ENTER)

You can later execute the menu command by using:

menu -e myId;

  • The following script sets the graph window menu bar active. It then sets the sixth menu from the left in the graph window menu bar active, and deletes the second menu command in this menu.

menu -g;

menu 6;

menu -d 2;

  • The following script inserts a menu command separator in the third position in the active menu (of the active menu bar).

menu -i 3;

  • The next script adds a menu command separator to the end of the active menu (in the active menu bar).

menu;

Menu

Add, remove, and edit menus, submenus, and menu commands. For more information on menu manipulation, see the menu object.

Usage:

menu [option] <argumentList [{script}]>

The effects of the menu command may not be immediately apparent. Make a different window type active and then return to the original window to view the result.

Before using the window command, you must do the following:

  1. Select the active menu bar - either the graph, worksheet, layout page, or matrix window menu bar.

  2. Select the active menu (for example, the Edit menu).

Finding a Menu Command ID:

To find a menu command ID, do one of the following:

  • Press CTRL+SHIFT and select the menu command. The menu ID (and script) is typed to the Script window, but not executed.

  • Use the menu.lastID or the menu.lastExeID object properties.

Options (ordered alphabetically):

Examples:


NLSF

  • Assign a dataset to the fitter and open the Fitting Session dialog box.

  • Iterate the fitting routine # times.

  • Open the Fitting Session dialog box.

  • Select the fitting function specified by funcName.

  • Enter the fitting session and plot a trial fit curve for dataset.

  • Direct the fitting routine to display the fitting residuals in layer 2 of the active window.

  • Terminate the fitting session.

  • Update the fit curve according to the parameters in the dialog box.

  • Subtract the active fit curve from dataset.

  • Set parameters as fixed or variable during the fitting procedure.

  • Set parameter values.

no option dataset

- #

-e

-f funcName

FuncName must be included. The Fitting Session dialog box does not open.

-h dataset

This option does not display the Fitting Session dialog box. The option will not work unless you first select a fitting function.

-r

THIS OPTION IS NO LONGER SUPPORTED. Instead, use the nlsf.residuals(depVarName) object method.

-t

-u

-s dataset

-v value [init][inc]

A fixed parameter is held constant during the fitting, while a variable parameter varies. Set all parameters to value, where 0 = variable and 1 = fixed. Or start at parameter number init, and change each inc parameter thereafter.

-y value [init][inc]

Sets all parameters to value, unless you specify an initial parameter init, and an increment inc.

Instead, use the nlsf object methods and properties to control curve fitting.

The fitting information is stored in the following system variables. The equivalent nlsf object oriented properties are given in parentheses.

FitWtMode -- Weighting method used: 0 = weight, 1 = instrumental, and 2=statistical. This value is initialized when the fitting session begins. If there are error bars plotted with the data, the weight is set to instrumental, otherwise it is set to zero. (nlsf.wtype)

Pn -- The value of parameter n. (nlsf.Pn)

Pen -- The standard error of parameter n. (nlsf.En)

PVn -- Tells whether parameter n is fixed or allowed to vary during fitting: 1 = vary, 0 = fixed. (You can fix a parameter using linear constraints.) (nlsf.Vn)

PUn -- The upper confidence limit of parameter n. Use nlsf.paraconf() to make it first, otherwise you get zero values.

Pln -- The lower confidence limit of parameter n. Use nlsf.paraconf() to make it first, otherwise you get zero values.

  • The following script selects the Guassian fitting function.

nlsf -f gauss;

  • The next script sets parameter 2 to 100.

P2 = 100;

  • The next script assigns the value of parameter 3 to the variable ttt.

ttt = P3;

  • The next script assigns the error value of parameter 7 to the variable sss.

sss = PE7;

  • The last script fixes parameter 3 so that it is not modified during fitting.

PV3 = 0;

NLSF

This command controls a number of functions associated with nonlinear least squares curve fitting and the fitting session.

Usage:

nlsf [option] dataset

Note: The nlsf object methods and properties provide greater control over curve fitting and should be used in place of this command.

Options (ordered alphabetically):

System Variables and Object Properties (Note: We recommend that you avoid using these variables):

Examples:


Open

  • Append FileName to the currently active worksheet as columns.

  • Append FileName to the currently active worksheet as rows.

  • Open the specified fileName text file into the specified (optional) winName notes window.

  • Import the FileName file into the active graph window. Specify the plotting designations for the columns in the import file.

  • Import the given Thermo Galactic SPC data file into the active worksheet starting from the first empty column.

  • Import the given Thermo Galactic SPC data file into the active worksheet starting from the first empty column.

  • Import the given Thermo Galactic SPC data file into the active worksheet as new data, replacing any existing data.

  • Import the given ASCII file into the active window.

  • Import the given file into the active worksheet by using the appropriate import filter.

  • Import the given file into the active worksheet by using the appropriate import filter.

-a filename

-ar filename

-n fileName [winName]

-p plottingDesignations fileName

Only X and Y (plotting designations) can be specified. If the import file is ordered as X and any number of Ys, set plottingDesignations to XY. Otherwise, explicitly specify the repeat pattern. For example plottingDesignations = XYYYXYYY.

-s filename

or

-spc filename

(For information about files dropped into Origin, see the doc object.)

-se filename

Do not read in the x column if x values are evenly spaced (For information about files dropped into Origin, see the doc object.)

-sn filename

(For information about files dropped into Origin, see the doc object.)

-w filename

-wf filename

The file type is determined automatically. The type of file can be WKS, WK1, WK3, WKQ, or DIF.

-we ext filename

The type of file is specified by ext, which can be one of the following: XLS4, XLS3, XLS2, DBF4, DBF3PLUS, DBF3, or DBF2. In each case, the (file) numbers refer to the version of the software that created the file.

  • The following script opens the Open dialog box to import Lotus or DIF files into the worksheet.

getfile *.WKS *.WK1 *.WK3 *.DIF *.WKQ;

open -wf %B%A;

  • The last script opens the Open dialog box to import an Excel file. Since these formats require special ext values in the open command options, the getnum command is used to get the version of the Excel file.

getfile *.XLS;

ver = 4;

getnum (Version {2 to 4}) ver (Excel Import);

open -we XLS$(ver) %B%A;

Open

Open or import a data file.

open option filename

<*If there are spaces in fileName, enclose fileName in quotation marks " ".

Options (ordered alphabetically):

Examples:


Page

  • Open the Plot Details dialog box with the page tabs active.

  • Open the Page Color dialog box.

  • Adjust the page dimensions to fit the current window aspect ratio.

  • Convert a multiple layer graph into multiple graph windows in which each layer displays in its own graph window.

  • Read the specified template file and add all of its layers to the page in the active graph window.

  • Set the page to portrait, landscape, or rotate the page.

  • These two options set or get page related parameters.

  • Select the specified object on the page.

  • Select the specified object on the page, leaving all current object selections selected.

  • Replace the page in the active graph window with the template templateName, without closing the active graph window.

  • Set the page to the specified view mode.

  • Switch between the workbook view and the hidden Origin worksheet layer view for the active Excel workbook in Origin.

  • Plot each column in the worksheet to separate graph layers.

no option

-c

-f

-j

-l templateName

-o type

    • portrait (type = p)

    • landscape (type = l)

    • rotate the page (type = r)

-pg type varName

-ps type value

Type can be one of the following:

C -- Closing flags: 0 = normal, 1 = no close, and 2 = no warning.

D -- Document closing method. When value = 1, set the active window as a system window which remains open when the project is closed. In addition, this window is not saved with the project. For related information on the page.syswin object property, see the page object.

H -- Height of the page in dots. For a graph window, this value is the number of dots from the top to the bottom of the page. For a worksheet window, this number is the vertical screen resolution in pixels.

P -- Maximum show points: 0 = show all data points.

S -- Search flags:

bit (n) | value (2^n) | disable search on
0 | 1 | axis
1 | 2 | data plot
2 | 4 | label
3 | 8 | graphical object
4 | 16 | layer frame
5 | 32 | tick labels

W -- Width of the page in dots. For a graph window, this value is the number of dots across the page. For a worksheet window, this number is the horizontal screen resolution in pixels.

-s object

If no object is given, this command clears the current selection.

-sa object

-t templateName

All current layers are deleted. Similar to the document -t and window -t commands (document -t lets you specify a complete path).

-v n

0 = Print view, 1 = Page View, 2 = Window View, and 3 = Draft View.

-vx

-w wksName c1 r1 c2 r2 [ID]

Same as the layer -w command but put each dataset (column) into separate layers in the page. When the last layer is passed, cycles back to the first layer.

Note: An active graph window with the correct number of layers must already exist.

  • The following script disables the search on axes and labels for the page.

page -ps search 1;

Note: You can also use: page.noclick = 5;

  • The next script doubles the maximum display points for the page.

page -pg p npts; page -ps p (npts*2);

Note: You can also use: page.maxpts *= 2;

  • The next script adds the layer from the scatter template to the page.

page -l Scatter;

  • The last script makes graph1 the active window. It saves graph1 as a system window which remains open when the project is closed. However, graph1 will not be saved with the project.

win -a graph1;

page -ps d 1;

Page

Perform various operations on the current page.

Usage:

page [option]

Options (ordered alphabetically):

Examples:


Plot

  • Append a row of numbers c1, c2, etc. starting at the given column position nCol (1, 2, 3..) to the specified wksName worksheet.

  • Force an update of the active window (clear screen).

  • Update the active layer.

  • Append a new point to dataset at the XY position specified.

  • Redraw the page without redrawing any objects off the page.

  • Draw the graph using the full screen (active graph windows only).

  • Remove any update message for the active window.

-a wksName nCol $(c1) $(c2) $(c3) ...

Note that you must enclose numeric variable arguments with $(). This command is especially useful in that the data is added to the graph without causing a complete redraw. Therefore, you can use DDE as a data acquisition tool. This command activates all the real-time related procedures.

For realtime numeric plotting, use the -an option.

-an wksName nCol c1 c2 c3 ...

To facilitate making scripts backward compatible, plot -an supports numeric interpretation without using the $() required by plot -a.

-c

-l

If there is a window update message in the queue for this window, remove it.

-n dataset xvalue yvalue

-p

-s

This command can only be used with active graph windows. The command draws the page using the full screen. Terminate this mode by double-clicking.

-v

  • The following script assigns numeric values to two variables and a text value to a string variable, and then appends the variable values and the specified text to columns in the Data1 worksheet.

v1 = 8;

v2 = -13;

%A = sample text;

plot -a Data1 1 $(v1) ($(v2)) text (more text) (%A);

The Data1 worksheet appears as follows:

Plot

Use this command to control window updating of dataset.

plot [option] dataset

To use this command, you must have previously used the layer command to plot dataset into this layer.

Options (ordered alphabetically):

Examples:


Print

  • Print the page in the active window.

  • Open the Print dialog box before printing the page.

  • Open the Page Setup dialog box.

no option

To print a named window, use the window command:

win -o windowName print;

-a

-s

  • The following script opens the Print dialog box for the active window.

print -a;

  • The next script prompts a user for multiple projects and prints all the graphs in all the selected projects.

getfile -m *.org; // opens multifile dialog

loop (i, 1, count)

{ // number of files is in count

getfile -get I; // get ith file into %A

doc -open %A; // opens project

doc -e P

{

print;

// pause 2 min to avoid overloading print queue

sec -pause 120;

};

};

Print

Usage:

print [option]

Options (ordered alphabetically):

Examples:


Queue

Delay the execution of the script.

Usage:

queue {script}

Place the script at the end of the current window message queue. Execution begins when the current window finishes redrawing.


Repeat

Execute the script the number of times specified by numberTimes, or until an error occurs, or until the break command is executed.

Usage:

repeat numberTimes {script}

Examples:


Return

  • The following script defines a macro that takes an argument and types OK if the argument is greater than 2. Otherwise, it types Not OK.

def test {

if (%1 > 2) {

type “OK”;

return;

}

type "Not OK";

}

In this case, test 1.876; would respond with Not OK.

  • If an object named Test contains the following script:

if (var1 + 3 * var3 > 1) return 0;

else return 1;

A script that accesses the object can use the return value as follows:

if (test.run()==0)

type “Result OK”;

else type “Result too small”;

Return

Immediately exit from a script or a macro without generating any error.

Usage:

return [value]

This command is particularly useful in an object script or in a script file script. The optional return value can only be used when returning from run.section(), run.file(), or object .run() calls. Macros do not return values. Also, only integer return values are supported.

Examples:


Run

if (condition)

{

// True condition statements

}

else

{

// False condition statements

}

  • Run the script file scriptfileName.

  • Execute the following text as if it were typed into the Run dialog box (from the Windows Start menu).

  • Execute the scriptfile after waiting for automatic update to complete.

  • Execute the following Help File.

no option scriptfileName

-e text

Uses the full path specification. If no path is specified, Origin uses the software directory instead of the current directory.

-p au scriptfile

For more information on "automatic update" see the Origin help file.

-sc HelpFileName

  • The following script opens Notepad and loads a file named README.TXT.

run -e notepad readme.txt;

  • The next script runs the specified script file.

run c:\c\test\mytest.ogs;

Run

Execute a script file or run a Windows program.

Usage:

run [option] argument

Note: The run command executes on a line-by-line basis. Multi-line structures must include the line continuation character "{" as in the following example:

The run object provides greater flexibility for script file execution.

Options (ordered alphabetically):

Examples:


Save

  • Save the current project using the specified path and filename.

  • Save the graph window as a bitmap file with the specified dimensions.

  • Save the project as fileName.

  • Save the project as version 2.8 together with the comments (if you are using an Origin dialog box).

  • Save the active worksheet, graph, or matrix window to a file.

  • Save the winName notes window to a file.

  • Save windowName into a graph or worksheet template.

  • Save a graph window to a template with an attached EMF of the graph.

  • Export the worksheet wksName to an ASCII file.

  • Export the workhsheet wksName to an ASCII file using the wks.export.cntrl

  • Save all system variables into fileName.

no option

You can specify the path and the file name after the command. For example:

save c:\mydir\myfilename;

Note: This command option should not be used in the Label Control dialog box of an object, as the object will be disabled after closing the current Origin session.

-bs PlotName FileName Width Height [B]

If B is included, save as a black-and-white bitmap.

-di fileName

If you are using an Origin dialog box, save the comments from the Save As dialog box with the project.

-di2 fileName

-i fileName

Name the file fileName. Include the extension with the fileName: OGW for worksheet, OGG for graph, and OGM for matrix windows. You can include the full path with fileName. Otherwise, the file is saved to the software directory.

-n winName fileName

Name the file fileName. Include the TXT extension with the fileName. You can include the full path with fileName. Otherwise, the file is saved to the software directory.

-t windowName fileName

FileName must be a full path description. In general, you should save your template to the Origin directory.

-tm windowName fileName

This EMF will then display in the graph template library.

-w wksName fileName

FileName must be a full path description.

-wh wksName fileName

Same as the -w option except this option uses the wks.export.cntrl object property to determine if headers are exported. Additionally, this option allows for a specific data range for export, using the wks.export.c1, etc. object properties.

-v fileName

  • The following script exports the worksheet into an ASCII file in the software directory.

save -w data1 %Ydata1.dat;

Save

Save the current project, window or template to file.

Usage:

save [option]

Options (ordered alphabetically):

Examples:


Second

  • Get the current time in seconds from Windows startup or the last time the second -i (Reset timer to 0) command was performed.

  • Get the elapsed time from the last time the command was issued.

  • Reset the timer to zero.

  • Pause for the specified number of seconds; other processes continue to execute.

  • Pause for the specified number of seconds; other processes are suspended.

no option

-e [variable]

When no variable is given, v1 is used by default.

-i

-p sec

The current script is suspended and then continued after the time elapses. During this period, all other processes continue to execute.

-w sec

Similar to the -p option but does not allow other processes to run.

  • The following script measures script execution time:

def HowLong {

sec; //get current system time

%1;

//execute script typed as argument to HowLong macro

sec -e time;

//get elapsed time since the sec command

type (Elapsed time = $(time) sec.);

//type time to Script window

}

If you now supply the HowLong macro with a script for an argument, for example:

HowLong {repeat 100 (i+=1)};

then script execution time is measured, and the result is printed to the Script window:

Elapsed time=0.384 sec.

Second

This command performs timer-related operations.

Usage:

second [option] [argument]

Options (ordered alphabetically):

Examples:


Selection

  • Align objects according to the specified param(eter).

  • Index line and fill colors.

  • Increase (value) or decrease (-value) the font size of all selected text labels.

  • Get the selected object name into the %char string variable.

  • Adjust an arrow head.

  • Set object drawing order.

  • Group the selected objects.

  • Ungroup the selected object.

  • Snap the orientation of a line or arrow to the horizontal or vertical.

-a param

t = top, b = bottom, l = left, r = right, c = center horizontally, v = center vertically, w = same width, h = same height, and s = same style.

-c param

Cycle the param colors: l = line and f = fill.

-f s value

For example, if value = 4, increase the font size of all selected text labels by a value of four. Thus, if the original font size was 18, the font size will increase to 22.

-g char

-h param val

param = angle or param = length. Val is the amount to adjust the arrow head angle or length. Positive values increase the angle or length. Negative values decrease the angle or length. The default step value used by the Object Edit tool is 5.

-o order

Possible values for order are: front, back, data 0 (in front of data plots), and data 1 (behind data plots). This option determines which objects are drawn on top of others. For RTM objects, this also determines the processing order for the objects.

-rg

-ru

The selected object must be a grouped object.

-t direction

direction = vertical or direction = horizontal.

  • The following script draws the object(s) in front of the data.

select -o data 0;

  • The next script aligns the center of the objects in a horizontal line.

select -a center;

  • The next script gets the selected object’s name into %A.

select -g A;

  • The next script snaps the selected line(s) to a vertical orientation.

select -t v;

  • The last script decreases the angle of the selected arrowhead by 10 units.

select -h angle -10;

Selection

Object selection management. This command is used in the Object Edit toolbar.

Usage:

select [option] value

A selection of one or more objects must exist, otherwise this command fails.

Options (ordered alphabetically):

Examples:


Set

  • Open the Plot Details dialog box for name.

  • Set the named dataset to be used for animation.

  • Do not save the dataset with the project.

  • Set the beginning of the display range (value equals first index number).

  • Temporarily set the beginning of the range of a dataset to the index given by value.

  • Set the plot line color and symbol edge color following the color palette:

  • Set the fill color (for fill area graphs) following the color palette:

  • Set the plot line color following the color palette:

  • Set the color for level n in a color mapped data plot following the color palette:

  • Set the plot symbol edge color following the color palette:

  • Set the plot symbol fill color following the color palette:

  • Set the Z level for level n in a color mapped data plot.

  • Set the line style.

  • Set the dataset as categorical.

  • Set the end of the worksheet display range.

  • Reset the data plot to the full range.

  • Set the end of the worksheet display range. When value = 0, set all data to missing values.

  • Set the number of rows available on the named worksheet.

  • Temporarily set the end of the range of a dataset to the index given by value.

  • Set the end of the worksheet display range. When value = 0, set all data to zero.

  • Set the corresponding X value for the first data point.

  • Set the function to plot from xvalue.

  • Set the function to plot to xvalue.

  • Set the lower limit of the histogram bin data.

  • Set the upper limit of the histogram bin data.

  • Set the histogram bin size.

  • Set the X increment for the dataset.

  • Set the internal data type for the name dataset or matrix to the value dataTypeValue.

no option

-a

The data plot automatically removes its own trace when redrawn without generating an update message.

-at value

When name is a dataset and value = 1, the dataset is not saved with the project.

-b value

If name is a worksheet, the display range affects both the worksheet and the data plots of all datasets in the worksheet. If name is a dataset, only the data plot display range is affected.

-bs value

This command is used with datasets to allow functions (such as sum()) to work on a subset of a dataset. Its temporary effect switches off with any window refresh.

-c color#

1 = black, 2 = red, 3 = green, 4 = blue, etc.

To map the symbol edge or line color to a dataset, use:

set DatasetName -c value;

where value = 101 + number-of-columns-to-the-right.

For example, to base the symbol edge color on a dataset located two columns to the right of the data plot's Y dataset in the worksheet, use value = 103 (Note: There is a limit of four columns to the right).

-cf color#

1 = black, 2 = red, 3 = green, 4 = blue, etc.

-cl color#

1=black, 2=red, 3=green, 4=blue, etc. If the data plot includes lines and symbols, this command will also control the symbol edge color.

-cmn

1 = black, 2 = red, 3 = green, 4 = blue, etc.

-cse color#

1 = black, 2 = red, 3 = green, 4 = blue, etc. If the data plot includes lines and symbols, this command will break the link (Automatic setting) between the symbol edge color and the line color.

-csf color#

1 = black, 2 = red, 3 = green, 4 = blue, etc.

-czn

-d style#

0 = solid, 1 = dash, etc. as in the line style list.

-dc value

0 = data is not categorical, 1 = data is categorical.

-e value

The data outside the end range is not changed, only hidden. See also -em and -ez.

-e -1

as in

set data1_b -e -1;

A graph window must be active.

-em value

Value equals last index number. When value = 0, all data are set to missing value. When value > 0, the data outside the end range is not changed, only hidden. See also -e and -ez.

-er value

This command is used with a worksheet only.

-es value

This command is used with datasets to allow functions (such as sum() ) to work on a subset of a dataset. It temporarily switches off with any window refresh.

-ez value

Value equals last index number. When value = 0, all data is set to zero. When value > 0, the data outside the end range is not changed, only hidden. See also -e and -em.

-f xvalue

Use with set -i to create an associated X dataset.

-f1 xvalue

-f2 xvalue

You must call -f2 to clear the Auto X Range check box. To select the Auto X Range check box, use:

set funcname -f2 (0/0);

-hbb value

-hbe value

-hbs value

-i xinc

You cannot use this option if there are already X values associated with the dataset.

-it dataTypeValue

For example, to set the internal data type of the active dataset held in %C to double, use:

set %C -it 0;

Possible values for dataTypeValue are the same as the values of the constants defined in the oc_const.h Origin C header file (located in the \OriginC\system subfolder):

FSI_DOUBLE = 0

FSI_REAL = 1

FSI_SHORT = 2

FSI_LONG = 3

FSI_CHAR = 4

FSI_TEXT = 5

FSI_MIXED = 6

FSI_BYTE = 7

FSI_USHORT = 8

FSI_ULONG = 9

  • If %C is a column in a worksheet, then only a Numeric column is supported and only types FSI_DOUBLE, FSI_REAL, FSI_SHORT, and FSI_LONG are supported.

  • If %C is a matrix, then all these constants are supported. However, FSI_TEXT and FSI_MIXED should be avoided for a matrix.

  • Set plot symbol shape (built-in symbols).

  • Set plot symbol shape (user-defined and ASCII).

  • Set plot data labels to bold.

  • Set plot symbol interior.

  • Set plot data labels to italic.

  • Set plot font for alphanumeric symbols (set DatasetName -k 12 or 13).

  • Set plot data label to underline.

  • Set plot line connection method.

  • Show/hide horizontal drop lines.

  • Set the horizontal drop line color.

  • Set the horizontal drop line style.

  • Set the horizontal drop line width.

  • Show/hide vertical drop lines.

  • Set the vertical drop line color.

  • Set the vertical drop line style.

  • Set the vertical drop line width.

  • Set the specified data plot as movable/not movable with the cursor.

  • Rename the dataset.

  • Plot the values in the name dataset as Y error bars for the plotted Ydataset.

  • Plot the values in the name dataset as Y (minus) error bars for the plotted Ydataset.

  • Plot the values in the name dataset as Y (plus) error bars for the plotted Ydataset.

  • Plot the values in the name dataset as Y error bars (relative) for the plotted Ydataset.

  • Plot the values in the name dataset as X error bars for the plotted Ydataset.

  • Plot the values in the name dataset as X (minus) error bars for the plotted Ydataset.

  • Plot the values in the name dataset as X plus (error) bars for the plotted Ydataset.

-k shape#

For graphs with symbols, 0 = no symbol, 1 = square, 2 = circle, 3 = up triangle, 4 = down triangle, 5 = diamond, 6 = cross (+), 7 = cross (x), 8 = star (*), 9 = bar (-), 10 = bar (|), 11 = number, 12 = LETTER, 13 = letter, 14 = right arrow, 15 = left triangle, 16 = right triangle, 17 = hexagon, 18 = star, 19 = pentagon, 20 = sphere. For any numeric values outside of this range (except 56 and 58), no symbol displays.

The numeric values of 56 and 58 display special symbol types: 56 = data markers and 58 = vertical lines that mark the X position of the data point.

To map the symbol shape to a dataset, use:

set DatasetName -k value;

where value = 100 + number-of-columns-to-the-right. For example, to base the symbol shape on a dataset located two columns to the right of the data plot's Y dataset in the worksheet, use value = 102. (Note: There is a limit of four columns to the right.)

For bar graphs, this option is used to set the color index.

-ka value#

User-defined bitmaps, value# = 0-24.

For ASCII character set, value# = 33-255.

-kb value

For graphs with data labels, display the data labels in bold font style. 1 = bold on, 0 = bold off.

-kf interior#

For graphs with symbols, set symbol interior: 1 = solid, 2 = open, 3 = dot center, 4 = hollow, 5 = + center, 6 = x center, 7 = - center, 8 = | center, 9 = half up, 10 = half right, 11 = half down, 12 = half left. For any numeric values outside of this range, no symbol displays.

To map the symbol interior to a dataset, use:

set DatasetName -kf value;

where value = 100 + number-of-columns-to-the-right. For example, to base the symbol interior on a dataset located two columns to the right of the data plot's Y dataset in the worksheet, use value = 102. (Note: There is a limit of four columns to the right.)

-ki value

For graphs with data labels, display the data labels in italic font style. 1 = italic on, 0 = italic off.

-kn font

For graphs with alphanumeric symbols (set DatasetName -k 12; or set DatasetName -k 13;), select the font. Use:

set DatasetName -kn font(FontName)

For example:

set data1_b -kn font(timesnewroman);

-ku value

For graphs with data labels, display the data labels with an underline. 1 = underline on, 0 = underline off.

-l connection#

Line connection method, numbered in order: 0 = scatter, 1 = line, 2 = segment, 3 = segment3, 8 = Bspline, 9 = spline, 11 = step horz, 12 = step vert, 13 = step center, and 15 = Bezier.

-lh value

1 = show drop lines, 0 = hide drop lines.

-lhc value

Follows the color palette: 1 = black, 2 = red, 3 = green, 4 = blue, etc.

-lhs value

0 = solid, 1 = dash, etc. as in the line style list.

-lhw value

500 = 1 point.

-lv value

1 = show drop lines, 0 = hide drop lines.

-lvc value

Follows the color palette: 1 = black, 2 = red, 3 = green, 4 = blue, etc.

-lvs value

0 = solid, 1 = dash, etc. as in the line style list.

-lvw value

500 = 1 point.

-m value

1 = movable, 0 = not movable (default).

-n name

-o YDataset

Name must be a plotted dataset. For example, if Data1_B and Data1_C are displayed as line data plots in the active graph window, the

set data1_c -o data1_b;

command displays data1_c as Y error bars for data1_b.

-om YDataset

Name must be a plotted dataset. For example, if Data1_B and Data1_C are displayed as line data plots in the active graph window, the

set data1_c -om data1_b;

command displays data1_c as Y (minus) error bars for data1_b.

-op YDataset

Name must be a plotted dataset. For example, if Data1_B and Data1_C are displayed as line data plots in the active graph window, the

set data1_c -op data1_b;

command displays data1_c as Y (plus) error bars for data1_b.

-or YDataset

Name must be a plotted dataset. For example, if Data1_B and Data1_C are displayed as line data plots in the active graph window, the

set data1_c -or data1_b;

command displays data1_c as Y (plus) error bars for data1_b.

-ox YDataset

Name must be a plotted dataset. For example, if Data1_B and Data1_C are displayed as line data plots in the active graph window, the

set data1_c -ox data1_b;

command displays data1_c as X error bars for data1_b.

-oxm YDataset

Name must be a plotted dataset. For example, if Data1_B and Data1_C are displayed as line data plots in the active graph window, the

set data1_c -oxm data1_b;

command displays data1_c as X minus error bars for data1_b.

-oxp YDataset

Name must be a plotted dataset. For example, if Data1_B and Data1_C are displayed as line data plots in the active graph window, the

set data1_c -oxm data1_b;

command displays data1_c as X plus error bars for data1_b.

  • Set plot bar or column border color.

  • Set plot bar or column border line style.

  • Set plot bar or column border line width.

  • Show/hide vertical drop lines.

  • Turn the fill area option on or off.

  • Set plot bar or column background color.

  • Set plot bar or column foreground pattern color.

  • Set plot bar or column fill pattern.

  • Control the Fill Area Under Curve setting.

  • Set plot bar or column fill pattern line width.

  • Show/hide the data plot.

  • Display every nth symbol in a line+symbol data plot.

  • Control the data plot rendering mode.

  • Set the text label font.

  • Set text label justification.

  • Set text label font size.

  • Set the Y offset for the plot data label.

  • Set the X offset for the plot data label.

  • Set (update) the current display range for name in the active layer to be true for name in all layers.

  • Update the Excel workbook when you set values in the associated Origin worksheet layer.

  • Update Origin when you type or paste data into an Excel workbook sheet.

  • Set the bar and column plot gap.

  • Set the bar and column plot border width (in points).

  • Set connecting line width.

  • Associate an X dataset with a Y dataset.

  • Set the dataset that is plotted in the current layer to be plotted (a) against row number or (b) the X start value and increment as specified using the -f and -i options (or through Format:Set Worksheet X).

  • Set data point symbol size.

-pbc color#

For data plots with bars or columns, set the border color of the bar or column: Follows the color palette: 1 = black, 2 = red, 3 = green, 4 = blue, etc.

-pbs style#

For data plots with bars or columns, set the border line style of the bar or column: 0 = solid, 1 = dash, etc. as in the line style list.

-pbw width

For data plots with bars or columns, set the border line width of the bar or column, with 500 = 1 point. Type your drop-down text here.

-pd value

1 = show drop lines, 0 = hide drop lines. (See also the -lh and -lv options.)

-pf value

1 = fill area on, 0 = fill area off.

-pfb color#

For data plots with bars or columns, set the background color of the bar or column following the color palette: 1 = black, 2 = red, 3 = green, 4 = blue, etc.

-pfc color#

For data plots with bars or columns, set the foreground pattern color of the bar or column following the color palette: 1 = black, 2 = red, 3 = green, 4 = blue, etc.

-pfp fillPattern#

For data plots with bars or columns, set the fill pattern of the bar or column following the pattern drop-down list: 0 = none, 1 = dense, 2 = medium, etc.

-pfv fillAreaSetting

1 = normal, 2 = inclusive broken by missing values, and 3 = exclusive broken by missing values.

-pfw width

For data plots with bars or columns, set the fill pattern line width, with 500 = 1 point.

-s value

1 = show, 0 = hide.

-skip n

The drawn line, on the other hand, goes through all points, up to the page.maxpts display limit.

-tb value

When value = 0, the data plot is rendered from metafile descriptions that are stored in memory. When value = 1, the data plot is rendered from an internal bitmap. For large data plots, the “bitmap mode” provides a faster redraw than the “metafile mode”. However, if you resize the graph, the data plot can appear “blocky” in the bitmap mode.

-tf font

Set the font, where font is the index number in the current font list. The font(fontName) function can be used to convert a text font name into the index number.

-tj just

Set the justification, with just = 0 for left, just = 1 for center.

-ts size

-tx yoffset

Yoffset is percent of the label text height.

-ty xoffset

Xoffset is percent of the label text height.

-u

-ue

-ui

-vg percentGap

-vw borderWidth

-w width

500 = 1 point.

-x value

Value must be a dataset name and serves as the X values for the dataset name. A graph window must be the active window. Value can refer to any dataset.

-yx

-z

For data plots with symbols, set the data point symbol size, in points, with 1 point = 1/72 inch. For data plots with error bars, this option sets the cap width of the error bars.

To map the symbol size to a dataset, use set DatasetName -z value, where value = 100 + number-of-columns-to-the-right. For example, to base the symbol size on a dataset located two columns to the right of the data plot's Y dataset in the worksheet, use value = 102. (Note: There is a limit of four columns to the right.)

  • The following script sets the beginning of the display range for dataset data1_b to 10.

set data1_b -b 10;

  • The next script sets the line width to two points.

set data1_b -w 1000;

  • The next script hides data1_b.

set data1_b -s 0;

  • The following script opens the Plot Details dialog box for data1_b.

set data1_b;

  • The next script sets the active scatter data plot to display row numbers as data point symbols.

set %C -k 11;

  • The next script adds an XY data plot (data2_b as Y, data1_a as X) to the active layer.

layer -i data2_b;

set data1_a -x data2_b;

rescale;

  • In the last example, open a new project and import the WIND.DAT file from the Origin \TUTORIAL folder. Select the Month column and then select Column:Move to Last. Set this column to a label column. Select the Power and Month column and select Plot:Scatter. Then run the following script to set the label data plot display attributes.

ii = font(Arial);

//use font function to find Arial index #

set Wind_Month -tr 90; //rotate 90 degrees

set Wind_Month -ty 50; //50% y offset

set Wind_Month -tj 0; //left justify

set Wind_Month -tf ii; //set as Arial font

Set

Change the attributes of the specified dataset, data plot, or worksheet.

Usage:

set name [option] [value]

Dataset, data plot or worksheet is specified by name.

  • If name is a dataset or data plot, only that dataset or data plot is affected.

  • If name is a worksheet, all datasets on the worksheet are affected.

The option switch determines which attribute is set to value. (Read these attributes with the get command.)

Options a through j (ordered alphabetically):

Options k through o (ordered alphabetically):

Options p through z (ordered alphabetically):

Examples:


Sort

data1_a = sort(data1_b);

sorts data1_b in ascending order, then assigns it to data1_a.

  • Sort the given variables in ascending order by value.

  • Sort all columns between c1 and c2, inclusive, in ascending order, against the specified worksheet dataset.

  • Sort all columns between c1 and c2, inclusive, in descending order, against the specified worksheet dataset.

  • Sort the entire worksheet in ascending order against values in the specified dataset.

  • Sort the entire worksheet in descending order against values in the specified dataset.

no option variable1 variable2 ... variable10

Reassign the values such that variable1 contains the smallest value, and variable10 (or the last variable given) contains the highest value.

-c c1 c2 datasetName

Row integrity is maintained.

-cd c1 c2 datasetName

Row integrity is maintained.

-w worksheetName datasetName

Row integrity is maintained.

-wd worksheetName datasetName

Same as -w, but sort in descending order.

  • If Data1 is the active window, the following script sorts the 2nd through the 7th columns against data1_c, in ascending order. If data1_c is not in the specified range, the relationship between it and the other columns is destroyed.

sort -c 2 7 data1_c;

  • The next script sorts all columns in the Data1 worksheet against the data1_c dataset.

sort -wd Data1 data1_c;

  • The following script uses the wks.nrows object property to assign the number of rows in several worksheets to several variables. The sort command is used to find the smallest value and place it in the A variable. The value of the smallest number of rows is typed to the Script window.

A = $(Data1!wks.nrows);

B = $(Data2!wks.nrows);

C = $(Data3!wks.nrows);

D = $(Data4!wks.nrows);

sort A B C D;

type “The smallest worksheet has $(A) rows.”;

Sort

Sort the given variables, or sort all values in the worksheet against a dataset.

Usage:

sort [option] object(s)

The built-in sort() function can also be used to sort a dataset. For example:

See also: sort object.

Options (ordered alphabetically):

Examples:


Switch

  • The following script uses the switch command. Because the expression in the parentheses following the switch command is the variable ii which evaluates to 2, case 2 is executed. The result from this script is b.

ii=2;

switch (ii)

{

case 1:

type “a”;

break;

case 2:

type “b”;

break;

case 3:

type “c”;

break;

default:

type “none”;

break;

}

  • In the following example, the expression in the parentheses following the switch command is a string variable, so its evaluation is case-sensitive. However, the keywords case, default, and to are case-insensitive.

GetString "Enter a string"; // input is put in %B

switch (%B)

{

CASE "a":

type -a "You entered an 'a'.";

break;

case "b": CASE "c":

type -a "You entered a 'b' or 'c'.";

break;

case "A":

type -a "You entered an 'A'.";

break;

case "A" "B" "F" to "Z":

type -a "You entered 'A' or 'B' or between 'F' and 'Z'.";

break;

case 1 2 5 to 7:

type -a "You entered 1 or 2 or between 5 and 7.";

break;

default:

type -a "No match, this is the default case.";

break;

}

Note that the lexical order is AaBbCc... so 'b' and 'B' would both be found by:

case "A" to "C":

Switch

The switch command is a special multi-way decision maker that tests whether an expression matches one of a number of values, and branches accordingly.

Usage:

switch (expression) {case 1: . . . case 2: . . . case n: . . . [default: . . .]}

The value can be either a constant, an identifier, or a string variable. When expression is a string variable, the evaluation is case-sensitive (see the Examples).

Each case requires a break command, so the following commands are not executed. A default case can also be used, and should come last (when nesting switch commands, the default case must come last). The default case is executed only when no other case is matched.

Note: The case, default, and to keywords are case-insensitive.

Examples:


Timer

  • Execute the TimerProc macro every cycleLength seconds.

  • Stop executing the TimerProc macro.

no option cycleLength

-k

This removes the current timer.

  • The following script prints “Hello” to the Script window every twenty seconds.

def TimerProc {type “Hello”};

timer 20;

Timer

This command executes the TimerProc macro every cycleLength seconds.

Usage:

timer <cycleLength>

Before issuing this command, you must define the action TimerProc should perform.

The @TM system variable indicates whether or not the timer is running. 1 = timer is running, 0 = timer is not running.

Options (ordered alphabetically):

Examples:


Type

n = 8000;

type $(n, %6.0f);

will output:

8000

whereas:

n = 8000;

type "$(n, %6.0f)";

will output:

8000

(with two leading white spaces)

Type -b $General.BadCalculation;

types out the BadCalculation text contained in the General section of the ORIGIN.OMG file to a dialog box with an OK button. The OMGfileName file extension is assumed to be OMG. If OMGfileName is not specified, the ORIGIN.OMG file is assumed.

To specify non-printable characters:

\n New line.

\r Return.

\d Delete/backspace.

\t Tab.

\xhh Any characters, where hh are two hex digits.

For example:

type -b “Test A \r\n\Next Line\x0d\x0a”;

A fixed width output is now supported allowing text and numbers to be output in a table-like format using the type command. Using the following notation, the output of the variable (represented by Var) will take up i number of characters no matter how long the variable is.

type $(Var,*,L$(i))

  • Print string to the Script window.

  • Open the Script window (if it is closed) and print string.

  • Display string in a dialog box with an OK button.

  • Display string in a dialog box with OK and Cancel buttons.

  • Hide the Script window.

  • Print to the Script window, but disable the carriage return and linefeed for this text.

  • Display string in a dialog box with Yes and No buttons.

  • Perform argument operation on the Script window.

  • Display string in the status bar.

  • Enable or disable the arithmetic status messages that show the progress of calculations.

  • Enable or disable the status bar.

  • Types string to a previously open Script window even if it has been hidden.

  • Type the text property of the object to an attention box.

  • Type the text property of the object to a Yes/No dialog box.

  • Type the text property of the object to the status bar.

  • Type the text property of the object to a Yes/No/Cancel dialog box.

  • Override escape sequence substitution.

  • Display string in a dialog box with Yes, No and Cancel buttons.

no option string

-a string

-b string

If the string is omitted, this command produces a beep.

-c string

Click on the Cancel button to generate a break in the current script.

-h

-l string

-n string

Click on the No button to generate a break in the current script.

-o argument

Argument can be one of the following (you need only supply the first letter):

  • execute -- Turn Script Execution off. This shifts the Script window out of script execution mode.

  • new -- Create a new Script window text file. Erases any changes made since last saving the current text file.

  • open [filename] -- Print the filename file to the Script window. If filename is not specified, open the Open dialog box.

  • print -- Print the contents of the Script window.

  • save [filename] -- Save the current Script window text. Create a new file named filename if filename is specified. This is the simplest way to create a script file.

  • tab pixels -- Set the tab spacing to pixels pixels. The default value is 45 pixels.

  • window title -- Change the title of the Script window to title.

-q string

-qp n

n = 1 (enable) or (disable) n = 0.

-qs n

Enable (n = 1) or disable (n = 0) the status bar. When the status bar is disabled, the last message displays until the status bar is enabled again.

-s string

-tb object.property

-tn object.property

-tq object.property

-ty object.property

-v -option message

Override using the escape sequence substitution so that \n is not recognized as New Line, \r is not recognized as Return, etc. (see the above note on “Specifying non-printable characters”).

Use -v before (option) -b, -c, and -y. This option allows the use of file paths in message (see the Examples below).

-y string

  • Click on the Yes button to set Origin’s t variable to one.

  • Click on the No button to set t to zero.

  • Click on the Cancel button to generate a break in the current script.

  • The following script displays the message “I’m busy right now” in the status bar.

type -q “I’m busy right now”;

  • The next script displays the message “Here is some text, and here is some more” on one line in the Script window.

type -l “Here is some text”;

// other code

type “, and here is some more”;

  • The next script prints “My file is stored in C:\TEMP\FILE1.OPJ.” to a dialog box with an OK button. Note: \T is not interpreted as a tab.

type -v -b “My file is stored in C:\TEMP\FILE1.OPJ.”;

  • The last script displays the Bottom X Axis Title text in the status bar.

type -tq “XB.text”;

Type

Outputs a string to the specified device.

Usage:

type [option] string

  • Always surround string with quotation marks, particularly if string contains leading white space. For example:

  • If string contains an equal sign “=”, enclose string in parentheses. Otherwise, the statement is interpreted as an assignment.

Note: In addition to entering literal text for string, you can specify $[OMGfileName].Section.Title. This enables you to access a string title in a message file. For example:

Important Notes:

Specifying non-printable characters (escape sequences):

Fixed Width Output:

Options (ordered alphabetically):

Examples:


Undo

  • Undo the last action.

  • Backup dataset by creating an internal copy of dataset.

  • Create an internal copy of the specified dataset range.

  • Create an internal copy of dataset.

  • Create an internal copy of the datasets in the active worksheet.

  • Create an internal copy of the datasets in the specified worksheet wks.

  • Create an internal copy of the selected dataset range in the active worksheet.

no option

dataset

-dr dataset i1 i2

The dataset range includes rows i1 to i2. To create an internal copy of a single data point, set i1 = i2.

Origin executes this command internally when a data point is deleted from the graph window using the Data:Remove Bad Data Points menu command.

-dx dataset

Origin executes this command internally when a data plot is (horizontally) translated using the Analysis:Translate:Horizontal menu command.

-wa

Origin executes this command internally when Edit:Clear Worksheet is selected.

-wc wks

Origin executes this command internally when Analysis:Sort is selected.

-wr

Origin executes this command internally when Analysis:Normalize is selected.

  • The following script modifies worksheet column values in Data1_B. It then restores the original column values.

undo Data1_B; // Make an internal copy of Data1_B.

Data1_B+=4;

undo; // Undo the dataset modification.

  • Assuming a range of data is selected in Data1_B, the next script modifies the values in the data range. It then restores the original values.

undo -wr; // Make an internal copy of the selected range.

Data1_B/=4;

undo;

  • The next script modifies worksheet column values in Data1_A and Data1_B. It then restores the original column values.

undo -wc Data1; // Make an internal copy of datasets in Data1.

Data1_A+=4;

Data1_B+=4;

undo; // Undo the dataset modification.

  • The last script restores a deleted data point (in this example, the second point) in the Data1_B dataset.

undo -dr Data1_B 2 2; // Make an internal copy of the second data point.

mark -d Data1_B -b 2 -e 2; // Delete the second data point.

undo;

Undo

This command provides a LabTalk interface to Origin’s Edit:Undo menu command.

Usage:

undo [option] [dataset]

For an understanding of usage, review the sample scripts provided in the Examples section.

Note: Some actions in Origin do not add anything to the undo stack and are therefore not reversible. Other actions will clear the undo stack. To find where this option is currently implemented, search the OGS files for “undo”.

Options (ordered alphabetically):

Examples:


Window

  • Set winName as the active window.

  • Activate (restore) the winName notes window.

  • Go to the URL web page.

  • Open or set as active, the specified window.

  • Close the winName window.

  • Close the winName window as if the user selected the Close menu command from the child window system menu.

  • Close the worksheet and delete all the data.

  • Hide the active window (window's Project Explorer view mode changes).

  • Close the winName notes window without prompting.

  • Create a duplicate of the active window.

  • Activate a graph window and delete all data plots. If the window does not exist, create a new window based on a named template and and name the window.

  • If the active window was opened from a template file, put the path and the template file name into %A.

  • Hide the active window (window's Project Explorer view mode is not changed).

  • Minimize the active window.

  • Minimize the winName notes window.

  • Put the active window to the end of the Window menu window list.

  • Merge all graph windows.

  • Prompt with a dialog box before merging all graph windows.

  • Create a new window from scratch (not from a template) and name it winName.

  • Execute (operate) the specified script for the named window.

  • Execute (operate) the specified script for the named hidden window.

  • Rename windowName with the given newName.

  • Open the Rename dialog box.

  • Specify a window label for the windowName window, and set the window to display the label in the window title.

  • Window system call to tile all windows.

  • Open a new window from the template file.

  • Open a new Excel workbook.

  • Temporarily set the active window to winName (allows commands that work with the active window to apply to winName).

  • Maximize the active window.

  • Maximize the winName Notes window.

-a winName

This option also has the effect of a Windows Restore if the active window is maximized or minimized.

-an winName

-aw URL

View htm files from the local computer (note the use of quotation marks). For example:

// example 1: Go to the OriginLab home page.

win -aw http://originlab.com;

// example 2: Open htm from Origin directory (held in %Y)

win -aw “file://%YmyHelp.htm”;

-b winName

This command option is obsolete. Use the GetNamedWin macro instead.

-c winName

The window is closed without prompting the user. If the window is a worksheet window, the datasets are not deleted.

-ca winName

This option prompts the user with a dialog box.

-cd winName

-ch n

n = 1 to hide the active window and n = 0 to show the active window.

The window's Project Explorer view mode changes. For example, if the window was in Normal view, it changes to Hidden view (Project Explorer View column) when n = 1. See also, win -h.

-cn winName

-d

The new window is named Datan or Graphn, etc. , where n is the lowest available number.

-e winName [template]

Activate the winName graph window and empty the window of all data plots. If the window does not exist, create a new window based on the specified template and name it winName. If template isn't provided, then open the window based on the winName template, otherwise open the ORIGIN.OTP template.

-g

-h n

n = 1 to hide the active window and n = 0 to show the active window. The window's Project Explorer view mode remains set to its current view (for example, Normal or Maximized), but it does not display. See also, win -ch.

-i

-in winName

-l 0

-m

-ma

-n winType [winName]

  • If winType is plot, open a graph window.

  • If winType is data or wks, open a worksheet.

  • If winType is n, open a Notes window.

If winName is not specified, use the next available default name (Graph1, Graph2, Data1, Data2, etc.).

Note 1: This option is not recommended for creating graph windows. Use the win -t command option instead.

Note 2: After creating a worksheet with the win -n command, you must set the number of rows for the worksheet using the set -er command. For more control over creating worksheets, use the win -t command or the create command and object.

-o winName {script}

WinName is temporarily set internally as the active window, the script is executed, then the original active window is re-established. Most commands operate on the active window. The %H system variable can be used by commands that require a window name.

-oa winName {script}

WinName is temporarily set internally as the active window, the script is executed, then the original active window is re-established. Most commands operate on the active window. The %H system variable can be used by commands that require a window name.

-r windowName newName

-ra

-rl windowName "labelContents"

This is equivalent to:

windowName!page.title = 1;

windowName!page.label$ = "labelContents";

-s T

-t winType template [winName

  • If winType is p, open a graph (plot) window.

  • If winType is d or wks, open a worksheet window.

  • If winType is m, open a matrix window.

  • <*If winType is t, open the window type specified by the template file (requires file extension in template).

The window is named winName, or named by default (Graph1, Graph2, etc.) if winName is not given.

If winType, template, and winName are omitted, Origin opens a Datan worksheet based on ORIGIN.OTW.

This command checks for a path in template and will use this path if specified. If the path includes spaces, you must surround the path with quotation marks (" ").

For example, use win -t winType c:\MyDir\MyTemp winName to open a winType window based on the MyTemp template in the c:\MyDir directory. Name this window winName.

Use win -t winType MyDir\MyTemp winName to open a winType window based on the MyTemp template in the MyDir subdirectory of the software directory. Name this window winName.

Whenever loading is from the software directory, it will search first on the user and then on the system directory.

Note: If you close the winName worksheet with the win -c command and then use this win -t command option to open a winName worksheet (where winName is the same with both command options), Origin's behavior is dependent on the value of the @wd system variable.

When @wd = 1, Origin deletes the datasets that remain from the win -c command and then opens the winName window.

When @wd = 0, #Command Error! prints to the Script window. Origin does not delete the datasets that remain from the win -c command. Additionally, Origin does not open the winName window.

-tx wks excel

-w winName

Temporarily set the active window to winName. This allows commands that work with the active window to apply to winName. You must eventually execute win -w to restore normal operation before using the command again.

-z

-zn winName

  • The following script opens a graph window from the MASTER template (in the software directory) and names the window Master.

win -t plot MASTER Master;

  • The next script opens a new worksheet from the FFT template (in the software directory) and names it by default (data1, data2, etc.).

win -t data FFT;

  • The next script opens a graph window from the MASTER template located in the C:\MYOWN directory and names the window Master.

win -t plot c:\MyOwn\MASTER Master;

  • The following script opens a graph window from the MASTER template located in the MYOWN subdirectory of the software directory and names the window Master.

win -t plot MyOwn\MASTER Master;

  • The next script finds the first window in the Window menu window list that begins with graph and sets it as the active window. If no window is found, it creates a Graph1 window.

win -b graph;

  • The following script rescales the Graph2 window's X axis from -10 to 10.

win -o graph2

{

x1=-10;

x2=10;

};

  • The last script closes the current worksheet together with all associated datasets.

Page.CloseBits=2; // uses the closebits page property

win -ca;

Window

This command creates, opens, closes, activates, and performs several actions on graph and worksheet windows.

Usage:

window option

The option switch determines the action to be performed.

Options (ordered alphabetically):

Examples:


Worksheet

  • Add n columns to the active worksheet.

  • Get the first worksheet that begins with winName.

  • Create a new Y column named colName and add it to the end of the worksheet.

  • Duplicate the active worksheet into a new worksheet named wksName (new wks becomes active window).

  • Duplicate the active worksheet into a new worksheet name wksName (original worksheet remains active).

  • Duplicate the active worksheet into a new worksheet name wksName and execute the worksheet script.

  • Open the specified worksheet dialogbox.

  • Set the colRef column to the given Format.

  • Set the number of decimal digits (nDigits) to be used by the colRef column.

  • Set the colRef column's internal type to the specified value.

  • Insert the name column as the n + 1 column in the worksheet.

  • Skip n header lines when importing ASCII data.

  • Store a maximum of n lines of header information in column labels when importing ASCII data.

  • Change the name of the colRef column to newName.

  • Plot the current worksheet selection in the nth graph type into the template.

  • Run the script in the Worksheet Script dialog box.

  • Set the specified range to be the current worksheet selection.

  • Set the colRef column as the given column type.

  • Verify that a named column exists. Create the column if it does not exist.

-a n

-b winName

  1. If the named window cannot be found, look for a template file called winName and open that.

  2. If no template file is found, open ORIGIN.OTW.

  3. If ORIGIN.OTW is not found, create a window from scratch, name it winName, and enumerate it.

-c colName

-d [wksName]

The new worksheet becomes the active window when this command is executed. If wksName is not specified, a default name (data1, data2, etc.) is used.

-da [wksName]

The new worksheet becomes the active window when this command is executed. If wksName is not specified, a default name (data1, data2, etc.) is used.

-dr [wksName]

The new worksheet becomes the active window when this command is executed. If wksName is not specified, a default name (data1, data2, etc.) is used.

-e dialogbox

Values for dialogbox are listed below. (Note: For Format, a column must be selected. Use the wks.colSel() object method. )

ASCII -- ASCII Import Options for Datan dialog box.

DisplayControl -- Worksheet Display Control dialog box.

Format -- Worksheet Column Format dialog box (first select a column).

Par -- Import Verification dialog box.

Script -- Worksheet Script dialog box. If the user clicks on the Do It button, i is set to 1. If the user clicks on the Update button, i is set to 0.

-f colRef colFormat

colRef must be the column number.

colFormat values: 1 = numeric, 2 = text, 3 = time, 4 = date, 5 = month, 6 = day of week, 7 = text & numeric.

-fd colRef nDigits

ColRef must be the column number.

nDigits = -3 specifies free format.

Note: This option is only available for columns set to Numeric (see the -f option, above).

-fi colRef internalType

ColRef must be the column number.

internalType: 1 = double, 2 = float, 3 = short, 4 = long.

-i n name

-k n

Determines the number of lines of header to skip when importing an ASCII file. When n = 0, skip 0 lines. When n = 1, skip 1 line, etc.

-kl n

Determines the maximum number of lines of header to store as column labels when importing an ASCII file.

-n colRef newName

ColRef must be the column number.

-p n template

Opens the Select Columns for Plotting dialog box if there is no current worksheet selection. Plots into the ORIGIN.OTP template if no template is specified. Possible n values are listed in the table, below.

Certain templates are included with the Origin software, and the template name is provided where applicable. You are not restricted to using the Provided Template.

n Value | Graph Type | Provided Template (OTP)
193 | Bubble (indexed size) | scatter
194 | Bubble + color mapped (2 Y columns selected) | scatter
200 | Line | line
201 | Scatter | scatter
202 | Line+symbol | linesymb
203 | Column | column
204 | Area | area
205 | High-Low-Close | hclose
206 | Box | box
207 | Floating Bar | floatbar
208 | XYAM Vector | vector
210 | 3D Walls | walls
211 | 3D Ribbons | ribbon
212 | 3D Bars | bar3d
213 | Column Stack | column
214 | Fill area | fillarea
215 | Bar | bar
216 | Stack Bar | bar
218 | XYXY Vector | vectxyxy
225 | Pie chart | pie
226 | Contours | contour, contline, contgray
227-229 | DLL | none
240 | 3D space plots | 3d, traject
242 | 3D surface plots | mesh, xconst, yconst, cmap, wirefrm, wireface
245 | Ternary | ternary
247 | Color mapped | scatter
248 | Bubble+color mapped (3Y columns selected) | scatter
279 | Histogram | hist

-r

-s c1 r1 c2 r2

To select entire columns, set r1 and r2 to zero. To select entire rows, set c1 and c2 to zero.

-t colRef colType

ColRef must be the column number.

colType: 1 = Y, 2 = Disregard, 3 = Y Error, 4 = X, 5 = Label, 6 = Z, and 7 = X Error.

-v colName

Otherwise, do nothing.

Note: If the column is created, the end display range is set to row 0.

  • The following script adds 20 columns to the worksheet.

work -a 20;

  • The next script renames each column as C1, C2, C3, etc., and fills each column with 100 values.

for (ii = 1; ii <= 20; ii++)

{

work -n $(ii) C$(ii);

work -t $(ii) 1;

wcol(ii)=data(ii, 100, ii);

}

  • The next script sets the selection range in the data1 worksheet and plots this data into the scatter graph template. The script then sets a new selection range in the worksheet and plots the data into a second graph window.

win -a data1; //activate data1

worksheet -s 2 0 2 0; //select column 2

worksheet -p 201 scatter; //plot into scatter template

win -a data1; //re-activate data1

worksheet -s 3 0 3 0; //select column 3

worksheet -p 201 scatter; //plot into scatter template

  • The last script sets column 3 as a text column.

work -f 3 2;

Worksheet

Use this command to set various formatting options for, and plot data from, the active worksheet.

Usage:

Worksheet option argument

Options (ordered alphabetically):

Examples:


Object Reference

Object Reference by Category

Object Properties and Methods

Internal Object Overview

External Object Overview

Alphabetical Listing of Objects


Object Reference by Category

Data Manipulation and Calculation

Display Control

Input/Output

Script Management


Data Manipulation and Calculation

Object | Description
curve | Perform smoothing, integration, differentiation, and baseline and peak operations on a data plot.
excel | Run Excel macros or VB application functions from Origin.
fft | Perform forward and backward fast Fourier transforms, correlation, convolution, and deconvolution.
integ | Read the integration results from the integrate command.
limit | Read the limit results from the limit command.
lr | Read the linear regression results from the lr command.
mat | Convert data between a worksheet and matrix. Perform mathematical operations on matrix data.
nlsf | Perform nonlinear least squares fitting.
sort | Sort worksheet data.
stat, stat.ds, stat.lr, stat.mr, stat.pr | Calculate descriptive statistics, linear, polynomial, and multiple regression.
sum | Read the statistics results from the sum() function or from Statistics on Columns.


Display Control

Object | Description
create | Create worksheets. Delete worksheet columns and datasets.
ed | LabTalk Editor control.
draw | Edit objects in Button Edit Mode.
layer | Edit the properties of a layer. Add data to a layer.
layer.axis | Edit the properties of an axis.
layer.axis.break | Edit the properties of an axis break.
layer.axis.grid | Edit the properties of axis grid lines.
layer.axis.label | Edit the properties of axis tick labels.
layer.plotn.boxchart | Edit the bin and box properties of a box chart.
page | Edit the properties of a page (e.g., the graph page).
system | Read the general project properties including the current date and time, the Origin version number, and the starting menu level.
system.axis | Edit the default axis color and width for graphs that aren't created from a template.
system.dash | Edit the dash line settings and hatch line settings.
system.datadisplay | Edit the properties of the Data Display toolbar.
system.date | Edit the custom date formats available from the Date Format drop-down lists.
system.dialog | Edit the open and close properties of the Options dialog box.
system.display | Edit the display properties for balloon help, window updating, and axis blinking when double-clicked.
system.excel | Edit the settings for using Excel in Origin.
system.font | Edit the font-related settings for text labels.
system.graph | Edit the graph-related settings that aren't saved with a template.
system.grid | Edit the properties of axis grid lines for graphs that aren't created from a template.
system.math | Set the angular units to radians, degrees, or gradians.
system.notes | Control the size of a notes window. Display a prompt when closing a notes window.
system.numeric | Edit the numeric display settings including the number of digits displayed after a decimal point, the numeric separator, and the conversion threshold for decimal to scientific notation.
system.operations | Control the display of the toolbar spacer.
system.page | Edit the spacing of the axis grid lines and the object grid lines.
system.project | Edit the Project Explorer display settings. Control the type of child window that displays when you open a new project.
system.script | Display a prompt when closing the Script window.
system.symbol | Edit the symbol border width and the line and symbol gap for data plots.
system.tick | Edit the tick and tick label settings that aren't saved with a template.
system.toolbar | Custom toolbar control.
system.wks | Display a prompt when closing an Excel workbook, worksheet, or matrix. Delete datasets when deleting a worksheet. Delete empty columns after transposing a worksheet. Set new columns to Numeric or to Text & Numeric.
type | Hide the Script window or the status bar.
wks | Edit the properties of a worksheet. Add, select, and insert columns. Combine worksheets. Open a worksheet based on a template.
wks.col | Edit the properties of a worksheet column.


Input/Output

Object | Description
copy | Read the number of elements copied when using the copy command.
db | ODBC import.
doc | Drag and drop import properties.
export | Export a graph to a file.
export.image | Control the display of an advanced dialog box for editing the image attributes when exporting a graph.
fdlog | Edit the properties and open the Save As, Open, and Open Multiple Files dialog boxes.
getpts | Read or set the points/screen coordinate properties when using the getpts command. The getpts command graphically gets points/screen coordinates from a data plot.
image | Export graphs. Import and export raster graphic images.
opack | Exchanging custom tools.
rt | Read the properties of the real-time data block coming into Origin.
system.copypage | Edit the Copy Page and export graph settings.
system.display | Control the setting when pasting images from the Clipboard (metafile or bitmap).
system.fileext | Add and remove file extension groups and add file extension types to the Save As and Open dialog boxes. Track the default file paths within an Origin session or between Origin sessions.
system.operations | Use OLE in-place activation when editing Origin objects embedded in another application.
system.print | Edit the print-related settings.
system.project | Back-up the current project file before saving.
type | Copy the contents of a worksheet to the Script window. Redirect analysis output to the Script window or a notes window. Display a modal message box. Append a header to the Results Log.
wks | Copy the contents of a worksheet into %A. Paste the variable contents into a worksheet.
wks.export | Control the data export options for a worksheet.
wks.import | Open the Import Verification dialog box before importing a data file.


Script Management

Object | Description
ini | Create sections in an initialization file. Assign values to keywords. Create new keywords.
macro | Read the number of arguments passed to a macro.
menu | Manipulate menu commands.
run | Execute script from a script file.


Object Properties and Methods

LabTalk operates on objects with properties and methods. Properties are specific attributes of an object, such as the color of a label or the number of columns in a worksheet. LabTalk property statements set a particular object attribute or return its current value. Methods are things that can be done to or with an object, such as updating its graphic image. LabTalk method statements take arguments and perform operations which are directly related to an object.

Properties

Methods


Properties

A property either sets or returns a number or a text string associated with an object.

Setting a Property Value

Returning a Property Value


Setting a Property Value

objName.Property = value

objName is the name of the object.

Property is a valid property for the type of object.

value is a number.

objName.Property$ = value

objName is the name of the object.

Property is a valid property for the type of object.

value is a text string.

Setting a Property Value

Numeric properties are set by LabTalk scripts using statements with the following syntax:

Text properties are set by LabTalk scripts using statements with the following syntax:


Returning a Property Value

  • Read the current value of a numeric property and assign the value to a variable:

  • Read the value of the numeric property in the Script window:

  • Use substitution notation to return the value of a numeric property:

variable = objName.Property

objName.Property =

For example, entering the following script in the Script window:

page.active =

could return

page.active = 1

indicating that the first layer of the page is active.

type -a “The property is $(page.active)”;

This script obtains the current value of the page object property, substitutes it for the expression, and types it in the Script window.

  • Read the current value of a text property and assign the value to a string variable:

  • Read the value of the text property in the Script Window:

  • Use substitution notation to return the value of a text property:

%letter = objName.Property$;

For example, enter the following script in the Script window to assign the value of the text property of a text label to the %Z string variable:

%Z = objName.text$

%Z =

type -b “The property is %Z”;

Returning a Property Value

The value of a numeric property is read and assigned to a variable using the following syntax:

The value of a text property is read and assigned to a string variable using the following syntax:


Methods

Methods are a form of immediate command. When executed, they carry out a function related to the object and return a value. Object methods use the following syntax:

objName.Method(arguments)

objName is the name of the object.

Method is a valid method for the type of object.

arguments determine how the method functions. Some arguments are optional and some methods do not require any arguments. However, the parentheses “()” must be included in every object method statement.


Internal Object Overview

Internal objects are objects which are constructed by Origin. There are two types of internal objects:

  • Window objects. Window objects are visible parts of Origin child windows. These include the visual objects created by Origin, as well as user-created visual objects.

  • Utility objects. Utility objects are generalized objects. These objects do not have a visual counterpart in the Origin project. Utility objects allow you to set properties that affect the active Origin session. The default values for most of these properties are set in the OPTION.CNF file which is read when Origin is launched. Many default property values may also be changed during an Origin session in the Options dialog box. To open the Options dialog box, select Tools:Options. See Utility Objects, Property and Method Syntax.


Visual Objects Created by Origin

[winName!]layer[n].property =

NOT

[winName!]page.layer[n].property =

[winName!]Layer[n].X.property =

NOT:

[winName!]X.property =

[winName!]Layer[n].Y.break.property =

NOT:

[winName!]break.property =

[winName!]wks.property =

NOT:

[winName!]page.wks.property =

For example:

[winName!]layer.property =

NOT:

[winName!]page.layer.property =

[winName!]wks.col[n].property =

NOT:

[winName!]col[n].property =

layer

layer.axis

layer.axis.break

layer.axis.grid

layer.axis.label

layer.plotn.boxchart

page

wks

wks.col

wks.export

wks.import

Properties and methods of Origin’s window objects affect the object in a specific window. If a window is not specified, the active window is used. The window object syntax is as follows:

[WinName!]objName.Method(arguments)

[WinName!]objName.Property = value

[WinName!]objName.Property$ = string

WinName! is optional. However, if winName is specified, its name must be followed by an exclamation point “!”. If winName! is not specified, the named object in the active window is affected.

objName is the name of the object.

Method is one of the available objName methods.

arguments are specific to the method.

Property is a valid property for objName.

value is a number.

string is a text string or string variable.

Visual Objects Created by Origin

The visual objects created by Origin are hierarchical in nature. For example, each Origin child window contains a visual page with an associated page object. A page can be either a graph or worksheet page, but most page object properties affect the visual graph page.

Each graph page contains at least one visual layer with an associated layer object. Because a graph window can contain only one page, when accessing the layer object’s properties or methods, the associated page object is not included or referenced. Thus, the property and method syntax of the layer object does not include the syntax of the page object. For example:

The graph layer contains a set of X Y axes with associated X, Y, etc. objects. Because a page can contain multiple layers, when accessing the X, Y, etc. object’s properties or methods, the associated layer object is included or referenced. Thus, the X, Y, etc. objects’ method and property syntax includes the syntax of the layer object. The X, Y, etc. objects are sub-objects of the layer object. For example:

The axes within an Origin child window can also contain graphic elements including tick labels, an axis break, and an axis grid. These visual elements have associated objects (label, break, and grid). The label, break, and grid objects are sub-objects of the respective X, Y, etc. object, which is a sub-object of the layer object. The object method and property syntax of the sub-objects includes the syntax of the “main” object. For example:

Each worksheet page contains no more than one visual worksheet with an associated wks object. The worksheet page also contains no more than one layer with an associated layer object. Because a worksheet window can contain only one page, and the page contains only one worksheet, when accessing the wks object’s properties or methods, the associated page object is not included or referenced. Likewise, because the worksheet page contains only one layer, when accessing the layer object’s properties or methods, the associated page object is not included or referenced. Thus, the syntax of the wks and layer objects does not include the syntax of the page object. For example:

The worksheet contains visual columns with associated col objects. The col object is a sub-object of the wks object. Thus, the col object method and property syntax includes the syntax of the wks object. Additionally, like the layer object, the col object is enumerated if the active column is not to be referenced. For example:

Window objects available in Origin:

Property and Method Syntax:


User-created Visual Objects

To open the Label Control dialog box:

  1. Select Edit:Button Edit Mode to enter Button Edit Mode.

  2. Click on the object, then select Format:Label Control.

  3. Enter the desired name in the Object Name text box.

  4. Click OK to close the dialog box.

[winName!]objName.property = value

or

this.property = value

WinName! is optional. It specifies the window that the named object resides in. This is useful when there are several objects with the same name in a project.

objName is the object’s name, as entered in the Object Name text box in the Label Control dialog box.

Property is one of the available objName properties.

The generic properties of these objects are listed below. (Note that not all properties are available for all objects.)

Property

Access

Description

object.arrowBeginLength

Read/write, numeric

Length of beginning arrow heads in point size.

object.arrowBeginShape

Read/write, numeric

Shape of beginning arrow heads by position in drop down list, Object Control dialog box: 0 = none, 1 = filled, 2 = chevron, etc.

object.arrowBeginWidth

Read/write, numeric

Width of beginning arrow heads in point size.

object.arrowEndLength

Read/write, numeric

Length of end arrow heads in point size.

object.arrowEndShape

Read/write, numeric

Shape of end arrow heads by position in drop down list, Object Control dialog box: 0 = none, 1 = filled, 2 = chevron, etc.

object.arrowEndWidth

Read/write, numeric

Width of end arrow heads in point size.

object.arrowPosition

Note that object.arrowBeginShape

and object.arrowEndShape

must also be set.

Read/write, numeric

Controls the display of arrow heads for each line segment of polyline and freehand objects:

0 = no arrow heads.
1 = arrow at beginning of each segment.
2 = arrow at end of each segment.
3 = arrow at both ends of each segment.

object.attach

Read/write, numeric

‘Attach to’ method:

0 = layer
1 = page
2 = axes scales

object.auto

Read/write, numeric

Redraw automatically after property changes: 0 = disable, 1 = enable.

object.background

Read/write, numeric

Control the background of an object as follows: 0 = no background, 1 = black line, 2 = shadow, 3 = dark marble, 4 = white out, and 5 = black out.

object.color

Read/write, numeric

Line, text, or outline color index number. Use the color() function, as in name.color=color(red);

object.dx, object.dy

Read/write, numeric

Width and height in axes units.

object.enable

Read/write, numeric

Enable hotspots on the object: 0 = disable, 1 = enable.

object.event

Read only, numeric

The object’s script execution: 1 = run script when button is clicked, 0 = all other events.

object.fillColor

Read/write, numeric

Shape object fill color index number. Use the color() function, as in name.fillcolor = color(red);

object.font

Read/write, numeric

Text label font index number. Use the font() function, as in name.font = font(arial);

object.fSize

Read/write, numeric

Text label font size.

object.height

Read only, numeric

Height in layer coordinate units.

object.hMove

Read/write, numeric

Horizontal movement: 0 = disable, 1 = enable.

object.index

Read only, numeric

Only applicable for objects composed of multiple items, such as the UIM objects. Indicates which item in an object has been affected by a Windows action.

(Note: The UIM is a component of OriginPro. For more information, contact OriginLab or your Origin distributor.)

object.keepInside

Read/write, numeric

Restrict object’s movement to within the layer frame: 0 = disable, 1 = enable.

object.left

Read/write, numeric

Left location of the object in physical coordinates.

object.lineType

Read/write, numeric

Line and arrow object line type: 1 = solid, 2 = dash, and 3 = dot.

object.lineWidth

Read/write, numeric

Line or arrow object line width.

object.mouse

Read/write, numeric

Mouse access to the object: 0 = disable, 1 = enable.

object.name$

Write only, string

Object name.

object.realTime

Read/write, numeric

Real-time update of substitution notation in a text label message: 0 = disable, 1 = enable.

object.revVideo

Read/write, numeric

Reverse video display: 0 = disable, 1 = enable.

object.rotate

Read/write, numeric

Text label rotation in degrees.

object.script

Read/write, numeric

Script, Run After mode index number, from the drop-down list in the Label Control dialog box.

object.show

Read/write, numeric

Object display: 1 = visible, 0 = hidden. Hidden objects are not selectable

object.states

Read/Write, numeric

Controls object edit states. The property is bit-oriented so that values can be added.

Example: polygon.states = 3, disables resizing and rotating for the object named polygon.

0 = all controls are enabled.
1 = resizing is disabled.
2 = rotating is disabled.
4 = skewing is disabled.
8 = moving individual points is disabled.
16 = in place editing is disabled.
32 = resize text label border disabled.
64 = horizontal movement is disabled.
128 = vertical movement is disabled.

object.text$

Read/write, string

Message displayed by a text label.

object.top

Read/write, numeric

Top of the object in physical coordinates.

object.vMove

Read/write, numeric

Vertical movement: 0 = disable, 1 = enable.

object.width

Read only, numeric

Width in layer coordinate units.

object.x, object.y

Read/write, numeric

Axes X Y coordinates of the center of the object.

object.x1, object.x2, object.y1, object.y2

Read/write

x1 and y1 are the axes position of the first drawn point of the object (for example, the start location of a line).

x2 and y2 are the axes position of the last drawn point of the object (for example, the end location of a line).

For more control over drawing lines, see the draw - l command.

The syntax of the user-created object methods is as follows:

[winName!]objName.Method(arguments)

or

this.Method(argument)

WinName! is optional. It specifies the window that the named object resides in. This is useful when there are several elements with the same name in a project.

objName is the object’s name, as typed in the Object Name text box in the Label Control dialog box.

Method is one of the available objName methods.

arguments are specific to the method.

Append the contents of stringVariable or my string to a text label. Requires a screen refresh to view the change.

object.addText(stringVariable)

object.addText(“my string”)

Examples:

  • Append text.

%A=append this text;

text.addtext(A); // Note: use A not %A

text.addtext(“append this text”); // Note: use quotation marks.

  • Simulate a click on the nth hot spot of the object. Multiple hot spots are a feature of UIM objects.

object.click(n)

  • Redraw the object. Option = local to redraw hot spots. Option = global to redraw the entire object.

object.draw(option)

  • Run the script of the object.

object.run()

  • The following script uses the addText method to add text to the text1 label. Note that the string variable argument does not include the percent character.

%Z = " added to end of line";

text1.addtext(Z);

%Z="

added as a new line";

text1.addtext(Z);

text1.draw(global);

  • The next script disables horizontal movement for the Arrow object in the Graph2 window.

Graph2!Arrow.hmove = 0;

  • When entered in the Script window, the next script types the X and Y coordinates of the center of the Button object to the Script window.

Button.x =;

Button.y =;

  • The following script runs the script associated with an object named Mode in the Graph1 window.

Graph1!mode.run();

  • The last script uses the draw() method to redraw the WksData object in the Data2 window.

Data2!WksData.draw(global);

User-created Visual Objects

Visual objects can also be created by the Origin user and placed in an Origin child window. These objects include labels, arrows, lines, and other user-created graphic elements. These objects are accessed from script by their name, as defined in the associated Label Control dialog box.

Scripts can be attached to these labels by typing the script into the text box of the Label Control dialog box. The Script execution trigger is set from the Script, Run After drop down list.

In general, only named objects can be accessed from LabTalk script. However, an unnamed object can be accessed by a script from within its own Label Control dialog box with this. notation, as described below.

The syntax of the user-created visual object properties is as follows:

Available General Properties:

Methods:

Available General Methods:

Examples:


Utility Objects, Property and Method Syntax

Break

Copy

Create

Doc

Draw

Excel

Export

Export.Image

Fdlog

GetPts

Ini

Integ

Limit

LR

Macro

Menu

RT

Run

Sort

Sum

Type

and

System

and all the system subobjects:

System.Axis

System.Circle

System.CopyPage

System.Dash

System.DataDisplay

System.Date

System.Dialog

System.Display

System.Excel

System.FileExt

System.Font

System.Graph

System.Grid

System.Line

System.Line4

System.Math

System.Notes

System.Numeric

System.Operations

System.Page

System.Path

System.Polygon

System.Polyline

System.Print

System.Project

System.Rect

System.Script

System.Symbol

System.Tick

System.Toolbar

System.Wks

Utility Objects, Property and Method Syntax

Properties and methods of Origin’s utility objects affect the entire Origin session. The utility object syntax is as follows:

objName.Method(arguments)

objName.Property = value

objName.Property$ = string

objName is the name of the object.

Method is one of the available objName methods.

arguments are specific to the method.

Property is a valid property for the objName object.

value is a number.

string is a text string or string variable.

These utility objects available in Origin:


External Object Overview

External objects are objects which exist in external DLLs. External objects are not window specific - they affect the entire Origin session. A number of external objects are already accessible in Origin. Additionally, you can create your own objects in user-defined external DLLs. This process is reviewed in the OriginPro Manual (OriginPro only).

To list the current external objects and the DLL that each is mapped to in the Script window, use the DLL -l; command.

External Objects, Property and Method Syntax

Common Properties and Methods


External Objects, Property and Method Syntax

Ed

Curve

DB

FFT

Image

Mat

OPack

NLSF

Stat

External Objects, Property and Method Syntax

Properties and methods of external objects affect the entire Origin session. External object syntax is as follows:

objName.Method(arguments)

objName.Property = value

objName.Property$ = string

objName is the name of the object.

Method is one of the available objName methods.

arguments are specific to the method.

Property is a valid property for the objName object.

value is a number.

string is a text string or string variable.

The following external objects are available in Origin:


Common Properties and Methods

Property | Access | Description
object.apparent | Read/write, numeric | If object = stat: Use axes scale functions to perform apparent fitting. 1 = enable, 0 = disable.
object.data$ | Read/write, string | If object = stat: The name of the input dataset in linear and polynomial regression. If object = curve: the name of the input dataset.
object.error |  | Not in use.
object.errorOut |  | Not in use.
object.errow |  | Not in use.
object.matrix$ |  | Not in use.
object.msg$ |  | Not in use.
object.name.datan$ |  | New dataset name as generated by object.
object.name.worksheet$ |  | New worksheet name as generated by object.
object.orgVer |  | Not in use.
object.sysErr |  | Read only, numeric. System error. Same as ERRNO defined in STDLIB.H.
object.version |  | Not in use.
object.warnMsg |  | Not in use.
object.worksheet$ | Read only, string | Name of the worksheet with the original data.
object.X$ |  | Not in use.
Method | Description
object.lastErrID() | Not in use.
object.listErr() | List all errors that occurred in the program (in reverse order of occurrence).
object.reset() | Reset all DLL properties to their original, unassigned values.
object.test() | Not in use.

Common Properties and Methods

External objects share a number of properties and methods. These properties and methods are listed and described in the following sections.

Note: Replace object with the desired external object (for example, curve).

Properties:

Methods:


Alphabetical Listing of Objects

A complete listing of all LabTalk objects is provided in the following sections:

Ascimport | Layer.Axis.Break | System.CopyPage | System.Polyline
Break | Layer.Axis.Grid | System.Dash | System.Print
Copy | Layer.Axis.Label | System.DataDisplay | System.Project
Create | Layer.Plotn.BoxChart | System.Date | System.Rect
Curve | Limit | System.Dialog | System.Script
DB | LR | System.Display | System.Symbol
Doc | Macro | System.Excel | System.Tick
Draw | Mat | System.FileExt | System.Toolbar
Ed | Menu | System.Font | System.Wks
Excel | NLSF | System.Graph | Type
Export | OPack | System.Grid | Worksheet (wks)
Fdlog | Page | System.Line | Wks.Col
Export.Image | RT | System.Line4 | Wks.Export
FFT | Run | System.Math | Wks.Import
GetPts | Sort | System.Notes |
Image | Stat | System.Numeric |
Ini | Sum | System.Operations |
Integ | System | System.Page |
Layer | System.Axis | System.Path |
Layer.Axis | System.Circle | System.Polygon |


Ascimport

Property | Access | Description
Ascimport.ApplyRange | Read/write, numeric | Apply new range to dataplots when file is imported. 1 = on, 0 = off.
Ascimport.AutoColTypes | Read/write, numeric | Automatic determination of column types. 1 = on, 2 = off.
Ascimport.AutoSubHeaderLines | Read/write, numeric | 1 = Use autodetermination of subheaders. 0 = specify using Ascimport.SubHeaderLines.
Ascimport.Character$ | Read/write, Character | The character to use when Ascimport.Delimeter = 4 (Other). One, printable ASCII character is allowed.
Ascimport.Delimited | Read/write, numeric | Specify fixed width or delimited column separation. 0 = fixed width, 1 = delimited.
Ascimport.Delimiter | Read/write, numeric | The delimiter to use for column separation. From the Origin list: 0 - Unknown 1 - Comma(,) 2 - Tab 3 - Space 4 - Other
Ascimport.FileName$ | Read/write string | The full path and name of the file to import.
Ascimport.HeaderLines | Read/write numeric | Number of lines to read as header.
Ascimport.Labels | Read/write numeric | Create column Labels from headers. 1 = on, 0= off.
Ascimport.LeadingZeroes | Read/write numeric | Support numbers with leading zeroes. 1 = on, 0 = off.
Ascimport.MaxLabels | Read/write numeric | Maximum lines to store in Column Labels.
Ascimport.NonNumeric | Read/write numeric | Action when non-numeric data is read for a numeric field: 0 - Terminate import 1 - Read as missing data 2 - Start new worksheet/column 3 - Append to header label
Ascimport.NumColumns | Read/write numeric | Specific number of columns to import. Deprecated - Use partial import instead.
Ascimport.Partial | Read/write numeric | Use Partial Import (1) or Full Import (0)
Ascimport.Partial.C1 | Read/write numeric | First column for partial import
Ascimport.Partial.C2 | Read/write numeric | Last column for partial import
Ascimport.Partial.R1 | Read/write numeric | First row for partial import
Ascimport.Partial.R2 | Read/write numeric | Last for partial import
Ascimport.RenameCols | Read/write numeric | Rename columns if first line has labels. 1 = on, 0 = off.
Ascimport.RenameWks | Read/write numeric | Rename Worksheet to Filename after import. 1 = on, 0 = off.
Ascimport.SubHeaderLines | Read/write numeric | Number of lines to read as SubHeader.
Ascimport.TestLines | Read/write numeric | Number of lines used for file structure testing.
Ascimport.Width$ | Read/write string | The string to use for Fixed Column Widths. For example: "6,19,19,19,2,20"

Method | Description
Ascimport.GetSettings() | Read the import settings from the active worksheet into the ascimport object. You can also specify the worksheet as in ascimport.getsettings(Data4).
Ascimport.Import() | Execute the ASCII import.
Ascimport.Reset() | Resets the partial range.
Ascimport.WriteSettings() | Write the ascimport object properties to the active worksheet. You can also specify the worksheet as in ascimport.writesettings(Data4).

This example reads the current settings, specifies a range for partial import, sets the partial import flag, prompts the user for a filename, writes the settings and executes the import.

ascimport.GetSettings();

ascimport.Partial.C1=2;

ascimport.Partial.C2=5;

ascimport.Partial.R1=10;

ascimport.Partial.R2=14;

ascimport.partial=1;

getfile *.dat;

ascimport.WriteSettings();

ascimport.import();

Ascimport

The Ascimport object contains properties and methods corresponding to the ASCII import Options dialog box.

Properties

Methods

Examples


Break

Property | Access | Description
break.abort | Read only, numeric | 1 = the user pressed the Cancel button. Otherwise, is 0.
break.max | Read/write, numeric | Maximum value of the progress bar. Note: Must set this property value after using the break.open() method.
break.min | Read/write, numeric | Minimum value of the progress bar. Note: Must set this property value after using the break.open() method.
break.style | Read/write, numeric | 0 = default, 1 = no progress bar, 2 = End button instead of a Cancel button.
Method | Description
break.close() | Close the progress/information dialog box.
break.open(message) | Open a progress/information dialog box. Message is displayed in the dialog box.
break.set(value) | Set the current value for the progress dialog box. Note: If you need a progress bar that shrinks, then you must precede every break.set() that causes shrinking with a break.set(break.min) to clear the progress bar.

Break

Construct a progress/information dialog box that is under scripting control.

Object type: Utility

Properties:

Methods:


Property | Access | Description
copy.n | Read only, numeric | Read the number of elements copied when using the copy command.

  • The following script assumes that a Data1 worksheet exists with at least two columns, Data1_A and Data1_B. The script copies the elements of Data1_A to Data1_B and prints (to the Script window) the number of elements copied.

copy Data1_A Data1_B;

type “$(copy.n)”;

Copy

The copy object is used in association with the copy command.

Object type: Utility

Properties:

Examples:


Create

Property

Access

Description

create.datan$

Read only, string

Returns the nth created dataset created with the create.wks() method.

create.enumerate

Read/write, numeric

Enumerate worksheet columns:

1 = enable. When using create.wks(), if the columns passed already exist in the worksheet, then add new enumerated columns based on the column names.

0 = disable. If the columns already exist, overwrite them.

create.enumWks

Read/write, numeric

Enumerate worksheet.

1 = enable. When using create.wks(), if the worksheet set by create.wksname$ already exists, create a new enumerated one.

0 = disable. If the worksheet exists, use that worksheet. Otherwise create it.

create.npts

Read/write, numeric

Total number of rows in the worksheet. Default is 60. The minimum is 25.

create.numTypes

Read/write, numeric

If specified, it determines the total number of column types.

If this is not specified, then the total number of column types is equal to the nth value in create.type. The default is 0 and is user-assigned only (it is never set internally).

create.readOnly

Read/write, numeric

Set the worksheet as read only. 1 = enable. 0 = disable.

create.template

Read/write, numeric

Name of the worksheet template to use to create the worksheet. Most Origin scripts use CREATE.OTW. Example: create.template$ = "Create"; will use CREATE.OTW to create the worksheet.

create.typen

Read/write, numeric

n can be 1 to 20. This specifies the column type for the columns created by create.wks(). If more columns are being created than the number of types, then the "pattern" is repeated unless typeN is specified.

Example: Type1 = 4; Type2 = 1: this will make the columns X and Y repeatedly (unless TypeN is specified) until the total number of columns (specified in wks() method) are created.

create.typeN

Read/write, numeric

This value is used if the number of columns being created is greater than the total number of types specified. If typeN = 0, then the rest of columns will get the same type as the first set of columns. Default is 0.

Example: create.type1 = 4; create.type2 = 1; create.typeN = 6; When create.wks() is executed, it will create one X column, one Y column, and the rest of the columns created will be Z columns.

create.wksLabel$

Read/write, string

Set the label for the worksheet created with the create.wks() method.

create.wksName$

Read/write, string

String property to specify the name of the worksheet. After create.wks() is executed, it holds the name of the last worksheet created.

Method | Description
create.delete(colName) | Deletes the column and the associated datasets. If a Y column is specified, the associated X, Err, and Label columns will also be deleted. If an X column is specified, the dependant Y columns will be deleted. The worksheet this operates on is specified in create.wksName$.
create.reset() | Currently not implemented.
create.wks(colName) | Create a minimized worksheet with the name set to the string stored in create.wksName$. If colname equals an existing dataset, concatenate and truncate (if necessary) the name by removing the "_".

The following script creates a hidden worksheet named Test1 with an X and Y column.

create.wksName$ = "Test";

create.enumwks = 1;

//If worksheet exists, truncate and enumerate name of

//next wks

create.wkslabel$ = "This is a test worksheet";

create.template$ = "CREATE";

//Use the CREATE.OTW

create.npts = 30;

//Set the number of rows

create.enumerate = 1;

//If columns passed already exists,

//truncate and enumerate newly created columns

create.numtypes = 2;

//Only two types of columns will be used

create.type1 = 4;

//Only explicitly specify 1st type as X

create.type2 = 1;

//Set TypeN = Y column type

create.wks(A B);

//Create wks named Test with X column=A and Y column=B

%A = create.data1$;

//Set %A to first created dataset

%B = create.data2$;

// Set %B to second created dataset

%K = create.wksname$;

//Set %K to name of last worksheet created

Create

The create object is used to create a custom minimized worksheet.

Object type: Utility

Properties:

Methods:

Examples:


Curve

Property | Access | Description
curve.baselinePts | Read/write, numeric | Number of points used in baseline creation.
curve.data$ | Read/write, string | Name of the Y column in the worksheet to perform the operations on. This property must be set before performing an operation.
curve.derivDeg | Read/write, numeric | Degree of differentiation: 0, 1, or 2.
curve.i1 | Read/write, numeric | Starting row index number of the selected range.
curve.i2 | Read/write, numeric | Ending row index number of the selected range. When i1 > 0, i2 must be specified.
curve.plotName$ | Read/write, string | The name of the graph containing the data to be acted on by the curve object. This property does not require setting.
curve.show | Read/write, numeric | Display the integration area: 0 = do not show, 1 = show.
curve.smoothPts | Read/write, numeric | Total number of points to be smoothed including point (must be odd and >= 3).
curve.x0 | Read only, numeric | Value of X at i1.
curve.x1 | Read only, numeric | Value of X at i2.
curve.y0 | Read only, numeric | Value of Y at i1.
curve.y1 | Read only, numeric | Value of Y at i2.
curve.ymax | Read only, numeric | Maximum value of the active dataset with respect to the baseline.
curve.ymax0 | Read only, numeric | Maximum value of the active dataset with respect to zero.
curve.ymax0i | Read only, numeric | Row index number for ymax0.
curve.ymax0x | Read only, numeric | Value of X corresponding to ymax0.
curve.ymaxi | Read only, numeric | Row index number for ymax.
curve.ymaxx | Read only, numeric | Value of X corresponding to ymax.
curve.ymin | Read only, numeric | Minimum value of the active dataset with respect to the baseline.
curve.ymini | Read only, numeric | Row index number for ymin.
curve.yminx | Read only, numeric | Value of X corresponding to ymin.
Property | Access | Description
curve.base$ | Read/write, string | Name of the worksheet column that is used as a baseline. For integration, you must set this property. Set it to an existing dataset (curve.base$ = wks_colName;) or specify the following: (curve.base$ = “ “;). When curve.base$ is set to “ “, then the curve.integrate() method integrates from y = 0.
curve.integrate.area | Read/write, numeric | Integral.
curve.polyDeg | Read/write, numeric | The degree of the underlying polynomial used for smoothing. Values can range from 1 to 9.
curve.res | Read only, numeric | Tolerance for deviation in X axis values. This value is fixed at 5%.
curve.result$ | Read/write, string | Name of the (existing) dataset that stores the results. This property must be set before performing the math operation.
curve.smoothLeftPts | Read/write, numeric | The number of points on the right of the data point being smoothed when using curve.sgsmooth(). This property combined with curve.smoothRightPts make up the smoothing window and can not exceed 100 points. The window can be asymmetric about a particular data point - i.e., the number of points to the left of the point of interest can be different from the number to the right.
curve.smoothRightPts | Read/write, numeric | The number of points on the right of the data point being smoothed when using curve.sgsmooth(). This property combined with curve.smoothLeftPts make up the smoothing window and can not exceed 100 points. The window can be asymmetric about a particular data point - i.e., the number of points to the left of the point of interest can be different from the number to the right.
curve.x$ | Read/write, string | Name of the X column to use for the math operation.
Method | Description
curve.adjave() | Smoothing using the adjacent averaging method. The result is stored in curve.result$.
curve.deriv() | Differentiate. The result is stored in curve.result$.
curve.FFTSmooth() | Smoothing using the Fourier transform method. The result is stored in curve.result$.
curve.integrate() | Integrate. The result is stored in curve.result$.
curve.SGDeriv() | Differentiate using the Savitzky-Golay method. The result is stored in curve.result$.
curve.SGSmooth() | Smoothing using the Savitzky-Golay method. The result is stored in curve.result$.

Property

Access

Description

curve.areas$

Read/write, string

Worksheet column used for storing areas between base points.

curve.basex$

Read/write, string

Worksheet column used for storing X coordinate for the base points.

curve.basey$

Read/write, string

Worksheet column used for storing Y coordinate for the base points.

curve.centers$

Read/write, string

Worksheet column used for storing the center points.

curve.halfWidths$

Read/write, string

Worksheet column used for storing the half-widths.

curve.heights$

Read/write, string

Worksheet column used for storing the heights.

curve.integrate.area

Read only, numeric

Area under a single peak.

curve.integrate.center

Read only, numeric

Center point of a single peak.

curve.integrate.halfwidth

Read only, numeric

Half-width for a single peak.

curve.integrate.height

Read only, numeric

Height of a single peak.

curve.markerIndex$

Read only, string

Worksheet column used for storing the selected baseline points.

curve.maxPeakRange

(You must also set curve.minPeakRange and curve.minHeight.)

Read/write, numeric

The value of this property is used for peak picking only if curve.pickPeaks.simple = 0.

Set this property to be the percentage of the total number of points in curve.data$ that the peak must not exceed in order to be recognized as a peak.

curve.minDer

Read/write, numeric

Minimum value of the first derivative below which a point is accepted.

curve.minHeight

(You must also set curve.minPeakRange and curve.maxPeakRange.)

Read/write, numeric

The value of this property is used for peak picking only if curve.pickPeaks.simple = 0.

Set this property to be the percentage of the total amplitude (difference between min and max values) of curve.data$ that a peak must have, to be considered a peak. This property enables you to exclude noise when determining peaks.

curve.minPeakRange

(You must also set curve.maxPeakRange and curve.minHeight.)

Read/write, numeric

The value of this property is used for peak picking only if curve.pickPeaks.simple = 0.

Set this property to be the percentage of the total number of points in curve.data$ that the peak must have in order to be recognized as a peak.

curve.peakDirection$

Read/write, string

Holds the name of the dataset that will have either a P (for positive) or an N (for negative) in the Peaks worksheet. The indexes of the peaks will be loaded in curve.peakIndex$.

curve.peakIndex$

Read/write, string

Worksheet column used for storing the index for the peak points.

curve.pickPeaks.minHeight

(You must also set curve.pickPeaks.rectHeight and curve.pickPeaks.rectWidth.)

Read/write, numeric

The value of this property is used for peak picking only if curve.pickPeaks.simple = 1.

Set this property to be the percentage of the total amplitude (difference between min and max values) of curve.data$ that a peak must have, to be considered a peak. This property enables you to exclude noise when determining peaks.

curve.pickPeaks.rectHeight

(You must also set curve.pickPeaks.minHeight and curve.pickPeaks.rectWidth.)

Read/write, numeric

The value of this property is used for peak picking only if curve.pickPeaks.simple = 1. When curve.pickPeaks.simple = 1, the curve.pickPeaks() method uses a search rectangle for peak picking. Curve.pickPeaks.rectHeight determines the height of the search rectangle.

Set this property to be the percentage of the difference between the maximum and minimum values in curve.data$.

curve.pickPeaks.rectWidth

(You must also set curve.pickPeaks.rectHeight and curve.pickPeaks.minHeight.)

Read/write, numeric

The value of this property is used for peak picking only if curve.pickPeaks.simple = 1. When curve.pickPeaks.simple = 1, the curve.pickPeaks() method uses a search rectangle for peak picking. Curve.pickPeaks.rectWidth determines the width of the search rectangle.

Set this property to be the percentage of the total range of values in curve.data$.

curve.pickPeaks.simple

Read/write, numeric

Set this property to 1 if curve.data$ does not have a definable baseline. If curve.data$ has a definable baseline (even if irregular), then set curve.pickPeaks.simple = 0.

Method | Description
curve.baseline() | Find all points that make a baseline.
curve.mrkIntegrate() | Get the first baseline points on either side of the peak.
curve.pickPeaks() | Get all the peak points. The search method depends on property settings. See curve.pickPeaks.simple, curve.maxPeakRange, curve.minHeight, curve.minPeakRange, curve.pickPeaks.minHeight, curve.pickPeaks.rectHeight, curve.pickPeaks.rectWidth.

  • This script performs a differentiation using the Savitzky-Golay method (%Y holds the DRIVE:DIRECTORY for the ORIGIN70.INI file.):

  • This script performs an integration from a baseline (%Y holds the DRIVE:DIRECTORY for the ORIGIN70.INI file.):

  • This script finds peaks in the active data plot and adds the peak XY values and row index numbers to the original worksheet:

//Open a new worksheet

win -t data Origin;

//Import sample file

open -w %YSamples\Data\Data with noise.dat;

//Create a column for results

wks.addcol(Result);

//Assign datasets

curve.data$ = DataWithNoise_Signal;

curve.result$ = DataWithNoise_Result;

curve.i1 = -1;

curve.smoothpts = 5;

curve.derivdeg = 1;

//Perform differentiation,

//fill Result column of original worksheet

curve.sgderiv();

//Open a new worksheet

win -t data Origin;

//Import sample file

open -w %YSamples\Data\Peaks with base.dat;

//Create a column for results

wks.addcol(Results);

curve.data$ = PeaksWithBase_Amp;

curve.base$ = PeaksWithBase_Base;

curve.result$ = PeaksWithBase_Results;

//Perform integration,

//fill results column of original worksheet

curve.integrate();

//Send the total area to the script window

type "Area = $(curve.integrate.area)";

curve.reset(); //initialize

%W = %[%C,'_']; //get name of wks for active data in layer

%W!wks.addcol(Pkindex); //add column to store index value

%W!wks.addcol(Pkx); //add column to store x value

%W!wks.col$(%W!wks.ncols).type = 4; //set as X column

%W!wks.addcol(Pky); //add column to store y value

curve.data$ = %C; //dataset to find peak values

curve.peakIndex$ = %W_PkIndex;

curve.pickPeaks.rectHeight = .05;

curve.pickPeaks.rectWidth = .05;

curve.pickPeaks.minHeight = .05;

curve.pickPeaks(1); //pick peaks without a definable baseline

get %W_PkIndex -e end;

for (ii = 1; ii <= end; ii += 1)

{

%B = curve.data$; // %B is current active dataset

index = %W_pkindex[ii]; // get peak index

%W_Pkx[ii] = xvalue(index,%B); // Set corresponding x value

%W_Pky[ii] = %B[index]; // Set corresponding y value

}

Curve

The curve object provides for the following math operations on a data plot:

  • Smoothing

  • Integration

  • Derivation

It also provides for baseline operations and peak selection.

Object type: External

Common Curve Object Properties:

Curve Object Properties Specific to Math Operations:

Curve Object Methods Specific to Math Operations:

Curve Object Properties Specific to Baseline Operations and Peak Selection:

Curve Object Methods Specific to Baseline Operations and Peak Selection:

Examples:


DB

db.autosetcol | Read/write, numeric | This option automatically determines whether the worksheet column type and name can be changed or not. The value of this property can be 1 for true, and 0 for false. This affects each column in the worksheet, and if enabled, the db.read() method will set the column type as well as the column name. If disabled, the read operation will return an error if the column type in the worksheet is not consistent with the column type in the database. (Used by the db.read() method only.)
db.c1 | Read/write, numeric | Column number of wksname to send data to.
db.dbc1 | Read/write, numeric | Column number in the database table to begin reading. By default, the value of this parameter is 1 (see db.read.mode).
db.dbc2 | Read/write, numeric | Column number in the database table to end reading (see db.read.mode).
db.dbcolcount | Read only, numeric | The total number of columns in a particular table from a particular data source.
db.dbcolname$ | Read/write, string | Name of the column in the database table (see db.readcol).
db.dbcolnamelist$ | Read/write, string | All the column names in a particular database table.
db.dbpath$ | Read/write, string | Drive and path to data source.
db.dbpwd$ | Read/write, string | Database password for the user ID.
db.dbr1 | Read/write, numeric | Row number in the database table to begin reading. By default, the value of this parameter is 0 : read the data in the database table from row 1 (see db.readrow).
db.dbr2 | Read/write, numeric | Row number in the database table to end reading. If not specified, db.readrow will return an error message (see db.readrow).
db.dbsource$ | Read/write, string | Name of the data source. This data source name should first be defined by using the ODBC Administrator. If the name is empty or there is no source with this name, an error message is sent to the users.
db.dbsourcecount | Read only, numeric | The total number of data sources in the user’s computer.
db.dbsourcelist$ | Read only, string | All the data source names in the user’s computer. This means all the data source names in the ODBC.INI file.
db.dbsql$ | Read/write, string | SQL SELECT statement.
db.dbtable$ | Read/write, string | Name of the table in the database. If the table name is empty or there is no such table in the database, an error message is sent to the users.
db.dbtablecount | Read only, numeric | The total number of the tables in a particular data source.
db.dbtablelist$ | Read only, string | All the table names in a particular data source.
db.dbuid$ | Read/write, string | Database user ID.
db.getcolinfo.name$ | Read only, string | The column name in a table.
db.getcolinfo.type | Read only, numeric | The column type: 0 for numeric, 1 for text.
db.r1 | Read/write, numeric | Row number of wksname to send data to.
db.read.autoaddcol | Read/write, numeric | This option will determine whether the worksheet column can be added or not. The value of this property can be 1 for true, 0 for false. If enabled, the db.read() method will automatically add columns and the new columns will automatically set as the correct type and name corresponding to the database table column type and name. If disabled, and the total number of columns in the table is larger than in the worksheet, the read operation will return an error. (Used by the db.read() method only.)
db.read.mode | Read/write, numeric | This property is only for the db.read() method. Define mode as follows: mode = 0 default, read the entire database; mode = 1, read a range of the database as specified by dbc1 and dbc2 (see db.read(mode)).
db.sqlcomment$ | Read/write, string | Holds any comments or description.
db.tabletype$ | Read/write, string | “Table” or “View”.
db.wksname$ | Read/write, string | Name of the worksheet to receive the data.
Method | Description
db.addsource() | Add the data source through the ODBC administrator. Open a dialog box from which the user can add one data source.
db.close() | Close a database which has been opened (see db.open()).
db.editsql() | Open the ODBC Dialog dialog box with the Data Base and Select Case tabs. If the data source is valid it should be listed in the Data Source list box. If the table is valid for the source it should be listed in the Table list box. Upon user confirmation, convert the spreadsheet display as well as the table name and database name into an SQL string to store in db.dbsql$.
db.getcolinfo(colNumber) | Get one column’s information and set the information to db.getcolinfo.name$ and db.getcolinfo.type. Input the column number.
db.getcolslist() | Set db.dbcolcount and fill db.dbcolnamelist$.
db.getsourcelist() | Set db.dbsourcecount and fill db.dbsourcelist$.
db.gettablelist() | Set db.dbtablecount and fill db.dbtablelist$. (This closes the database; if you want to get table information, reopen the database.)
db.loadsql([#]) | Gets the comment, data source name, table name, and SQL SELECT statement from an SQL text object : SQL1, SQL2, etc. The first line of an SQL text object is a comment. The second line is the name of the ODBC data source. The third line is the name of the table. The fourth line is either TABLE or VIEW. The fifth and subsequent lines are for the SELECT statement. The number argument is optional - the default is 1. Return 0 for OK (i.e. the data source is valid, the table exists within the source and the SQL syntax is proper for this combination) and 1 if an error occurs.
db.open() | Open a database as specified in db.dbsource$.
db.read(mode) | The argument ‘mode’ can be set with db.read.mode if it is not specified in db.read() as an argument. When specified as an argument, db.read.mode is ignored and uses the specified argument instead. (To set the read column range of a database table, see db.read.mode.)
db.readcol() | Read the data in the database for the specified column name. If the column name is empty or the column name is not correct, return an error message. (See db.readrow() for the db.autosetcol option - db.dbc1 and db.dbc2 should be 0).
db.readrow() | Read the data in the table from db.dbr1 to db.dbr2. If db.dbr2 is not specified, return an error message. Whether the column type and name in the worksheet can be set or not is determined by the db.autosetcol option.
db.reset() | Resets the db object properties.
db.savesql([#]) | Sets the db.comment$, data source name, table name, and db.dbsql$ to an SQL text object : SQL1, SQL2, etc. The first line of an SQL text object is a comment. The second line is the name of the ODBC data source. The third line is the name of the table. The number argument is optional - the default is 1. Return 0 for OK and 1 if an error occurs.

You can use LabTalk script along with SQL commands to import data from a data source without selecting the File:Import:ODBC menu command. SQL (Structured Query Language) is a standardized language that has evolved for accessing data from a variety of databases. In this section, we will describe only a small subset of SQL for the purposes of importing data from a database into an Origin worksheet. The basic SQL commands and syntax that we need to understand are shown in the following example of an SQL query statement:

SELECT column list FROM table name

WHERE "columnname1">20 AND "columnname1" <= 40

AND "columnname2" = String

OR "columnname3" <> 20 ###

ORDER BY "columnname1" DESC

For example, suppose you have a data source named ProjectData with a table named SalesTable and columns named State, City, Sales, and Balance. Then the following SQL query:

SELECT "State", "Sales", "Balance" FROM SalesTable

WHERE "Sales" > 20 AND "Sales" <= 40 AND "STATE" = "Texas"

OR "Balance" <> 0

ORDER BY "Sales" DESC

selects data from columns State, Sales and Balance (but not City) from the table named SalesTable satisfying Sales between 20 and 40 (including 40), State equal to Texas and Balance not equal to 0.

Finally, order the selection from the largest Sales value to the smallest (DESC means descending order).

  • To select all the columns of the table, use an asterisk * as in SELECT * FROM SalesTable.

  • To select ascending order, omit the word DESC.

  • To select the original order in the data table, omit the entire ORDER BY command.

Once a data source, data table, and an SQL selection are decided upon, you can use LabTalk commands to import the selected data. The following example illustrates this procedure.

In Step 1 of the example code, a Label Object named sql2 is made whose label message is the following:

nwind_mdb

Order Details

SELECT * FROM "Order Details"

WHERE "UnitPrice" > 20 AND "UnitPrice" < 30 AND

"Quantity" < 30

ORDER BY "ProductID" DESC

The first two lines are the name of the data source and the name of the data table, respectively. Use Origin's Data Base tab to assign or determine data sources and tables. The remaining lines comprise the SQL query statement, which can be any number of lines. You can use label names sql1, sql2, etc. but not arbitrary names. This is because the method loadsql(#) loads the label message of the label named sql#. Also, avoid sql1 because sql1 is the default label name used by the Select Case tab to store your selection and query. Instead, use sql2 etc. when writing script.

In Step 2 of the example code, an ODBC command object named db is created using the LabTalk command:

dll -a db odbc60;

This allows the db object to access the functions in ODBC60.DLL as properties and methods.

In Step 3, the db object's methods and properties are used to import data according to the information in the label message sql2.

Step 4 writes some information to the Script window.

Example LabTalk Script Code to Import a Data Source Table or View into an Origin Worksheet with a specified SQL Statement:

// LabTalk script begins here:

// Step 1. Create a non-visible Label object called SQL2

// with the message: (substitute your query)

// SQL2

// nwind_mdb

// Order Details

// SELECT * FROM "Order Details"

// WHERE "UnitPrice" > 20 AND "UnitPrice" < 30 AND

// "Quantity" < 30

// ORDER BY "ProductID" DESC

// label -n name message. creates a Label object.

label -n SQL2 //SQL2 Statement

nwind_mdb

Order Details

TABLE

SELECT * FROM "Order Details"

WHERE "UnitPrice" > 20 AND "UnitPrice" < 30 AND "Quantity" < 30

ORDER BY "ProductID" DESC

;

SQL2.show = 0; // Clear Visible check box in Label Control box.

// Step 2. Create an ODBC60.DLL command object called db.

dll -a db odbc60;

db.loadsql(2); // Load the message of sql2 label.

// Step 3. Now import into specified worksheet

repeat wks.ncols {del col(1)}; // empty active worksheet

db.wksname$ = %H; // %H is active wks

db.open();

db.autosetcol = 1;

db.read.autoaddcol = 1;

db.read(0);

db.close();

// Step 4. Show SQL query in Script window for verification.

type -a Data has been imported according to the SQL query:;

%A = sql2.text$;

%A = ;

// sql2.show = 1. make visible

type -a Data Source, Table/View and SQL Query:;

%A = sql2.text$;

%A = ;

type -a Origin Worksheet Name:;

%B = db.wksname$;

%B = ;

// End of LabTalk Script

DB

Origin provides a DLL named ODBC60.DLL that allows you to create an ODBC command object whose properties and methods connect Origin to Microsoft's ODBC interface. You can create a command object named db using the following LabTalk script:

dll -a db odbc60;

The command object db can now be used as an Origin object with the following properties and methods.

Object type: External

Properties:

Methods:

Example: Using LabTalk and SQL to Import Data from a Data Source


Doc

Property | Access | Description
doc.dropCount | Read only, numeric | Total number of files that have been dropped onto the Origin workspace. The OnOpen section in DOFILE.OGS will run once for each dropped file; dropIndex will indicate which file is being processed and will increment from 1 to dropCount.
doc.dropIndex | Read only, numeric | When one or more data files are dropped into Origin, this property holds the number of files dropped.
doc.dropLayer | Read only, numeric | When one or more data files are dropped onto a graph, this property holds the layer number the data is added to. If the data is dropped onto a worksheet, this property is set to 1. If the drop location is inside the Origin program window but outside of a worksheet or graph window, this property is set to 0. If the drop location is on the Origin program icon, this property is set to -1.
doc.dropWinName$ | Read only, string | When one or more data files are dropped onto a graph or worksheet window, this property holds the window name. If the files aren't dropped on a window, or if the files are dropped onto the Origin program icon, then this property is set to "".
doc.isNew | Read only, numeric | This property has a value of 1 if the project is a new project (not loaded from a file) and has never been saved. Once the project is saved, this property becomes 0.
doc.wksNamen$ | Read only, string | Returns the name of the nth worksheet. n is the order in which the worksheets were created in the project (1, 2, etc.).

If Data1 is the first worksheet created in the project, then the following (Script window) script returns Data1.

%Z = doc.wksname1$;

%Z = ;

Doc

The doc object provides read only access to general project properties.

Object type: Utility

Properties:

Examples:


Draw

Property | Access | Description
draw.auto | Read/write, numeric | 0 = globally disable all object.auto properties. For more information on the object.auto property, see User-created Visual Objects.
draw.last$ | Read/write, string | Name of the last created label or named object.
draw.mode | Read/write, numeric | 1 = Button Edit Mode, 0 = normal mode.
draw.showProg | Read/write, numeric | Real-time objects flash while processing data: 1 = enable, 0 = disable. Mostly used with RTM objects. For more information on RTM objects, contact OriginLab or your Origin distributor.
Method | Description
draw.get(GrpObj) | This method is the reverse of the draw.set() method. Instead of updating all the properties of all the sub-objects in a tool from a source object, this method updates the source object properties from the tool sub-object property values. GrpObj is the name of the tool containing the source sub-object property values. The object which is updated with the tool’s sub-object property values is specified by the tool sub-object’s name. The sub-object's name must start with an "_@". It is assumed that the characters following the "_@", and before any numeric digits, are the name of the object to receive the sub-object property values. The property values are assigned by matching the sub-object’s control or label names with the object’s property names. Note: The object’s properties must be writable.
draw.set(GrpObj [, DefObj]) | This method updates all the properties of all the sub-objects in a tool from a source object. GrpObj is the name of the tool. DefObj (optional) is the name of the default object that contains* the source values. *The properties of the tool sub-objects are updated from one of the following source objects: 1. DefObj 2. An object specified by the sub-object’s name. If the sub-object's name starts with an "_@", then it is assumed that the characters following the "_@", and before any numeric digits, are the name of the source object to get the values from. If the sub-object's name does not start with an "_@", then DefObj is used as the source. The property values are assigned by matching the source object’s property names with the sub-object's control or label names. Note: The tool’s sub-object properties must be writable.

The following script is equivalent to selecting Edit:Button Edit Mode.

draw.mode = 1;

Draw

The draw object maintains properties for current settings in label object management.

Object type: Utility

Properties:

Methods:

Examples:


Method | Description
ed.open() | Open a new LabTalk Editor window.
ed.open(fileName) | Open the specified script file in a new LabTalk Editor window.
ed.open(fileName, sectionName) | Open the specified script file at the specified section in a new LabTalk Editor window.
ed.openFile(fileName) | Open the specified script file in the active LabTalk Editor window.
ed.saveFile(fileName) | Save the current script in the active LabTalk Editor window to the fileName script file.

Ed

The ed object provides script access for the LabTalk Editor.

Object type: External

Methods:


Excel

Method | Description
excel.run(functionName, Arg1, Arg2, …, Arg5) | Run a Visual Basic application function from Origin. You must supply the correct number of arguments with this method. The method can accept up to five arguments. The workbook containing the Visual Basic application function must be active. FunctionName is the Visual Basic application function.
excel.runRange(sheetName, RangeName, Arg1, Arg2, …, Arg5) | Run a macro from Origin. You must supply the correct number of arguments with this method. The method can accept up to five arguments. The workbook containing the macro must be active. SheetName is the name of the sheet containing the macro. Rangename is the name of the cell on the sheet where the macro starts (for example, C6)

Note: The excel.runRange() method was designed for older versions of Excel macros that were actually included as part of a spreadsheet in a particular cell or range. (Since Excel 5, macros have become VBA code and old-style macros can't be created in new versions of Excel.) Example: Use of the excel.runRange() method:

excel.runRange(SheetName,ExcelRange)

which will activate SheetName and select ExcelRange.

For example:

excel.runRange(Sheet2,A12:F25);

will activate Sheet2 of the (active) Excel workbook and select columns A through F and rows 12 through 25.

New style macros can be run with the excel.run() method.

Excel

The excel object provides script access for running Excel macros and invoking Visual Basic application functions.

Object type: Utility

Methods:


Method | Description
export.image(fileName, imageType) | This method exports the active graph to an image file. The file name is specified in the fileName string argument. The type of image file is specified in the imageType string argument. For valid image type strings, see the export.image.types$ property for the export.image sub-object.

Export

The export object provides script access for exporting graphs to graphic files.

Note: We recommend you use the image object instead of the export object.

Object type: Utility

Methods:


Fdlog

Property | Access | Description
fdlog.asReadOnly | Read only, 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.
fdlog.choice | Read only, 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.
fdlog.defType | Read/write, 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. Dialog Method Default Name Open Open SaveAs Save As MultiOpen Import Multiple ASCII
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$.
fdlog.multiOpen.colView | Read/write, 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.
fdlog.multiOpen.comboSel | Read/write, numeric | The default and the user selection from the combo box.
fdlog.multiOpen.count | Read only, 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.
fdlog.multiOpen.sort | Read/write, numeric | The list of user's selected files in the MultiOpen dialog box supports two types of sort. The first type of sort is the "standard" sort, where files in the list can be sorted by file name, size etc. by clicking on the corresponding column. This corresponds to fdlog.multiOpen.sort = 0 and is the default value of the property. fdlog.multiOpen.sort = 1 specifies the second type of sort, where each group of files added is sorted within itself, but the groups are not intermixed.
fdlog.multiOpen.colToggle | Read/write, 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"; There is currently a limit of 25 file types.

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.

Filtertype can be:

0 = filters for ASCII data

1 = filter for Binary data

2 = user defined filters

-1 = all filters (default)

Wintype can be:

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.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. If 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.

  • 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.

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

  • 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.

[main]

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(Calc); //add a column to the worksheet

%(%H,wks.ncols) = %(%H,1) + %(%H,2); //perform a calculation

[createplot]

win -t plot line; //open the line.otp graph template

layer -i %(%1,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);

fdlog.ShowComment = 0;

fdlog.UseGroup(Template);

fdlog.UseType(OTP);

if (fdlog.Open(A))

return 1;

%B = fdlog.Path$;

doc -t %B%A;

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;

}

}

Fdlog

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).

Object type: Utility

Definitions for this object:

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".

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)

Extension Group: A list of Extension Descriptions. Example: Images

Properties:

Methods:

Examples:


Property | Access | Description
export.image.showDialog | Read/write, numeric | During exporting, this property determines if a dialog box of image settings will be shown to allow the user to change image attributes. A value of nonzero will show the dialog box and a value of zero will not show the dialog box.
export.image.types$ | Read only, string | This property is used to get a list of all the image types currently supported. The list contains file extensions. Example: "BMP EPS JPG". The main use of this property is with the fdlog.useType() method.

Export.Image

The export.image object is a sub-object of the export object. It provides script access for the graphic export filters and filter properties.

Note: We recommend you use the image object instead of the export.image object.

Object type: Utility

Properties:


FFT

The fft object performs forward and backward (i.e., inverse) Fast Fourier Transforms. It also handles Correlation, Convolution, and Deconvolution Functions.


Fast Fourier Transforms

Note: Some properties are shared by all external objects. For a list and description of these properties, see Common Properties and Methods.

Property | Access | Description
fft.backward.fDelta | Read/write, numeric | Sampling interval in the frequency domain to be used in backward FFT.
fft.backward.freqData$ | Read/write, string | Name of the sampling dataset in the frequency domain to be used in backward FFT.
fft.backward.imagData$ | Read/write, string | Name of the dataset for the imaginary components in the frequency domain to be used in backward FFT.
fft.backward.realData$ | Read/write, string | Name of the dataset for the real components in the frequency domain to be used in backward FFT.
fft.convention | Read/write, numeric | Switch the sign used in calculating FFT. 0 = negative exponent for forward FFT, and positive for backward FFT. This is the Electronic Engineering convention. 1 = positive exponent for forward FFT, and negative for backward FFT. This is the Physics convention.
fft.forward | Read/write, numeric | (>0) for forward FFT. Otherwise, backward FFT.
fft.forward.imagData$ | Read/write, string | Name of the dataset for the imaginary components in the time domain to be used in forward FFT.
fft.forward.realData$ | Read/write, string | Name of the dataset for the real components in the time domain to be used in forward FFT.
fft.forward.tDelta | Read/write, numeric | Sampling interval in the time domain to be used in forward FFT.
fft.forward.timeData$ | Read/write, string | Name of the sampling dataset in the time domain to be used in forward FFT.
fft.nextPowerOf2 | Read/write, numeric | The next power of 2, compared to fft.size.
fft.normalize | Read/write, numeric | (>0) to normalize FFT results.
fft.output.ampData$ | Read/write, string | Name of the dataset for the amplitude in the output.
fft.output.imagData$ | Read/write, string | Name of the dataset for the imaginary components in the output.
fft.output.interval | Read/write, numeric | Sampling interval in the output.
fft.output.phaseData$ | Read/write, string | Name of the dataset for the phase (angle) in the output.
fft.output.powerData$ | Read/write, string | Name of the dataset for the power spectrum in the output.
fft.output.realData$ | Read/write, string | Name of the dataset for the real components in the output.
fft.output.samplingData$ | Read/write, string | Name of the sampling dataset in the output.
fft.real | Read/write, numeric | (>0) for FFT on real numbers.
fft.resolution | Read/write, numeric | Used when checking whether the sampling data is equally spaced. This is the tolerance in percentage of the average spacing.
fft.shifted | Read/write, numeric | (>0) shift the FFT results.
fft.size | Read/write, numeric | The number of data points.
fft.spectrum | Read only, numeric | 1 = display amplitude, 2 = display power spectrum.
fft.start | Read/write, numeric | The starting row number of the selected data for FFT.
fft.unwrap | Read/write, numeric | (>0) unwrap the phase data.
fft.windowing | Read/write, numeric | Window method: 1 = rectangular, 2 = Welch, 3 = Hanning, 4 = Hamming, and 5 = Blackman.
Method | Description
fft.backward() | Performs backward FFT.
fft.chkres() | Check whether the sampling data is equally spaced. The tolerance is set by fft.resolution.
fft.forward() | Performs forward FFT.

Return values of 0 and 1 represent the success and failure of the method. A message also appears in the Script window when a failure occurs.

  • The following script performs a forward FFT on data with the Time data dataset as Data1_A and the Real data dataset as Data1_B. The results will be put into the worksheet FFT1.

fft.reset();

fft.forward = 1;

fft.forward.timeData$ = Data1_A;

fft.forward.tdelta = Data1_A[2] - Data1_A[1];

fft.forward.realData$ = Data1_B;

window -t W fft FFT1;

fft.output.samplingdata$ = FFT1_Freq;

fft.output.realdata$ = FFT1_Real;

fft.output.imagdata$ = FFT1_Imag;

fft.output.ampdata$ = FFT1_r;

fft.output.phasedata$ = FFT1_Phi;

fft.output.powerdata$ = FFT1_Power;

fft.real = 1;

fft.normalize = 1;

fft.shifted = 1;

fft.windowing = 1;

fft.spectrum = 1;

fft.unwrap = 1;

fft.forward();

Fast Fourier Transforms

The following criteria are important for using the fft object:

  • All properties must be assigned before each transform. Otherwise, the last assignments made may have an effect on the current transform.

  • The Time dataset always converts time to frequency in forward FFT transform, and frequency to time in backward FFT.

  • Inverse FFT does not calculate amplitude and phi of data.

Object type: External

Properties:

Methods:

Examples:


Correlation, Convolution, and Deconvolution Functions

Property | Access | Description
fft.corr.corrData$ | Read/write, string | Name of the dataset for the correlation result.
fft.corr.lagData$ | Read/write, string | Name of the dataset for the lag.
fft.conv.convData$ | Read/write, string | Name of the dataset for the convolution result.
fft.conv.indexData$ | Read/write, string | Name of the dataset for the index.
fft.deconv.deconvData$ | Read/write, string | Name of the dataset for the deconvolution result.
fft.deconv.indexData$ | Read/write, string | Name of the dataset for the index.
Method | Description
fft.conv(signalData, responseData) | Performs a convolution of two datasets: signalData and responseData. Results are stored in fft.conv.convData$ and fft.conv.indexData$.
fft.corr(dataset1, dataset2) | Performs a correlation of two datasets: dataset1 and dataset2. If the datasets are the same, then it becomes an autocorrelation. Results are stored in fft.corr.corrData$ and fft.corr.lagData$.
fft.deconv(signalData, responseData) | Performs a deconvolution of two datasets: signalData and responseData. Results are stored in fft.deconv.deconvData$ and fft.deconv.indexData$.

  • The following script imports a sample data file and performs a convolution.

//Open a new worksheet

win -t data Origin;

//Import sample file

open -w %YSamples\Data\Data with noise.dat;

//Insert columns for results

wks.col = wks.ncols+1;

wks.insert(Index Conv);

//Response dataset must have odd number of points

//and less than half the number of points than the signal.

set DataWithNoise_Response -e 51;

fft.conv.indexdata$ = DataWithNoise_Index;

fft.conv.convdata$ = DataWithNoise_Conv;

fft.conv(DataWithNoise_Signal,DataWithNoise_Response);

Correlation, Convolution, and Deconvolution Functions

The convolution and deconvolution functions require you to input two columns of datasets (the signal dataset and the response dataset). The data should be formatted with numeric values.

The correlation and convolution functions output two new columns, one for "lag" or "index" variables, and one for the correlation, convolution, or deconvolution result.

In Origin, there are some special requirements for the response dataset:

  • The response dataset should consist of an odd number of points and be a representative sample of a symmetric function.

  • The number of points, r, in the response dataset must be less than half the number of points, s, in the signal dataset. (The last r points, and, to a lesser extent, the first r points, of the s points in the result are of no value. Therefore, 2*r should be much less than s.)

  • The sum of the points in the response curve should be unity in order to retain the amplitude of the original dataset. Otherwise the convolution result will be scaled by a factor equal to the sum.

To avoid possible artifacts from the FFT (performed as part of the convolution process), you should pad the signal data with zero values until you have an integral power of two number of points. You will also need to extend your X data accordingly.

Object type: External

Properties:

Methods:

Examples:


GetPts

Property | Access | Description
getpts.count | Read/write, numeric | Contains the number of selected points.
getpts.data$ | Read/write, string | The name of the plotted dataset to use.
getpts.index | Read/write, numeric | The index of the latest selected point.
getpts.indexData$ | Read/write, string | The dataset containing indexes.
getpts.max | Read/write, numeric | The number of points to get.
getpts.xdata$ | Read/write, string | Dataset that holds each successive X position value.
getpts.ydata$ | Read/write, string | Dataset that holds each successive Y position value.

GetPts

The getpts object is the object replacement for the getpts command.

Object type: Utility

Properties:


Image

Property | Access | Description
image.fileName$ | Read/write, string | Use to specify the source and destination file name.
image.libError | Read only, numeric | Equals the last error that occurred in a third-party library. The image object is handled by the OIMG60 DLL. This DLL makes calls to third-party libraries. If an error occurs in a third party library then image.libError will be set to the error number returned by the third-party library.
image.showOptions | Read/write, numeric | Used to specify if the Options dialog box should be displayed when the image.export methods are called.

Method

Description

image.getExtList(strVar, list)

Get a list of supported file extensions and put it into strVar.
The extensions depend on the value of list. list can be one of the following:
"EP" = Export Page
"EM" = Export Matrix
"IM" = Import Matrix
"R" = Raster
"V" = Vector
Returns the number of extensions copied into strVar or -1 for error.

image.isVector(extension)

Test if the specified extension is a vector format. Returns 1 if format is vector, else 0.

Image

The image object provides script access for exporting graphs to graphic files. It also provides script access for importing a raster graphic image file into a matrix and for exporting the matrix to a raster graphic image file.

Object type: External

Properties:

Methods:


Image.Export SubObject

Property

Access

Description

image.export.tempRaster

Read/write, numeric

When exporting to a raster format, Origin creates a temporary image that will be converted to the destination image by the third-party library. Origin can pass an EMF or a BMP to the third-party library. Each format has its advantages and disadvantages. This property specifies which format to use. 0 = EMF, 1 = BMP, 2 = BMP first, if BMP not successful then EMF. Option two (2) exists because high resolution BMPs can quickly consume a lot of memory and Windows 95 and 98 are limited to 16MB BMPs in memory. If the BMP fails to be created then Origin will try an EMF.

image.export.vectorKeepSize

Read/write, numeric

When exporting vector formats, Origin will pass an EMF to the third-party library. EMFs and WMFs are created using the Copy/Export Page Settings on the Page tab of the Options dialog box.

If image.export.vectorKeepSize is 0 then the metafile is created using the settings in the dialog box.

If image.export.vectorKeepSize is 1 then the metafile is created using the following settings:
Ratio = 100, system.copyPage.ratio = 100
Margin Control = Page, system.copyPage.closeness = 2
Advanced On (Simple off), system.copyPage.advanced = 1
Keep Size On (Set Resolution off), system.copyPage.advKeepSize = 1

Method | Description
image.export.matrix(matrixName, imageType) | Export a matrix window to a raster gray scale image. matrixName is the name of the matrix window to export. imageType is the destination image type. The destination file name is specified in image.fileName$. Example: Image.FileName$ = "myimage.bmp"; Image.Export.Matrix(Matrix1, BMP);
image.export.pageDPI(imageType, dotsPerInch, bitsPerPixel, compression) | Export the active graph or layout window to an image using a dots per inch resolution. bitsPerPixel is the color depth. Not all image types support all color depths. If the color depth specified is not supported by the specified image type, then Origin will use the best matching color depth supported by the specified image type. compression is the type of compression to use. Not all formats support compression. JPG can be from 2 to 255. TIF can be 0 = none, 1 = packbits, 2 = LZW (if enabled) The destination file name is specified in image.fileName$. Example: Image.FileName$ = "myimage.bmp"; Image.Export.PageDPI( BMP, 96, 24, 0 );
image.export.pagePixel(imageType, widthInPixels, heightInPixels, bitsPerPixel, compression) | Export the active graph or layout window to an image using a width and height in pixel resolution. bitsPerPixel is the color depth. Not all image types support all color depths. If the color depth specified is not supported by the specified image type, then Origin will use the best matching color depth supported by the specified image type. compression is the type of compression to use. Not all formats support compression. JPG can be from 2 to 255. 2 is high quality, low compression. 255 is low quality, high compression. TIF can be 0 = none, 1 = packbits, 2 = LZW (if enabled) The destination file name is specified in image.fileName$. Example: Image.FileName$ = "myimage.bmp"; Image.Export.PagePixel( BMP, 640, 480, 24, 0 );

Image.Export SubObject

The image.export object provides script access for exporting graphs to graphic files. It also provides script access for exporting a matrix to a raster graphic image file.

Object type: External

Properties:

Methods:


Image.Import SubObject

Method | Description
image.import.matrix(matrixName) | Import an image into a matrix. matrixName is the name of the destination matrix window. The source image file is specified in image.fileName$. Example:
image.import.object(winName, objName, replace) | Add an image to a graph or a layout page. winName defaults to the active window objName defaults to a DIB (Origin's internal default). replace 0 = no replacement (default); 1 = replacement. The position (and size) of the image must be managed by the user. The file can be any of the supported image file types. If you opt NOT to replace an existing object (replace = 0), then a new, enumerated object is created. If you DO opt to replace an existing object, then you need to refresh after the replacement. Note that the replacement actually deletes the old object and creates a new one of the same name. This means the location is not preserved. Example:

image.fileName$ = Example.bmp;

image.import.matrix(Matrix1);

getfile *.bmp; // get a file

image.filename$=%B%A; // need to setup the image object

image.import.object(Graph1,MyObject,0);

getfile *.bmp; // get another file

image.filename$=%B%A; // need to setup the image object

image.import.object(Graph1,MyObject,0); // do not replace - creates a "MyObject1"

getfile *.bmp; // get another file

image.filename$=%B%A; // need to setup the image object

image.import.object(Graph1,MyObject,1); // replace MyObject

doc -uw; // refresh to see the replacement

Image.Import SubObject

The image.import object provides script access for importing graphic image files.

Object type: External

Methods:


Image.FileDlg SubObject

Property | Access | Description
image.fileDlg.title$ | Read/write, string | Dialog box's title/caption. If set to "", then Windows default captions are used.
image.fileDlg.path$ | Read/write, string | Default and ending path.
image.fileDlg.fileName$ | Read/write, string | Default and ending file name.
image.fileDlg.fileTypes$ | Read/write, string | Image types to display in the dialog box's "Files of type" list. This should be set to a list of image types returned by the image.getExtList() method.
image.fileDlg.fileType | Read/write, numeric | The index of the default and ending image type in the dialog box's "Files of type" list.
image.fileDlg.preview | Read/write, numeric | Set to 1 to enable or 0 to disable the dialog box's preview window.
Method | Description
image.fileDlg.open( [strVar] ) | Show the Open dialog box. If the optional strVar is specified, then the string variable will contain the full file name if the dialog box closes on OK or Open. Example:

Image.FileDlg.Open();

Image.FileDlg SubObject

The image.fileDlg object provides script access to the import image dialog box.

Object type: External

Properties:

Methods:


Ini

[SectionName]

KeyName = StringOrNumber

Property | Access | Description
ini.file$ | Read/write, string | A string with the file name to be accessed by the ini object. The Origin directory is assumed if no path is specified.
ini.get.fileName$ | N/A | Use ini.file$. This property is provided for backward compatibility only.
ini.get.key$ | N/A | This property is no longer in use.
ini.get.section$ | N/A | This property is no longer in use.
ini.key$ | Read/write, string | A string with the key name to be accessed by the ini object.
ini.keyNamekeyNumber$ | Read, string | Returns the name of keyNumber for section ini.getSection(sectionName). Example: %A = ini.keyName1$ //returns name of first key in %A.
ini.keyNum | Read, numeric | Returns the number of keys for section ini.getSection(sectionName).
ini.keyValuekeyNumber$ | Read, string | Returns the value of keyNumber for section ini.getSection(sectionName). Example: %A = ini.keyValue1$ //returns value of first key in %A.
ini.section$ | Read/write, string | A string with the section name to be accessed by the ini object.
ini.sectionName.keyName | Read/write, numeric | Read or write a value in a file. KeyNames are created if they do not exist.
Method | Description
ini.check(SectionName, KeyName) | Returns 0 if the sectionName or keyName exists, otherwise returns 1 and creates the sectionName and/or keyName. The keyName is set to 0 when created.
ini.get(OGIFilename) | Link the contents of an OGI file to Origin objects. The destination objects are determined by the OGI section names. If a section name is prefixed with an “_@”, then the name following the prefix identifies a destination object. The section’s entry names determine the properties to link. All entries are linked. There is no linking prefix for property names. Section names that are not prefixed with an “_@” are skipped.
ini.getSection(SectionName) | Returns the number of keys in SectionName.
ini.getStr(strvar, default, key, section, file) | This method accesses the INI file, section, and key specified in the properties. These can be used for accessing section and key names with spaces or other characters not allowed in LabTalk object/property names. strvar = variable to receive string default = string to return if key not found or blank key = key name. If blank use the value of the Ini.Key$ property. section = section name. If blank use the value of the Ini.Key$ property. file = file name. If blank use the value of the Ini.Key$ property.
ini.setStr(value, key, section, file) | This method accesses the INI file, section, and key specified in the properties. These can be used for accessing section and key names with spaces or other characters not allowed in LabTalk object/property names. value = value to assign to key. key = key name. If blank use the value of the Ini.Key$ property. section = section name. If blank use the value of the Ini.Key$ property. file = file name. If blank use the value of the Ini.Key$ property.

Ini

The ini object allows you to access any files that are formatted as INI files which include sections enclosed in square brackets and key names assigned to values.

Example:

Object type: Utility

Properties:

Methods:


Integ

Property | Access | Description
integ.area | Read only, numeric | Area of the integration.
integ.dx | Read only, numeric | Half width of the peak.
integ.x0 | Read only, numeric | X value of y0.
integ.x1 | Read only, numeric | Beginning X.
integ.x2 | Read only, numeric | Ending X.
integ.y0 | Read only, numeric | Maximum height (measured from the baseline if present, otherwise measured from zero).

  • The following script performs an integration from zero on the active data plot. The integration results are printed to the Script window.

integ %C;

if (mks1 >= 0)

{

i1 = mks1;

i2 = mks2;

}

else

{

get %C -b i1;

get %C -e i2;

}

type -a "Integ of %C from zero";

type "i = $(i1) --> $(i2)";

type "x = $(integ.x1) --> $(integ.x2)";

type "Area\tPeak at\tWidth\tHeight";

type "$(integ.area)\t$(integ.x0)\t$(integ.dx)\t$(integ.y0)";

Integ

The integration results from the integrate command are placed in the following integ object properties.

Object type: Utility

Properties:

Examples:


Layer

[winName!]layer[n].property =

WinName! is optional. If winName! is not specified, a layer in the active window is affected.

n is the layer number. If n is not specified, the active layer is used.

Property | Applies To | Access | Description
layer.3DCoor | graphs | Read/write, numeric | Coordinate system: 1 = right-hand system, 0 = left-hand system.
layer.border | graphs | Read/write, numeric | Layer border pattern: 0 = off, 1 = shadow, 2 = marble, 3 = white out, 4 = black out.
layer.bounds.height | N/A | N/A | Not currently implemented.
layer.bounds.left | N/A | N/A | Not currently implemented.
layer.bounds.top | N/A | N/A | Not currently implemented.
layer.bounds.width | N/A | N/A | Not currently implemented.
layer.color | graphs, worksheets | Read/write, numeric | Layer or worksheet heading color. Numbers from the color list, or transparent (0). The color() function can be used, as in: layer.color = color(blue);
layer.disp | graphs | Read/write, numeric | Display of column or bar graphs with zero values: 0 = do not show zero-valued columns or bars as a line, 1 = show zero-valued columns or bars as a line.
layer.factor | graphs | Read/write, numeric | Set scaling factor as on the Display tab of the layer's Plot Details dialog box.
layer.fixed | graphs | Read/write, numeric | Fixed factor scale of elements: 1 = enable, 2 = disable. Same as on the Display tab of the layer's Plot Details dialog box.
layer.height | graphs | Read/write, numeric | Height of the layer frame, measured in units specified by layer.unit.
layer.include.group | graphs, worksheets | Read/write, numeric | Used when the layer.include() method is operating on a vector. 1 = group and 0 = ungroup.
layer.include.useAll | graphs, worksheets | Read/write, numeric | Used when adding datasets with the layer.include() method in a box chart. 1 = disregard column designations, 0 = use column designations.
layer.is3D | graphs | Read only, numeric | Returns 1 if the layer is from a 3D plot type (3D charts, 3D surfaces, and 3D wire frames). Otherwise, returns 0.
layer.left | graphs | Read/write, numeric | Distance from the frame to the left edge of the page. Measured in units specified by layer.unit.
layer.link | graphs | Read/write, numeric | Linked layer number, 0 if no link.
layer.name$ | worksheets | Read/write, string | The active layer name. Useful when working with a workbook with multiple sheets.
layer.period | N/A | N/A | This property is no longer in use.
layer.plot | graphs | Read/write, numeric | Active data plot number in the layer.
layer.showData | graphs, worksheets | Read/write, numeric | Display of data plots and worksheet cell values: 1 = show, 0 = hide.
layer.showLabel | graphs, worksheets | Read/write, numeric | Display of labels and other objects: 1 = show, 0 = hide. Unlike objects hidden with the Visible check box in the Label Control dialog box, all labels remain selectable.
layer.showx layer.showy | graphs, worksheets | Read/write, numeric | Display of X and Y axes, and row and column headings: 1 = show, 0 = hide.
layer.tickL | graphs | Read/write, numeric | Tick length in units of .1 of a point. When you set this property, it sets the tick length for all the ticks in the layer. When you read this property, it returns the tick length for the first displayed X axis in the layer.
layer.tickW | graphs | Read/write, numeric | Tick thickness. See layer.tickL for read and set conventions.
layer.top | graphs | Read/write, numeric | Distance from the frame to the top edge of the page. Measured in units specified by layer.unit.
layer.unit | graphs | Read/write, numeric | Layer frame measurement units: 1 = % page, 2 = inches, 3 = cm, 4 = mm, 5 = pixel, 6 = points, and 7 = % of linked layer.
layer.width | graphs | Read/write, numeric | Width of the layer frame, measured in units specified by layer.unit.
Method | Description
layer.include(Dataset [,PlotType]) | Dataset is the name of the dataset to be added to the active graph layer. PlotType (optional) is the numeric value for the desired graph type. For a list of possible PlotType values, see the worksheet command. If PlotType is not included, the default data plot type for the active graph window is used.
layer.include(Vector, PlotType, WksName) | Allows the use of object vectors as arguments. An object vector is a special string array. In Origin, the only object vector is wks.cname$ which is a read only property. In OriginPro, the ComboBox and ListBox objects include the object vector v. PlotType (optional) is the numeric value for the desired graph type. For a list of possible PlotType values, see the worksheet command. If PlotType is not included, the default data plot type for the active graph window is used. WksName is the dataset source worksheet.
layer.plotxy(Xdataset, Ydataset[, PlotType]) | Plot the specified X dataset and Y dataset into the active layer. (This method only works with the active layer.) Both datasets must come from the same worksheet. Worksheet column designations are disregarded. To plot the data into a specific template, include PlotType. For the PlotType values for the graph templates, see the worksheet command.

  • This script changes the color of layer 1 in the Graph1 window to green.

  • This (Script window) script sets layer 2 of the Graph1 window active, and then types the height of the layer 2 frame to the Script window.

  • This script plots Data1_B as a column plot in the active layer.

Graph1!layer1.color = color(green);

Graph1!page.active = 2;

layer.height = ;

Layer.include(Data1_B, 203);

Layer

The layer object controls the appearance of the specified (or active) layer on the page. The layer object contains the axis sub-object. The axis object also contains sub-objects.

Object type: Window

Properties:

Methods:

Examples:


Layer.Axis

[winName!]Layer[n].axis.property =

WinName! Is optional. If winName! Is not specified, an axis in the active graph window is affected.

n is the layer number. If n is not specified, the active layer is used.

Axis is the axis specification: X is the bottom X axis, X2 is the top X axis, Y is the left Y axis, Y2 is the right Y axis, Z is the front Z axis, and Z2 is the back Z axis.

Property | Access | Description
layer.axis.atZero | Read/write, numeric | Display a straight line at Y = 0 for an X axis, X = 0 for a Y axis: 1 = show, 0 = hide.
layer.axis.color | Read/write, numeric | Axis color. Numbers from the color list, or transparent (0). The color() function can be used, as in: layer.x.color = color(blue);
layer.axis.decPlaces | Read/write, numeric | Set the number of decimal places displayed in the tick labels.
layer.axis.firstTick | Read/write, numeric | First tick value.
layer.axis.from | Read/write, numeric | First axis scale value.
layer.axis.inc | Read/write, numeric | Major tick increment.
layer.axis.labelSubtype | Read/write, numeric | Tick label format: 1 = decimal, 2 = scientific, 3 = engineering (1K), and 4 = decimal (1,000).
layer.axis.labelType | Read/write, numeric | Tick label type: 1 = numeric, 2 = text from dataset, etc.
layer.axis.link | Read/write, numeric | Link type for the specified axis residing in a layer that is linked with the layer.link property. 0 = no link, 1 = one-to-one link. (Note that you can not set a custom link through script.)
layer.axis.majorTicks | Read/write, numeric | Number of major ticks. 0 = default number of ticks.
layer.axis.minorTicks | Read/write, numeric | Number of minor ticks.
layer.axis.opposite | Read/write, numeric | Line opposite the axis: 1 = enable, 0 = disable.
layer.axis.rescale | Read/write, numeric | Rescale type: 1 = manual, 2 = normal, 3 = auto, 4 = fixed from, and 5 = fixed to.
layer.axis.rescaleMargin | Read/write, numeric | % of data range used to produce a margin around data. Select Plot:Rescale to Show All to view the change.
layer.axis.reverse | Read/write, numeric | Reverse axis direction: 1 = enable, 0 = disable.
layer.axis.showAxes | Read/write, numeric | Axis and tick display: 0 = hide axes, 1 = show ticks on axis, 2 = show ticks on opposite axis, and 3 = show ticks on both axes.
layer.axis.showGrids | Read/write, numeric | Grid display: 0 = hide grids, 1 = show major grids, 2 = show minor grids, and 3 = show both grids.
layer.axis.showLabels | Read/write, numeric | Show tick labels on axes: 0 = disable, 1 = enable, 2 = show the right or top labels, 3 = show both top and bottom or left and right labels.
layer.axis.space | Read/write, numeric | Same as layer.axis.type.
layer.axis.thickness | Read/write, numeric | Width of axis in points.
layer.axis.ticks | Read/write, numeric | Controls the major and minor ticks as follows: 0 = no ticks, 1 = major in, 2 = major out, 4 = minor in, and 8 = minor out. Numbers can be combined, so 3 = major ticks in and out.
layer.axis.TicksByData$ | Read/write, numeric | Specifies a dataset to control tick mark position and labels.
layer.axis.to | Read/write, numeric | Last axis scale value.
layer.axis.type | Read/write, numeric | Axis scale type: 0 or 1 = linear, 2 = log10, 3 = probability, 4 = probit, 5 = reciprocal, 6 = offset reciprocal, 7 = logit, 8 = ln, and 9 = log2.
layer.axis.whiteout | Read/write, numeric | White out around tick labels: 1 = enable, 0 = disable.

  • This (Script window) script types to the Script window the first value of the left Y axis in the second layer of the active window.

  • This script sets the major ticks out and minor ticks in for the top X axis in the first layer of the Graph2 window.

Layer2.y.from =

Graph2!layer1.x2.ticks = 6;

Layer.Axis

The axis object is a sub-object of the layer object. The axis object also contains sub-objects: break, grid, and label.

Object type: Window

Properties:

Examples:


Layer.Axis.Break

[winName!]layer[n].axis.break.property =

WinName! Is optional. If winName! Is not specified, an axis break in the active graph window is affected.

N is the layer number. If n is not specified, the active layer is used.

Axis is the axis specification: X is the bottom X axis, X2 is the top X axis, Y is the left Y axis, Y2 is the right Y axis, Z is the front Z axis, and Z2 is the back Z axis.

An axis break must exist for the following properties to be valid.

Property | Access | Description
layer.axis.break.from | Read/write, numeric | Starting axis break value.
layer.axis.break.inc | Read/write, numeric | Major tick increment after the break.
layer.axis.break.minorTicks | Read/write, numeric | Number of minor ticks after the break.
layer.axis.break.space | Read/write, numeric | Logarithmic scale after axis break: 1 = enable, 0 = disable.
layer.axis.break.to | Read/write, numeric | Ending axis break value.

  • This (Script window) script types to the Script window the value of the beginning of the axis break on the top X axis in layer 1 of the Graph2 window.

  • This script checks if the bottom X axis in layer 1 of the active window has a logarithmic scale. If so, the scale is set to logarithmic after the break.

Graph2!.layer1.x2.break.from =

If (layer1.x.type == 2)

{

layer1.x.break.space = 1;

};

Layer.Axis.Break

The break object is a sub-object of the (layer) axis object.

Object type: Window

Properties:

Examples:


Layer.Axis.Grid

Grid lines can be accessed using the following syntax:

[winName!]layer[n].axis.grid.property =

WinName! is optional. If winName! is not specified, grids in the active graph window are affected.

N is the layer number. If n is not specified, the active layer is used.

Axis is the axis specification: X is the bottom X axis, X2 is the top X axis, Y is the left Y axis, Y2 is the right Y axis, Z is the front Z axis, and Z2 is the back Z axis.

Property | Access | Description
layer.axis.grid.majorColor | Read/write, numeric | Major grid line color. Numbers from the color list, or transparent (0). The color() function can be used, as in: .majorcolor = color(blue)
layer.axis.grid.majorType | Read/write, numeric | Major grid line type number: 1 = solid, 2 = dash, 3 = dot, etc., from the Line Type drop down list.
layer.axis.grid.majorType | Read/write, numeric | Major grid line type number: 1 = solid, 2 = dash, 3 = dot, etc., from the Line Type drop down list.
layer.axis.grid.majorWidth | Read/write, numeric | Width of the major grid lines in points.
layer.axis.grid.minorColor | Read/write, numeric | Minor grid line color. Numbers from the color list, or transparent (0). The color() function can be used, as in: .minorcolor = color(blue)
layer.axis.grid.minorType | Read/write, numeric | Minor grid line type number: 1 = solid, 2 = dash, 3 = dot, etc., from the Line Type drop down list.
layer.axis.grid.minorWidth | Read/write, numeric | Width of the minor grid lines in points.

  • This (Script window) script types to the Script window the width of the major grid lines of the X axis of layer 3 of the active window.

Layer3.x.grid.majorwidth =

  • The next script sets the color of the minor grid lines of the Y axis in the first layer of the Graph3 window to be purple.

Graph3!layer1.y.grid.minorcolor = color(purple);

Layer.Axis.Grid

The grid object is a sub-object of the (layer) axis object. It is also a window object.

Object type: Window

Properties:

Examples:


Layer.Axis.Label

Tick labels can be accessed using the following syntax:

[winName!]layer[n].axis.label.property =

WinName! Is optional. If winName! Is not specified, tick labels in the active graph window are affected.

N is the layer number. If n is not specified, the active layer is used.

Axis is the axis specification: X is the bottom X axis, X2 is the top X axis, Y is the left Y axis, Y2 is the right Y axis, Z is the front Z axis, and Z2 is the back Z axis.

Property | Access | Description
layer.axis.label.bold | Read/write, numeric | Bold the tick labels: 1 = enable, 0 = disable.
layer.axis.label.color | Read/write, numeric | Tick label color. Numbers from the color list, or transparent (0). The color() function can be used, as in: .majorcolor = color(blue)
layer.axis.label.dataset$ | Read/write, string | Dataset name if the tick label is from a dataset. To read, assign the value to a string variable.
layer.axis.label.decPlaces | Read/write, numeric | Number of decimal points to display. To disable, set to -1.
layer.axis.label.divideBy | Read/write, numeric | Divide tick labels by this factor before displaying.
layer.axis.label.font | Read/write, numeric | Font number. Use the font() function, as in: layer1.x.label.font = font(arial); to set to Arial font.
layer.axis.label.numFormat | Read/write, numeric | Numeric display format: 1 = decimal without commas, 2 = scientific, 3 = engineering, and 4 = decimal with commas (for date).
layer.axis.label.offsetH | Read/write, numeric | Horizontal offset from axis, in % of current font.
layer.axis.label.offsetV | Read/write, numeric | Vertical offset from axis, in % of current font.
layer.axis.label.pre$ | Read/write, string | A string to display before each tick label. To delete the prefix, set .pre$ = “”;.
layer.axis.label.pt | Read/write, numeric | Size of the tick labels in pts.
layer.axis.label.rotate | Read/write, numeric | Tick label rotation, in degrees.
layer.axis.label.suf$ | Read/write, string | A string to display after each tick label. To delete the suffix, set .suf$ = “”;.
layer.axis.label.timeFormat | Read/write, numeric | Tick label time and date format. If layer.axis.label.type = 4, 1 = first selection from date format drop-down list, 2 = second selection from date format drop-down list, etc. If layer.axis.label.type = 3, 1 = first selection from time format drop-down list, 2 = second selection from time format drop-down list, etc.
layer.axis.label.type | Read/write, numeric | Tick label type: 1 = numeric, 2 = text from dataset, 3 = time, 4 = date, 5 = month, 6 = day of the week, 7 = column headings, and 8 = dataset indexed as tick #.
layer.axis.label.whiteout | Read/write, numeric | Background for tick labels: 0 = transparent background, 1 = white background.

  • The following script displays the tick labels of the left Y axis in layer 2 of the Graph1 window in scientific format.

Graph1!layer2.y.label.numformat = 2;

  • The next script checks the tick label type of the bottom X axis of the active layer in the active window. If the return value indicates the labels display text from a dataset, the script returns the name of the dataset to the Script window.

If (layer.x.label.type == 2)

{

%A = layer.x.label.dataset$;

%A = ;

};

Layer.Axis.Label

The (tick) label object is a sub-object of the (layer) axis object. It is also a window object.

Object type: Window

Properties:

Examples:


Property | Access | Description
layer.plotn.boxchart.binBegin | Read/write, numeric | Minimum of the bin range.
layer.plotn.boxchart.binEnd | Read/write, numeric | Maximum of the bin range.
layer.plotn.boxchart.binSize | Read/write, numeric | Size of the bins.
layer.plotn.boxchart.boxRange | Read/write, numeric | Box range, as in no box, SE, SD, Perc 25, 75, etc. 1 = no box, 2 = SE, 3 = SD, etc. See the Range drop-down list on the Plot Details Box tab.
layer.plotn.boxchart.type | Read/write, numeric | Type of box chart, as in box, data, box and data, etc. 1 = box, 2 = data, 3 = box and data, etc. See the Type drop-down list on the Plot Details Box tab.
layer.plotn.boxchart.width | Read/write, numeric | Box width, in points.

Layer.Plotn.BoxChart

The layer.plotn.boxchart object is a sub-object of the layer object. It provides script access to the box chart options in the Plot Details dialog box.

Note: Replace n with the data list number of the box chart you want to edit.

Object type: Window

Properties:


Limit

Property | Access | Description
limit.iMax | Read only, numeric | Corresponding index for maximum Y value.
limit.iMin | Read only, numeric | Corresponding index for minimum Y value.
limit.size | Read only, numeric | Total size (number of points) for dataset.
limit.xMax | Read only, numeric | Maximum X value.
limit.xMin | Read only, numeric | Minimum X value.
limit.yMax | Read only, numeric | Maximum Y value.
limit.yMin | Read only, numeric | Minimum Y value.

  • This script gets the limits of the active dataset, and then creates a new worksheet with an X and Y dataset based on the limit object properties.

Limit %C; //Get limits of current dataset

win -t data; //Create a new worksheet

%(%H,1) = data(limit.xmin,limit.xmax,1);

//Set new X data to range from Xmin to Xmax in steps of 1

%(%H,2) = data(limit.ymin,limit.ymax,1);

//Set new Y data to range from Ymin to Ymax in steps of 1

Limit

The limiting values resulting from the limit command are placed in the following limit object properties.

Object type: Utility

Properties:

Examples:


LR

Property | Access | Description
lr.a | Read only, numeric | Intercept.
lr.b | Read only, numeric | Slope.
lr.n | Read only, numeric | Number of points used in the fitting.
lr.r | Read only, numeric | Correlation coefficient.
lr.sd | Read only, numeric | Standard deviation of the fit.
lr.sda | Read only, numeric | Standard deviation of the intercept.
lr.sdb | Read only, numeric | Standard deviation of the slope.

  • This script performs a linear fit of dataset Data1_B beginning at the first data point and continuing until the end of the linear region. It types the resulting slope and intercept to the Script window.

Lr Data1_B;

type “Slope is $(lr.b)”;

type “Intercept is $(lr.a)”;

LR

Results generated from the (linear regression) lr command are placed in the following lr object properties.

For further control when performing linear regression, see the stat object.

Object type: Utility

Note: When you use the lr -b dataset or lr -e dataset commands to perform a linear regression on the beginning (b) or ending (e) linear region of dataset, the dataset is automatically searched for linearity, as determined by the following parameters that can be modified in the ORGSYS.CNF file:

lr.maxLRange: The percentage of the entire data range to perform a linear regression on. For example, when lr.maxLRange = 40 (default) and dataset has 20 points, lr -b dataset performs a linear regression on the first 8 points in dataset, if these points meet the requirements of the lr.chkLinearR parameter. Thus, if the fourth point is outside the tolerance set by lr.chkLinearR, then the lr -b dataset command would only perform a linear regression on the first three points in dataset.

lr.chkLinearR: Sets the amount of tolerance in the automatic determination of linear segments.

Properties:

Examples:


Macro

Property | Access | Description
macro.nArg | Read only, numeric | Inside any macro, this property contains the value for the number of arguments.

  • This script defines a macro called TypeArgs. If three arguments are passed to the TypeArgs macro, the macro types the three arguments to the Script window.

Def TypeArgs

{

if (macro.narg != 3)

{

type “Error! You must pass 3 arguments!”;

}

else

{

type “The first argument passed was %1.”;

type “The second argument passed was %2.”;

type “The third argument passed was %3.”;

}

};

If you define the TypeArgs macro as in the example, and then type the following in the Script window:

TypeArgs One;

Origin returns the following to the Script window:

Error! You must pass 3 arguments!

If you define the TypeArgs macro as in the example, and then type the following in the Script window:

TypeArgs One Two Three;

Origin returns the following to the Script window:

The first argument passed was One.

The second argument passed was Two.

The third argument passed was Three.

Macro

The macro object contains one property which, when inside a macro, contains the value for the number of arguments.

Object type: Utility

Properties:

Examples:


Mat

Property | Access | Description
mat.edgeView.xeCol$ | Read/write, string | Used with the mat.edgeview() method. This is the X column in the mat.edgeview.xeWksName$ worksheet.
mat.edgeView.xeWksName$ | Read/write, string | Used with the mat.edgeview() method. This is the worksheet where the X projection is stored.
mat.edgeView.yeCol$ | Read/write, string | Used with the mat.edgeview() method. This is the worksheet where the Y projection is stored.
mat.edgeView.yeWksName$ | Read/write, string | Used with the mat.edgeview() method. This is the worksheet where the Y projection is stored.
mat.edgeView.zxeCol$ | Read/write, string | Used with the mat.edgeview() method. This is the Y column in the mat.edgeview.xeWksName$ worksheet. This column contains the maximum Y along that X.
mat.edgeView.zxsCol$ | Read/write, string | Used with the mat.edgeview() method. This is a column in the mat.edgeview.xeWksName$ worksheet. This column contains the sum of all Ys along that X.
mat.edgeView.zyeCol$ | Read/write, string | Used with the mat.edgeview() method. This is the X column in the mat.edgeview.xeWksName$ worksheet. This column contains the maximum X along that Y.
mat.edgeView.zysCol$ | Read/write, string | Used with the mat.edgeview() method. This is a column in the mat.edgeview.xeWksName$ worksheet. This column contains the sum of all Xs along that Y.
mat.exp2m.cols | Read/write, numeric | When converting a worksheet to a matrix using the mat.exp2m() method, this property value controls the number of columns in the matrix. The number of columns in the matrix is determined by the number of columns in the worksheet multiplied by this property value.
mat.expand.col | Read/write, numeric | Column expansion factor when using the mat.expand() method.
mat.expand.row | Read/write, numeric | Row expansion factor when using the mat.expand() method.
mat.grid.average | Read/write, numeric | Used in correlation gridding. Average all points in a grid unit: 1 = enable, 0 = disable.
mat.grid.dCluster | Read/write, numeric | Used in correlation gridding. When mat.grid.average is enabled, this property represents the minimum number of cluster points used in a given direction. The maximum value allowed is 5 and the minimum is 3.
mat.grid.gcSize | Read/write, numeric | Size of a grid unit in the X direction. Choosing a smaller size gives better results but increases calculation time.
mat.grid.grSize | Read/write, numeric | Size of a grid unit in the Y direction. Choosing a smaller size gives better results but increases the calculation time.
mat.grid.maxSubpts | Read/write, numeric | The maximum number of points (raw data or grid units) allowed in gridding.
mat.grid.maxUseAll | Read/write, numeric | Used in correlation gridding. When the total number of data points is less than this value, all the data points are used in gridding. This speeds up the gridding process when the total number of points is less than 64 (default value).
mat.grid.minQuadra | Read/write, numeric | Used in correlation gridding. The minimum number of points used in a given direction in correlation gridding when mat.grid.average is disabled. The maximum value is 5 and the minimum value is 3.
mat.grid.nMatCols | Read/write, numeric | Number of columns in the matrix after gridding.
mat.grid.nMatRows | Read/write, numeric | Number of rows in the matrix after gridding.
mat.grid.radius | Read/write, numeric | If the distance between a data point and the gridding point is larger than this value, the contribution of this data point is set to a minimal value.
mat.grid.rule | Read/write, numeric | Used in weighted average gridding. This parameter determines the weight as a function of the distance between a data point and the gridding point: 1 = linear, 2 = power, 3 = logarithmic, 4 = exponential.
mat.grid.smooth | Read/write, numeric | Used in correlation gridding. Smaller values give smoother results.
mat.interpolate | Read/write, numeric | Control whether or not interpolation is used with the mat.profile() and the mat.segment() methods: 0 = no interpolation, non-zero = interpolation.
mat.interpolatePts | Read/write, numeric | Number of points to use for interpolating with the mat.profile() and the mat.segment() methods. If set to -1, then the matrix number of columns or rows is used.
mat.matName$ | Read/write, string | Name of the active matrix. Specify the active matrix before executing a mat object method.
mat.profile.angle | Read/write, numeric | Used with the mat.profile() method - for a profile along a line with a preset slope. This is the angle with X axis (in radians). The default value is PI/4.
mat.profile.hSection | Read/write, numeric | Used with the mat.profile() method. This is the number of points in the horizontal profile.
mat.profile.hwksName$ | Read/write, string | Used with the mat.profile() method. This is the worksheet that stores the horizontal profile.
mat.profile.hXCol | Read/write, numeric | Used with the mat.profile() method. This is the worksheet column that stores the X horizontal profile.
mat.profile.hZCol | Read/write, numeric | Used with the mat.profile() method. This is the worksheet column that stores the Z horizontal profile.
mat.profile.sSection | Read/write, numeric | Used with the mat.profile() method. This is the number of points in the slanted profile.
mat.profile.vSection | Read/write, numeric | Used with the mat.profile() method. This is the number of points in the vertical profile.
mat.profile.vWksName$ | Read/write, string | Used with the mat.profile() method. This is the worksheet that stores the vertical profile.
mat.profile.vYCol | Read/write, numeric | Used with the mat.profile() method. This is the worksheet column that stores the Y vertical profile.
mat.profile.vZCol | Read/write, numeric | Used with the mat.profile() method. This is the worksheet column that stores the Z vertical profile.
mat.res, mat.resolution | Read/write, numeric | When converting a regular worksheet to a matrix, small variations in the data are allowed. The tolerance for these variations is determined by this property. The default value is 10, which allows up to a 10% variation in the step size in X or Y. If you have very small variations of data, the default value may be too large (the conversion would still go through). Likewise, if you have very large fluctuations in your data, then the default value could be too small (the conversion will fail). Calculate a value appropriate for your data using: (maximum variation from mean step size * 100 / mean step size)
mat.shrink.col | Read/write, numeric | Column shrinkage factor when using the mat.shrink() method.
mat.shrink.row | Read/write, numeric | Row shrinkage factor when using the mat.shrink() method.
mat.type | Read/write, numeric | Used in conversion from a matrix to a worksheet in the mat.m2xyz() method. 0 = X column first, 1 = Y column first.
mat.wksName$ | Read/write, string | Name of the active worksheet. (Used with the mat.profile() method. This is the worksheet that stores the slanted profile.)
mat.xCol | Read/write, numeric | The X column number in the worksheet. (Used with the mat.profile() method. This is the worksheet column that stores the X slanted profile.)
mat.yCol | Read/write, numeric | The Y column number in the worksheet. (Used with the mat.profile() method. This is the worksheet column that stores the Y slanted profile.)
mat.zCol | Read/write, numeric | The Z column number in the worksheet. (Used with the mat.profile() method. This is the worksheet column that stores the Z slanted profile.)

Method

Description

mat.edgeView()

Plot the maximum values of X along a given Y, and Y along a given X. You can also specify a column (optional) to compute and store the sum of all Y along a particular X and the sum of all X along a particular Y.

mat.exp2m()

Expand all columns of the active worksheet (mat.wksName$) by a factor and convert it to a matrix (mat.matName$). The expansion factor is determined by mat.exp2m.cols. For example, if the active worksheet has 3 columns and mat.exp2m.cols = 2, the resultant matrix will have 6 columns.

mat.expand()

Expand the active matrix (mat.matName$). The expansion factor is determined by mat.expand.row and mat.expand.col.

mat.grid(coo)

Correlation gridding.

mat.grid(ave)

Weighted average gridding.

mat.grid(check)

Check and set the consistency and validity of gridding smoothness vs. minimum points per direction.

mat.integrate([varName])

Integrate the matrix by starting from zero. If varName is included, the integration result is stored in varName. If not included, the integration result is output to the Script window.

mat.inv()

Inverse the active matrix (mat.matName$).

mat.m2w()

Convert the active matrix (mat.matName$) to a worksheet (mat.wksName$) by the columns and rows directly. The worksheet looks exactly like the original matrix, but the X Y coordinate mapping information is lost.

mat.m2xyz()

Convert the active matrix (mat.matName$) to a worksheet (mat.wksName$). This method creates a worksheet with X, Y and Z columns. The cell values of the matrix are converted to a Z column. The corresponding X and Y column values in the worksheet are set by the X and Y coordinate mapping information in the matrix.

mat.multiply(matrix1, matrix2)

Multiply matrix1 by matrix2. Mat.matName$ stores the name of the target matrix. If this matrix is matrix1 or matrix2, the input matrix is overwritten.

mat.profile(x1, y1)

Provides three profiles:

1) The horizontal profile y = y1.

2) The vertical profile x = x1.

3) The profile along a line with a preset slope passing through (x1, y1). Set the angle with the X axis in radians using the mat.profile.angle property. The default angle is PI/4.
The profiles are stored in the following worksheets:

1) Horizontal: mat.profile.hwksname, mat.profile.hXcol, mat.profile.hZcol.

2) Vertical: mat.profile.vwksname, mat.profile.vYcol, mat.profile.vZcol.

3) Slanted: mat.wksname, mat.xcol, mat.ycol, mat.zcol.

The number of points in each profile can be accessed from mat.profile.hsection, mat.profile.vsection, and mat.profile.ssection. Specify use of interpolation with the mat.interpolate and the mat.interpolatePts properties.

mat.segment(x1, y1, x2, y2)

Find the profile between (x1, y1) and (x2, y2). The results are written to mat.wksName$. Control whether interpolation is used with the mat.interpolate and the mat.interpolatePts properties.

mat.shrink()

Shrink the active matrix (mat.matName$). The shrinkage factor is determined by mat.shrink.row and mat.shrink.col.

mat.w2m()

Convert the active worksheet (mat.wksName$) to a matrix (mat.matName$) by the columns and rows directly. The matrix looks exactly like the original worksheet.

mat.xyz2m()

Convert the active worksheet (mat.wksName$) to a matrix (mat.matName$). This method creates a matrix with cell values from the Z column. The X and Y coordinate mapping information in the matrix is from the corresponding X and Y column values in the worksheet.

  • This script converts a matrix to a worksheet using the matrix to regular XYZ format. The mat.type property determines the type of data transfer from the worksheet to the matrix. When mat.type = 0 or not specified (default), data copying follows the “X First” rule, i.e., the X axis of the matrix is the independent axis. When mat.type is any integer greater than zero, data copying follows the “Y First” rule.

  • This script converts a worksheet to a matrix using the regular XYZ to matrix format. X, Y, and Z columns for the matrix are specified within the worksheet. The X column contains the independent data. The Y column contains the dependent data. The Z column contains data that are to be placed in the corresponding cells in the matrix.

  • This script converts a matrix to a worksheet using the column-row format. The resultant worksheet is exactly the same as the matrix.

  • This script converts a worksheet to a matrix by correlation gridding.

  • Sample script for the mat.profile() method:

//Create a matrix

win -t mat;

//Set the dimensions to 10X10

matrix -ps DIM 10 10;

//Fill the cells of the matrix

(%H) = Data(1,100,1);

mat.matname$ = %H;

//Create an XYZ worksheet

win -t wks xyz;

mat.wksname$ = %H;

mat.type = 1;

//Convert the matrix to regular XYZ format

mat.m2xyz();

Note: %H is used only if the name of the window to be specified is the active window. Otherwise, specify the name of the window enclosed in double quotes, such as “data1” and “matrix1”.

mat.wksname$ = %H;

mat.xcol = 1;

mat.ycol = 2;

mat.zcol = 3;

//Create a new matrix

win -t mat;

mat.matname$ = %H;

//Convert the XYZ data to a matrix

mat.xyz2m();

Note: %H is used only if the name of the window to be specified is the active window. Otherwise, specify the name of the window enclosed in double quotes, such as “data1” and “matrix1”.

mat.matname$ = %H;

//Create a new worksheet

win -t wks;

mat.wksname$ = %H;

//Convert the matrix directly to a worksheet

mat.m2W();

mat.grid.nmatcols = 32;

mat.grid.nmatrows = 32;

mat.grid.grsize = 4;

mat.grid.gcsize = 4;

mat.grid.average = 0;

mat.grid.minquadra = 3;

mat.grid.radius = 2;

mat.grid.dcluster = 3;

mat.grid.smooth = .8;

mat.xcol = 1;

mat.ycol = 2;

mat.zcol = 3;

mat.wksname$ = %H;

sum(wcol(mat.xcol));

xmax = sum.max;

xmin = sum.min;

limit -r xmin xmax 8;

sum(wcol(mat.ycol));

ymax = sum.max;

ymin = sum.min;

limit -r ymin ymax 8;

win -t m;

matrix -ps x xmin xmax;

matrix -ps y ymin ymax;

mat.matname$ = %H;

mat.grid(coo);

Note: %H is used only if the name of the window to be specified is the active window. Otherwise, specify the name of the window enclosed in double quotes, such as “data1” and “matrix1”.

mat.matname$ = Matrix1;

mat.wksname$ = data1;

mat.xcol = data1_a;

mat.ycol = data1_b;

mat.zcol = data1_c;

mat.profile.hwksname$ = data2;

mat.profile.vwksname$ = data3;

mat.profile.hxcol = data2_a;

mat.profile.hzcol = data2_b;

mat.profile.vycol = data3_a;

mat.profile.angle = -PI/4;

mat.profile(7,7);

Mat

The mat object handles conversion between worksheets and matrices; mathematical operations on matrices such as inverse, transpose, computing the X and Y projections,and multiplication; data preparation such as gridding for 3D and contour plotting, and matrix profiling.

Object type: External

Properties:

Methods:

Examples:


Menu

Property | Access | Description
menu.lastExeID | Read only, numeric | Holds the ID number of the most recently executed menu command.
menu.lastID | Read only, numeric | Holds the ID number of the most recently created menu command.
Method | Description
menu.check(ID, num) | This method will only work for user-created menu commands. If num = 1, place a check mark next to the menu command with the specified menu ID. If num = 0, uncheck the menu command.
menu.cleanup() | Remove all menu modifications, including those made in configuration files. To recover configuration file modifications, select an option from Format:Menu.
menu.gray(ID, num) | Not currently implemented.
menu.itemDel(pos) | Delete the menu command at the specified pos position in the active menu.
menu.itemDelBelow(pos) | Delete the menu command at the specified pos position, and all the menu commands below it, from the active menu.
menu.rename(ID, name) | This method will only work for user-created menu commands. Rename the menu command with the specified menu ID to the specified name.

  • This script deletes the Paste menu command and all menu commands below it in the Edit menu.

  • This script creates a new menu command at the end of the Edit menu.

  • This script finds the ID of the most recently created menu command, and then executes the menu command.

Menu -w; //make the Worksheet menu bar active

menu ?Ed; //make the Edit menu active

menu.itemDelBelow(4);

Menu -P; //make the Layout menu bar active

menu ?Ed; //make the Edit menu active

Menu (My List) {type -b “my list”;};

// append My List menu command to the end of the Edit menu

MyId = menu.lastid;

// set the value of myID to the ID of the last menu command

menu -e myId;

// execute the menu command with ID ‘myId’

Menu

The menu object methods and properties are designed for menu manipulation. They are most effective when used together with the menu command.

The effects of the menu object methods may not be immediately apparent. It is sometimes necessary to make a different window type active before the result is visible. Alternatively, shrink Origin to an icon, then restore the application.

Menu manipulation requires exact specification of the desired menu bar, menu, and menu commands. For information on how to specify the active menu bar and the active menu, see the menu command.

Object type: Utility

Note: Menu manipulation requires exact specification of the desired menu bar, menu, and menu commands. For information on how to specify the active menu bar and the active menu, see the Menu command.

Properties:

Methods:

Examples:


NLSF

Property

Access

Descriptions

nlsf.cn

Read only, numeric

This is a vector value that stores values of the confidence interval for each parameter (Confidence Interval = Parameter Error * Chi-square Value). All the elements of this vector are shown in the ConfInter column of the Parameter worksheet.

nlsf.chiSqr

Read only, numeric

Read the reduced chi-square value. This value is computed during iterations.

nlsf.chiSqrErr

Read/write, numeric

Set the status of the Scale Errors with sqrt(reduced chi-square) check box on the Control Parameters dialog box. 0 = clear the check box. 1 = select the check box. For more information on this check box, see the Origin Help file.

nlsf.cod

Read only, numeric

Read the coefficient of determination (r^2 value). The COD value is computed at the end of a round of fitting iterations. For the mathematical definitions of COD, see the Origin Help file.

nslf.compile

Read/write, numeric

Report/control the state of the Compile Before Use check box located on the New Function / Edit Function tab of the NLSF: 0 = unchecked (do not compile), 1 = checked (compile) The current function is set from nlsf.func$.

nlsf.conf

Read/write, numeric

Set the confidence level value. For more information, see the Origin Help file.

nlsf.confCol$

Read/write, string

Same as nlsf.lconfcol$.

nlsf.constr$

Read/write, string

Set constraints to the fitting process. If the property is not set, the fitting module defaults to no constraints. If constraints are changed, use this property to set them again. To clear the constraint, use an empty string, i.e., nlsf.constr$ = "";. Because Origin always stores the constraints internally, this command may be necessary to clean up the memory.

nlsf.cor

Read only, numeric

Read the correlation coefficient which is computed at the end of a round of iterations.

nlsf.covar$

Read/write, string

Set a matrix that is used to store the variance-covariance matrix.

nlsf.curRow

Read/write, numeric

The current row number. Access this number in the function scripts. Note: versions prior to 3.0 store this value into the system variable i.

nlsf.dataBegin

Read/write, numeric

Set the beginning of the data range. The actual fitting is performed only on the data within this range. The default value is 1. However, when fitting from the menu, the fitting module automatically searches for the data range if it was set manually, or defaults to the entire column. For more information, see the Origin Help file.

nlsf.dataEnd

Read/write, numeric

Set the end of the data range. This value must be set if you fit from scripts, as its default value is 0.

nlsf.dataStep

Read/write, numeric

Set the data interval, which is defined as an incremental step size when only a subset of data points are used. This is a very useful feature when there are a large number of data points and you need a rough guess of the fit. 1 = every data point is used, 2 = every other data point is used, etc. When using script for fitting, this value is defaulted to 1. When you fit from the menu, this value is calculated so that only a limited number of data points are used. However, you may reset its value.

nlsf.derivStep

Read/write, numeric

Set the parameter change amount ( ) for calculating numeric derivatives. A smaller value gives higher precision but may cause numeric round-off errors. The default value is 0.005.

nlsf.dn

Read only, numeric

Read the dependency of the nth parameter.

nlsf.dof

Read only, numeric

Read the degree of freedom of the data and fitting function. For more information, see the Origin Help file.

nlsf.en

Read only, numeric

Read the standard error values of the nth parameter.

nlsf.err

Read only, numeric

Read the error code (or error message number). For more information, see the Origin Help file.

nlsf.fitColNum

Read only, numeric

Number of columns used for fitting.

nlsf.fitDatan$

Read/write, string

Read or set the full name(s) of the dependent variable(s). Note: You must assign the function to nlsf.func$ before you can assign the datasets to this property.

nlsf.fitWksName$

Read only, string

Read the name of the worksheet that contains the fitting datasets (columns).

nlsf.fType

Read only, numeric.

Read the internal ID of the function that is selected for fitting.

nlsf.func$

Read/write, string

Set the specified function as the fitting function. For example, nlsf.func$ = ”gauss”; sets the Gaussian function as the fitting function. Note: You must specify the function with this property before assigning nlsf.fitData$.

nlsf.funcCol$

Read/write, string

Set a column to store functional values (upon completion of the fitting session). This property can be used in conjunction with nlsf.xmode, nlsf.xpoints, nlsf.databegin, nlsf.dataend and nlsf.makecurve().

nlsf.funcx$

Read/write, string

Set a column as the X column to create datasets. These columns are used as the independent variables when creating the end results of a fitting session. This includes the fit curve, dataset and confidence and prediction bands. Refer to: nlsf.xmode and nlsf.makecurve().

nlsf.isBadData

Read only, numeric

Check the data: 1 = enable, 0 = disable.

nlsf.isBadFunc

Read only, numeric

Check the function selected for fitting: 1 = enable, 0 = disable.

nlsf.isDialogOpen

Read/write, numeric

Read/set the internal ID of the opened dialog box.

nlsf.keepParam

Read/write, numeric

Show if the parameters should be saved after closing the fitting session and restored before opening: 1 = enable, 0 = disable.

nlsf.lbn

Read/write, numeric

This is a vector value. For each parameter, it reads/sets the lower bound value. These are the values that are displayed in the edit boxes in the Parameter Constraints dialog box.

nlsf.lbxn

Read/write, numeric

This is a vector value. It reads/sets the sign of each low constraint. Value 0 corresponds to <=, value 2 corresponds to <, … These correspond to the button values displayed in the Parameter Constraints dialog box.

nlsf.lConfCol$

Read/write, string

Set a column that is used to store the values of the lower confidence band.

nlsf.ln

Read only, numeric

Read the lower confidence limit value of the nth parameter for a given confidence value (nlsf.conf).

nlsf.lPredCol$

Read/write, string

Set a column that is used to store the values of the lower prediction band.

nslf.maxIter

Read/write, numeric

Set the maximum number of iterations that will be performed.

nlsf.maxDerivStep

Read/write, numeric

The execution of fitting requires a calculation of derivatives of a selected function. If the function is user-defined, the derivative is calculated numerically (see the Origin Help file). In this case, the maximum value of the step for the numeric derivative must be set for a “flexible (non-fixed) step” regime. So nlsf.maxderivstep contains just this value. For user defined functions, this value is read and set in the Derivative Delta group of the Control Parameters dialog box.

nlsf.minDerivStep

Read/write, numeric

See nlsf.maxderivstep. This property is for the minimum value of the step.

nlsf.msgPrompt

Read/write, numeric

Set to suppress message prompts: 1 = show all message prompts, 0 = suppress all message prompts, 2 = suppress parameter mutual dependency messages.

nlsf.mu

Read/write, numeric

Set the value for diagonal magnification of the curvature matrix. This value is very important in the Levenberg-Marquardt routine. Its default value is 0.001.

nlsf.muMin

Read only, numeric

Read the smallest MU value ever reached.

nlsf.n$

Read only, string

This is a vector of strings. It contains the names of all the parameters.

nlsf.names$

Read only, string

Same as nlsf.n$.

nlsf.nConstr

Read only, numeric

Read the number of constraints. The linear constraints are parsed and translated into a matrix-vector format internally with the nlsf.nconstr as the number of linear equations.

nlsf.nConstrEff

Read only, numeric

Read the number of effective constraints. If some parameters are fixed, the fitter disables them in the constraint equations by moving them from the left side of the equations to the right side. This may reduce the total number of equations. As a result, the final number of linear constraint equations may be less and is denoted as nlsf.nconstreff.

nlsf.nIter

Read only, numeric

Read the number of iterations that are actually performed. Use nslf.maxIter to set the maximum number of iterations.

nlsf.noFitCurve

N/A

Not currently implemented. Read/set if the curve should be constructed. See nlsf.end() or nlsf.makecurve().

nlsf.nParaVary

Read only, numeric

Read the number of parameters that are allowed to vary. Use nlsf.vn or PVn to set the nth parameter to fixed or vary.

nlsf.nPoints

Read only, numeric

Read the number of data points that are actually used in the fitting. This value is the actual value used to calculate the degree of freedom (nlsf.dof) and the reduced chi-square value. Because there may be bad data points or functional evaluations, this value may be less than the user-specified value.

nlsf.numDepend

Read only, numeric

Read the total number of dependent variables.

nlsf.numFitSets

Read/write, numeric

Read/set the total number of sets. This property should be used when fitting multiple datasets. It should be set prior to assigning the independent and dependent variables. To set variables see: nlsf.indep$, nlsf.dep$ nlsf.setDepend() nlsf.setIndep(), nlsf.y$, nlsf.fitData$ and nlsf.x$.

nlsf.numIndep

Read only, numeric

Read the total number of independent variables.

nlsf.numReplica

Read/write, numeric

Read/set the number of replicas. This value should be set to the number of peaks in your dataset minus 1. When fitting multiple peak datasets, this value is used for each dependent variable.

nlsf.pasteToPlot

Read/write, numeric

Paste results into the graph after fitting: 1 = enable, 0 = disable. The results of using this property will not be evident until the fitting session is ended. See the method nlsf.end()

nlsf.pn

Read/write, numeric.

Set or read the nth parameter values. If you know the names of your parameters, you can also read/write them using the parameter name. For example

nlsf.pred

Read/write, numeric

Set the prediction level value. For more information, see the Origin Help file.

nlsf.predCol$

Read/write, string

Same as nlsf.lpredcol$.

nlsf.s#

Read/write, numeric

Read or set parameters as shared, where # is the parameter number as it occurs in the Parameters Sharing list on the Select Dataset page. 1 = Shared and 0 = not Shared.

nlsf.singularCriterion

Read/write, numeric

This property is applicable when the SVD (single value decomposition) method is used for the matrix inversion. The SVD method’s algorithm supposes to “ignore” (exactly, turn to 0 value = 1/element) the elements of the diagonal matrix, if these elements are very small (less than nlsf.singularcriterion).
The nlsf.singularcriterion variable contains the value that should be used as a criterion of how small the element (its relative value) is. All elements smaller than nlsf.singularcriterion will be turned to 0 in the inverse matrix. By default, nlsf.singularcriterion is equal to 1e-60.

nlsf.ssr

Read only, numeric

Read the value of the sum of squares function SS(p).

nlsf.status

Read only, numeric

0 after closing a fitting session. 1 after opening a fitting session and initializing.

nlsf.tolerance

Read/write, numeric

Set the tolerance value to stop the iterations. The tolerance value is a stop criterion. The default value is 1E-9. For more information, see the Origin Help file.

nlsf.ub

Read/write, numeric

Same as nlsf.lb, but for the upper bound.

nlsf.ubx

Read/write, numeric

Same as nlsf.lbx, but for the upper bound sign.

nlsf.uConfCol$

Read/write, string

Set a column that is used to store the values of the upper confidence band.

nlsf.un

Read only, numeric

Read the upper confidence limit value of the nth parameter for a given confidence value (nlsf.conf).

nlsf.uPredCol$

Read/write, string

Set a column that is used to store the values of the upper prediction band.

nlsf.vn

Read/write, numeric

Tells whether parameter n is fixed or allowed to vary during fitting: 1 = vary, 0 = fixed. (You can fix a parameter using linear constraints.)

nlsf.wn$

Read/write, string

Set the weight column. Weights designate the contributions from individual data points. This designated column must exist before this operation can be performed. This property can be incremented using n in cases where multiple datasets are being fitted simultaneously. See also nlsf.setWeight().

nlsf.wType

Read/write, numeric

Set weight type: 0 = no weight, 1 = instrumental, 2 = statistical, and 3 = a specified column for weighting. In general, the default value of nlsf.wtype is 0 and there is no weight. When error bars are plotted and the fitting is from the Fit menu, the weight is defaulted to instrumental type, using the error bars for weighting, with nlsf.wtype equal to 1. Otherwise, this value always defaults to no weight. For more information, see the Origin Help file.

nlsf.x$

Read/write, string

Set the X column as the independent variable for the fitting function. You typically have an X column to plot a dataset or a function. This designated column must exist before this operation can be performed. When there is no X column, Origin uses the default worksheet X values. Set default X values using the Format:Set Worksheet X menu command. This menu command allows you to set a start value and incremental step size for Y column plotting (or fitting) when no X column exists. See also 1) nlsf.indep$ and nlsf.dep$, 2) nlsf.setDepend() and nlsf.setIndep(), or 3) nlsf.y$ or nlsf.fitData$ (which is often paired with nlsf.x$).

nlsf.xBegin

Read/write, numeric

Set a start value for the curves created using the command nlsf.makecurve(). After a fit, you may want to create a dataset with the fitting function according to the parameters found from the fitting. Use this command with nlsf.xpoints, nlsf.xstep, or nlsf.xend to create a function dataset.

nlsf.xEnd

Read/write, numeric

Same as nlsf.xbegin but set the end value.

nlsf.xMode

Read/write, numeric

This value determines how to use the independent variable X when creating a function set or confidence and prediction intervals. Refer to the nlsf.makecurve() command for creating a dataset. There are several modes:
nlsf.xmode = 0: Create the dataset according to the X values of the original Y dataset (the dataset which is used for fitting). In this case the X values used are those in the dependent variable’s associated X column (or the Worksheet X if no X column is present).
nlsf.xmode = 1: Create the dataset according to the given X starting value (nlsf.xbegin), the incremental step size (nlsf.xstep), and the total number of data points (nlsf.xpoints). In this case a specific dataset is not needed.
nlsf.xmode = 2: Create the dataset according to any given X column. With this mode, you need to have an X column and set it using the command nlsf.funcx$ = ”xxx”. The X column must exist in a worksheet somewhere in the project and contain data for this xmode to work.
nlsf.xmode = 4: Create the dataset according to the first and last X values of the fitting dataset. The X values of the dataset are uniformly chosen reflecting the X-axis scale. There are nlsf.xpoints data points for this curve. With this mode, you must create an X column to store the X values. Assign this column using the command nlsf.funcx$ = ”xxx”. You also need to assign the number of data points using nlsf.xpoints. If you want a uniform curve on the graph with a nonlinear X-axis scale, use this command.
nlsf.xmode = 5: Similar to mode 4, but create the dataset with X values starting at nlsf.xbegin and ending at nlsf.xend. Otherwise, see the previous description.

nlsf.xPoints

Read/write, numeric

Set the number of points for the fit curve dataset. Refer to nlsf.makecurve(), nlsf.xbegin, and nlsf.xstep.

nlsf.xStep

Read/write, numeric

Set the incremental step size for the independent variable X for the function dataset. Refer to nlsf.make(), nlsf.xbegin, and nlsf.xpoints.

nlsf.yn$

Read/write, string

Set the Y column as the dependent variable for the fitting function. This is the dataset to be fitted. You must have this column set before you can perform any fitting operations. If you fit from the menu, Origin automatically sets the current active plotted dataset as the Y column, and its corresponding X column as the dependent variable (if there is an X column). This designated column must exist before this operation can be performed. When fitting multiple datasets, increment the dataset using n. See also nlsf.fitData$, nlsf.setDepend(), nlsf.Dep$. See related nlsf.x$, nlsf.setIndep(), nlsf.indep$.

When fitting with the Gauss function, you can read/set y0, xc, w, and A.

If replicas are enabled, increment each parameter name (i.e. xc1, w1, A1, … , xcn, wn, An). Note that y0 is not incremented in this case since it is common to both peaks.

Multiple datasets are incremented after an underscore. For instance, a two dataset fit where each dataset contains two peaks would yield parameters:

xc1_1, w1_1, A1_1, xc2_1, w2_1, and A2_1 for the first dataset

and

xc1_2, w1_2, A1_2, xc2_2, w2_2, and A2_2 for the second dataset.

Method

Description

nlsf.addfunc(category, path, arg)

Add a function to the function list in the NLSF. category = the category the function should appear under, path = the full path to the .fdf file, arg = whether or not the function file should be copied to the functions folder; 1 = copy, 0= don't copy.

nlsf.begin()

Start a fitting session. A fitting session is defined as the duration of time in which various mathematical operations can be performed, including the most important operation, the Levenberg-Marquardt minimization or the simplex minimization. In a fitting session, all storage space including the covariance matrix persists in the entire duration.

nlsf.category(arg)

Set the function’s category. Arg is the name of the category.

For example, nlsf.category(Exponential) sets the category to “Exponential” for the function’s selection. Arg should have the exact spelling as the nlsf category.

nlsf.control(arg)

() Open the NLSF dialog box at the current status.
(close) Close the current dialog box.
(select) Open the Select Function dialog box.
(dataset) Open the Select Dataset dialog box. In order to open this dialog box, you must have selected a function.
(new) Open the Define New Function dialog box.
(edit) Open the Edit Function dialog box. In order to open this dialog box, you must have selected a function.
(fit) Open the Fitting Session dialog box. In order to open this dialog box, you must have selected a function and assigned fitting datasets.
(replicas) Open the Replicas dialog box. In order to open this dialog box, you must have selected a function which allows replicas, such as the Gauss function.
(simulate) Open the Simulate Curves dialog box. In order to open this dialog box, you must have selected a function.
(results) Open the Generate Results dialog box. In order to open this dialog box, you must have selected a function and assigned fitting datasets.
(init) Open the Initializations dialog box. In order to open this dialog box, you must have selected a function.
(after) Open the After Fitting dialog box. In order to open this dialog box, you must have selected a function.
(control) Open the Control Parameters dialog box. In order to open this dialog box, you must have selected a function.
(constraints) Open the Parameter Constraints dialog box. In order to open this dialog box, you must have selected a function.

nlsf.chkConstr()

Check whether constraints are violated or not. This method helps you determine if the constraints are self-consistent, which may be critical for smooth fitting.

nlsf.cleanUpFitData()

Clean up all the internal objects. This method can be called at either the beginning or end of the fitting session. Its function is similar in both cases. At the beginning, nlsf.cleanupfitdata() can serve as a way to reset the fitting data sets if a fitting session was just performed (or you're not sure if one has) and you want to perform another one. At the end, the method serves as a way to clean up the internal data set assignments prior to ending a fitting session so that the next fit (if there is one) starts clean. Several properties remain set even after this method is executed. These include the fitting function and parameter values. This allows quicker fitting, especially from the NLSF GUI since one can reopen the NLSF after a fitting session has completed and reassign a new fit data set without having to reselect the fitting function and initialize the parameters..

nlsf.cmatrix(index1, index2)

Return the value of the element of the constraint’s matrix with indexes (index1, index2). Example: nlsf.cmatrix(2, 1) = ; returns the value of the element that is located in the second column and first row.

nlsf.createCurves(curveType)

Plot the confidence and prediction bands. If curveType = C, create confidence bands. If curveType = P, create prediction bands. The confidence and predicition levels can be from nlsf.conf and nlsf.pred.

nlsf.end(n)

End a fitting session. n = 8: do not paste Fit Label to results log. n = 4: do not paste Fit Label to graph. n = 1: do not create a fit curve. The argument uses a bit oriented method. In this method n= 13 ( 8+4+1) will set all three options. If n is omitted then no options are set. After this method, related internal storage space is destroyed. You can start another fitting session using nlsf.begin().

nlsf.fit(n)

Similar to nlsf.iterate(n), except this method automatically generates a fitted curve with an X dataset. In the default case the curve is generated and the data is placed in the original worksheet next to the independent variable. These datasets are generated with nlsf.xPoints number of points and the X values are evenly spaced in the current X axis space. The FitFunc datasets are not generated again if they already exist. To open the worksheet for these datasets, use the script: edit fitfunc;.

nlsf.funcVal(x)

Get the function value for a given independent value x.

nlsf.init()

Initialize the fitting DLL and put Origin in a status that is ready to start a fitting session. 50 parameters are allocated by default. All system variables are set to default values. This method is equivalent to selecting Action:Reset in the Advanced Fitter.

nlsf.iterate(n)

Iterate the fitting procedure for n iterations without creating a fit curve. This is the kernel of the fitting module, in the sense that the actual fitting routines which are the Levenberg-Marquardt minimization and the corresponding constraint routines (if there are any constraints) are used to find the parameters. If the tolerance value (see the Origin Help file) is satisfied, the fitter stops before the specified number of iterations are finished. This operation can only be done within a fitting session. If n = 0, the fitter is not activated but the reduced chi-square value as well as the fit are recalculated based on current parameters.

nlsf.make()

Same as nlsf.makecurve().

nlsf.makecurve(type)

Make datasets according to the specification type. The current implementation supports creating a fit curve dataset, confidence bands, prediction bands, and a variance-covariance matrix. The corresponding X values of these datasets are determined by nlsf.xmode. These operations succeed only after you have supplied proper column names for the generated datasets. (func) makes a function dataset according to the fitting function, the given parameters, nlsf.xmode, nlsf.xbegin, nlsf.xend, nlsf.xstep, and nlsf.xpoints.
nlsf.makecurve(conf) makes confidence bands according to the fitting function, the given parameters, nlsf.xmode, nlsf.xbegin, nlsf.xend, nlsf.xstep, and nlsf.xpoints. The default confidence value is 0.95, which can be changed using nlsf.conf. See also nlsf.createCurves( C )(pred) makes prediction bands according to the fitting function, the given parameters, nlsf.xmode, nlsf.xbegin, nlsf.xend, nlsf.xstep, and nlsf.xpoints. The default confidence value is 0.95, which can be changed using nlsf.pred.
For nlsf.makecurve(func), nlsf.makecurve(conf), and nlsf.makecurve(pred), you must provide columns to store the resulting datasets and assign them using nlsf.funcCol$, nlsf.lPredCol$, and nlsf.uPredCol$. Depending on nlsf.xmode, you may need to provide a corresponding X column (see nlsf.xmode). (v) creates the variance-covariance matrix. Before you use this command, you must create a matrix and use nlsf.covar to set the matrix to store the variance-covariance matrix.

nlsf.pasteParams(ctrl)

Paste the parameters to the graph or Results Log. If ctrl = PLOT (or just ctrl = P), paste the parameters to the graph. If ctrl = RESULTS (or ctrl = R), paste the parameters to the Results Log.

nlsf.paraConf()

Create the confidence intervals for individual parameters. View results using Pun for upper confidence limit of parameter n, and PLn for lower confidence limit. Use nlsf.conf = xxx; and nlsf.pred = xxx; to set the confidence and prediction levels before this command is executed. This operation can only be done within a fitting session.

nlsf.paraRange()

Set parameters to a region that satisfies constraints if they exist. This method actually invokes constraint routines.

Nlsf.paramWks(arg)

Create the parameters worksheet. Specify the name of the worksheet to be created by entering a string (or string variable) for arg. This is equivalent to clicking the Param. Worksheet button in Action:Results or running the [ParaConf] section in Fit.OGS.

nlsf.parse()

Parse constraints explicitly and set up related storage space for constraint operations. Constraints must be parsed before they can be used. The fitter checks for the constraints and calls this method internally if there are constraints and they are still not parsed.

nlsf.report(n)

Generates a report without ending the fitting session. n = 8: do not paste Fit Label to results log. n = 4: do not paste Fit Label to graph. n = 1: do not create a fit curve. The argument uses a bit oriented method. In this method n= 13 ( 8+4+1) will set all three options. If n is omitted then no options are set.

nlsf.residuals()

Create a residuals plot for the dependent variable.

nlsf.rsConstr()

Not currently implemented. This method restores the constraint’s value saved after the last fitting session closing.

nlsf.setDepend(VarName, Dataset)

VarName is the variable name. Dataset is the full dataset name. This method sets Dataset as the variable varName. Therefore, it has the same effect as an assignment in the Select Dataset dialog box. For example: nlsf.setdepend(act,data1_activity)

nlsf.setIndep(VarName, Dataset)

Same as nlsf.setdepend() but for independent variables.

nlsf.setWeight(VarName, WVarName, Dataset)

VarName is the dependent variable name. WVarName is the name of the weight variable related to VarName. Dataset is the full dataset name of the column to use as a weight for VarName.

nlsf.simplex(n)

Iterate to find parameters using the simplex method, according to the specified n iterations. When parameter values are unknown at the beginning, the simplex method can be used to initialize them or to make a reasonable guess. The simplex method typically needs more functional evaluations to reach the minimum.

nlsf.svConstr()

Not currently implemented. Save constraint values after closing a fitting session.

nlsf.unInit()

Un-initialize the fitting module and free up all memory that was allocated during various fitting operations. This method is necessary after fitting operations which use a lot of memory due to a large number of parameters and constraints.

nlsf.updateDialog()

Update the parameter values in the Fitting Session, Simulate, and Parameter Initialization dialog boxes. Used during a fitting session when new values for parameters are computed and need to be displayed in the dialog box.

nlsf.varCovar(index1, index2)

Used like nlsf.cmatrix(), but for the variance-covariance matrix.

  • This script fits the first plotted dataset in the active graph window using the exponential decay 2 fitting function.

  • This script performs an exponential decay 2 fit on worksheet data. This example assumes a worksheet named Exp is active with columns A, B and Fit.

  • This script fits two datasets (called Draw1_b and Draw2_b) to the built-in Boltzmann fitting function. First, the fitting session is set up. Next, the initial parameters for Draw1_B are defined. Third, the initial parameters for Draw2_b are defined. Finally, the fitting session is performed.

nlsf.func$ = ExpDecay2;

nlsf.cleanupfitdata(); //begin fitting session

nlsf.fitdata$ = %(1,@D); //fit first dataset in layer

nlsf.tolerance = 0; //set tolerance

nlsf.W$ = errof(%(1,@D)); //use error bars as weight if exist

if (nlsf.w$ == "")

{

nlsf.wtype = 0;

};

else

{

nlsf.wtype = 1;

};

limit %C;

nlsf.xBegin = limit.xmin; //set up x values

nlsf.xEnd = limit.xmax;

nlsf.xPoints = 1000; //number of data points for fitted curve

nlsf.fit(20); //FIT, 20 iterations

nlsf.func$ = ExpDecay2;

A1 = 10; //initialize parameter values

t1 = 1;

x0 = 0;

y0 = 0;

nlsf.cleanupfitdata();

nlsf.fitdata$ = exp_b;

nlsf.iterate(20);

nlsf.xmode = 2;

nlsf.funcx$ = exp_A; //use as X dataset

nlsf.funccol$ = exp_Fit; //dataset to store fitted Y values

nlsf.makecurve(func); //dataset generated for the fitted curve

To work through this example, you must first create the data. You can do this by opening an empty graph window and using the Draw Data tool on your Tools toolbar. Creating two drawn datasets in this manner in a new project will automatically prepare you for this example as the datasets are named Draw1_b and Draw2_b by default.

After preparing the data, execute the following script (for example, in the Script window):

// Set up the fit //

nlsf.func$ = Boltzmann; // select Boltzmann fitting function

nlsf.numfitsets = 2; // indicate 2 datasets to be fitted

nlsf.fitdata1$ = Draw1_B; // define 1st dataset to be fitted

nlsf.fitdata2$ = Draw2_B; // define 2nd dataset to be fitted

// Initialize parameter set for draw1_b //

nlsf.p1 = 0.1; // A1 of first dataset

nlsf.p2 = 10; // A2 of first dataset

nlsf.p3 = 4; // x0 of first dataset

nlsf.p4 = 1; // dx of first dataset

// Initialize parameter set for draw2_b //

nlsf.p5 = 0.1; // A1_2 of 2nd dataset

nlsf.p6 = 10; // A2_2 of 2nd dataset

nlsf.p7 = 8; // x0_2 of 2nd dataset

nlsf.p8 = 1; // dx_2 of 2nd dataset

// Perform the fit //

nlsf.fit(100); // iterate 100 times

NLSF

The nlsf object performs operations on nonlinear least squares fitting. Curve fitting from script should be handled through the this object’s methods and properties.

Object type: External

Properties:

Methods:

Examples:


OPack

Property | Access | Description
opack.autoReplace | Read/write, numeric | Controls whether the user is prompted to replace existing files. 0: (Default) Ask the user before replacing existing files. 1: Automatically replace existing files.
opack.file$ | Read/write, string | List of files need to be packed. Used by all methods. If the file name begins without '\', go to the Origin directory to find the corresponding file.
opack.fileName$ | Read/write, string | Archive file name. Use OPK as the extension name. Used by the opack.getFileNames(), opack.pack(), and opack.unpack() methods. If file name begins without '\', the archive file will be put in the corresponding path under the Origin directory.
opack.pack.saveFolderInfo | Read/write, numeric | Only used in the opack.pack() method. 1: (Default) Save the full path name when pack into archive file. 0: Save the file name only.
opack.unpack.useFolderInfo | Read/write, numeric | Only used in the opack.unpack() method. 1: (Default) Use the directory structure saved in OPK file when unpacking. 0: Use the file name only.
opack.unpack.targetFolder$ | Read/write, string | This is the unpack directory. This property is only used in the opack.unpack() method. If it is not empty, use this as the target directory.
Method | Description
opack.getFileNames(TextFileName) | TextFileName is the name of text file containing the destination archive file name and the names of the files need to be packed. This method reads the first line to FileName$, then reads the following lines into the File$ property.
opack.findFile(FileName [, StrVar]) | FileName is the file name to be found. StrVar is the string variable (optional). This method searches from the beginning of the File$ property. If the required file name is found, it assigns it to the LabTalk string variable. Otherwise, it leaves the variable unchanged. When the search is performed, only the last part of the file name will be compared. For example: opack.findFile(.dat, S) will find the first file name with "dat" as the extension from the current position of the File$ property and then assign it to a LabTalk string variable S. This method's return value is the element index if found, or 0 if not found.
opack.findNext([StrVar]) | StrVar is the LabTalk string variable (optional). This method searches from the current index of the File$ property for the file name passed by the opack.findFile() method. If found, it is assigned to the LabTalk string variable. Otherwise, the variable is left unchanged. This method returns the element index if found, or 0 if not found.
opack.pack([UserAccessCode]) | UserAccessCode can be: 0 = All, 1 = Non-registered, and 2 = Registered. If UserAccessCode is not included, then 0 (All) is used. This method packs all the files listed in the File$ property to the file FileName$. If opack.pack.SaveFolderInfo = 1, save the full path name for every source file. If opack.pack.SaveFolderInfo = 0, save the file name only. This method returns 0 for success, 2 for a File I/O error, or 6 for a File creation error.
opack.uninstall(ModuleName) | Uninstall OPK file moduleName. If found, removes the button group from the ini file. Returns 0 = success, 1 = failure.
opack.unpack() | Unpacks the archive file FileName$. If opack.unpack.UseFolderInfo = 1, use the directory structure saved in the OPK file. If no folder information was saved, use the Origin directory instead. If opack.unpack.UseFolderInfo = 0, use the file name only. Return values are: 0 Success, 1 User access error, 2 File I/O error, 3 File header error, and 4 Expanding file error.
opack.reset() | Sets opack.pack.SaveFolderInfo = 1, and opack.unpack.UseFolderInfo = 1. Sets all the other arguments to empty.

OPack

The OPack object is used to pack and unpack user-specified files.

Object type: External

Properties:

Methods:


Page

Page properties can be accessed using the following syntax:

[winName!]page.property =

WinName! Is optional. If winName! Is not specified, the active window is affected.

Property | Applies To | Access | Description
page.active | graphs | Read/write, numeric | Active layer number.
page.baseColor | graphs, worksheets | Read/write, numeric | Page color. Numbers from the color list: transparent (0). The color() function can be used, as in: page.basecolor = color(blue);
page.closeBits | graphs, worksheets | Read/write, numeric | Window closing behavior: 0 = normal, 1 = window will not close, and 2 = no warning message on window close.
page.cntrl | graphs, Matrices | Read/write, numeric | For Graphs, controls drawing of overlapping layers: 0 = show data that extends into another layer (default) 4 = draw layers sequentially, thus hiding underlying data. This would, for instance, prevent underlying data from showing through an inset graph. For Matrices, controls view mode: 0 = Data view mode 1 = Image view mode
page.cntrlColor | graphs | Read/write, numeric | When the control region is displayed (page.cntrlregion = 1), then page.cntrlcolor sets and reads the color of the control region using the numbers from the color list. Set page.cntrlcolor = 18 to display the control region using the graph window margin color (gray area).
page.cntrlHeight | graphs | Read/write, numeric | Set the height of the control region (if you want to display the control region at the top of the page).
page.cntrlRegion | graphs | Read/write, numeric | Set page.cntrlregion = 1 to display a control region. A control region provides a convenient location for placing tools. Set page.contrlregion = 0 to disable the display.
page.cntrlWidth | graphs | Read/write, numeric | Set the width of the control region (if you want to display the control region at the left of the page).
page.connect | graphs | Read/write, numeric | Connect missing values in line data plots: 0 = disable, 1 = enable.
page.dvHeight | graphs | Read only, numeric | When page.paperview = 0 (viewpaper off), page.dvheight = pixel height of the page (white area). When page.paperview = 1 (viewpaper on), page.dvheight will be reduced by 2*page.dvtop. The property value changes as the window is resized.
page.dvLeft | graphs | Read only, numeric | When page.paperview = 0 (viewpaper off), page.dvleft = 0. When page.paperview = 1 (viewpaper on), page.dvleft = 12. The property value changes as the window is resized.
page.dvTop | graphs | Read only, numeric | When page.paperview = 0 (viewpaper off), page.dvtop = 0. When page.paperview = 1 (viewpaper on), page.dvtop = 9. The property value changes as the window is resized.
page.dvWidth | graphs | Read only, numeric | When page.paperview = 0 (viewpaper off), page.dvwidth = pixel width of the page (white area). When page.paperview = 1 (viewpaper on), page.dvwidth will be reduced by 2*page.dvleft. The property value changes as the window is resized.
page.extInfo | worksheets | Read only, numeric | Type of active worksheet window: 0 = Origin worksheet, 1 = Excel workbook.
page.gradColor | graphs, worksheets | Read/write, numeric | When displaying the page with a gradient fill, page.gradColor determines the gradient color. Use numbers from the color list: transparent (0). The color() function can be used, as in: page.basecolor = color(blue);
page.height | graphs | Read/write, numeric | Page height in pixels.
page.icons | graphs | Read/write, numeric | Layer icons: 1 = show, 0 = hide.
page.label$ | graphs, worksheets | Read/write, string | Assign a label to a window. To display the window label as the window title, set page.title = 1. (Note: You can also define and display a window label using the win -rl windowName "labelContents" command.)
page.layoutCntrl | graphs, worksheets | Read/write, numeric | The Speed mode and View mode of all graph windows are controlled by the layout page window, if one exists: 1 = enable, 0 = disable.
page.layoutSpeed | layout pages | Read/write, numeric | The Show Picture Placeholders mode causes graph or worksheet pictures in the layout page window to be displayed as named, cross-hatched boxes: 1 = enable, 0 = disable.
page.maxPts | graphs | Read/write, numeric | Maximum number of data points to display for each data plot. The displayed data points are evenly distributed throughout the data plot. Increases screen display when working with large data plots. Printing is not affected.
page.nLayers | graphs, worksheets | Read only, numeric | Number of layers on the page.
page.nLinks | graphs | Read only, numeric | Total number of child layers on the page.
page.noClick | graphs, worksheets | Read/write, numeric | Disable mouse clicking on various objects: 1 = on axes and column headings, 2 = on data plots and cells, 4 = on labels, 8 = on objects, 16 = on layer frames, and 32 = on tick labels. Values are cumulative, so page.noclick = 5 disables clicking on axes and labels.
page.resx | graphs, worksheets | Read/write, numeric | Horizontal resolution.
page.resy | graphs, worksheets | Read/write, numeric | Vertical resolution.
page.rtMaxPts | graphs | Read/write, numeric | Independent real-time calculation of maxpts: 0 = disable and use maxpts.
page.smPlotGap | -- | -- | Internal use only.
page.smPlotRev | -- | -- | Internal use only.
page.speed | -- | -- | Not currently implemented.
page.sysWin | graphs, worksheets | Read/write, numeric | Set the window as a system window which remains open when the project is closed: 1 = enable, 0 = disable.
page.title | graphs, worksheets | Read/write, numeric | Control the display of window names and labels: 0 = display name, 1 = display label, 2 = display name (page.title = 2 if the Rename dialog box was opened, the name was changed, and the Name radio button was selected), 3 = display name and label.
page.unit | graphs | Read/write, numeric | Page measurement units, as on the Miscellaneous tab of the page's Plot Details dialog box: 1 = inch, 2 = cm, 3 = mm, 4 = pixel, and 5 = point.
page.viewPaper | graphs | Read/write, numeric | Page is surrounded by background color: 1 = enable, 0 = disable. The background color can be set with the system.ExtBackColor property.
page.width | graphs | Read/write, numeric | Page width in pixels (200 pixels/inch).
page.xnColumns | -- | -- | Internal use only.
page.zoomIn, page.zoomOut, page.zoomWhole, page.zoomLayer | graphs | Read/write, numeric | Zoom mode: 0 = zoom to page center, 1 = zoom to last point clicked. Note: These are actually methods, not properties. However, they are accessed as if they were properties.

[winName!]page.method(argument)

Method

Description

page.dimUpdate()

Update the active graph window to the printer setup mode.

page.getFileName(A)

Get the window label or, if there is no label, the window name into %A. If the active window has a page.label (whether displayed or not), then the label is returned in the specified string variable. Otherwise, the window name is returned.

page.layerNumber(layerName)

Returns the layer number of the LayerName layer. Returns 0 if LayerName is not a valid name. Useful when working with Excel workbooks with multiple sheets.
Note: The active layer’s name is stored in the object property layer.name$.

page.reorder(n[, m])

Layer number change. If m is not specified, change current layer to nth position. Otherwise, change nth layer to be the mth layer.

Caution: If your graph includes linked layers, you should only change parent layer numbers. Origin may still break links during the reordering process.

page.smCrossMatrix()

Internal use only.

page.smSelfMatrix()

Internal use only.

  • This script uses the active property to set layer 2 in the Graph1 window as the active layer.

  • This script uses the reorder() method to change layer 1 to layer 2. Layer 2 will move up a position to layer 1. Use the Edit:Add & Arrange Layers menu command to physically move the positions.

  • This script changes the displayed name of a window to an arbitrary title. Any associated datasets are not renamed. The window is script accessible using the original name, and when the window is saved, the original name is used.

  • This script loops over each layer in the active graph window and types the layer number to the Script window.

Graph1!page.active = 2;

Graph1!page.reorder(1,2);

Data1!page.label$ = DisplayName;

Data1!page.title = 1;

Loop (num,1,$(page.nlayers))

//loop from 1 to the # of layers in the page

{

type “layer number $(num)”;

};

Page

A page is the base object that a window contains. A page can be either a graph page or a worksheet page, although page object properties are most often used for a graph page.

Object type: Window

Properties:

Methods:

Examples:


RT

Property | Access | Description
rt.bi | Read only, numeric | i = 1 - 32. First row of cell values.
rt.colBeg | Read only, numeric | Contains the column number of the worksheet that the new block is appending from.
rt.ei | Read only, numeric | i = 1 - 32. Last row of cell values.
rt.nCols | Read only, numeric | Number of columns in the block.
rt.nRows | Read only, numeric | Number of rows in the block.
rt.rowBeg | Read only, numeric | Contains the row number of the worksheet that the new block is appending from.
rt.update | Read/write, numeric | Real-time events pass to labels: 1 = enable, 0 = disable. When rt.update = 1, real-time events pass to labels that have the Real-Time check box enabled in the associated Label Control dialog box. Additionally, if Real-Time is selected from the label’s ‘Script, Run After’ drop down list, the script in the Label Control dialog box is executed when a real-time event is passed to the label.

RT

The rt object stores the real-time data block for script access. When real-time data comes into Origin, it is represented as a block with n x m cells of the same type. n is the number of columns and m is the number of rows. The data block can then be accessed through the rt object (the cells inside the block are not accessible).

Object type: Utility

Properties:


Run

Property | Access | Description
run.automate | -- | Internal use only. Not implemented in Origin.

Method

Description

run.dialog(OGOName[,DLLObject])

General mechanism for tool launching. OGOName is the tool OGO file name. DLLObject is the object (existing in an external DLL) that contains source values for the tool sub-objects. (For a full discussion of “source” and tool sub-objects, see the draw.set() method.)

The run.dialog() method is equivalent to the following script:

dotool -w OGOName;

run.section(OGSName,INIT);

DLLObject.reset();

draw.set(OGOName,DLLObject);

(Where the OGSName is named the same as OGOName.)

The run.dialog() method returns 0 if there is no error. It returns 1 if there is an error.

run.file(fileName)

Execute the specified LabTalk script file. This is the preferred mechanism for running user-defined script files (versus using the run command). You can specify a path in fileName. Otherwise, the Origin software folder is assumed.

run.LoadOC("myFile", [option])

Load and compile an Origin C function or workspace.

run.section(fileName,sectionName[,arg1 arg2 arg3 arg4 arg5])

Execute the named section of the specified LabTalk script file. You can specify a path in fileName. If no path is specified, Origin first looks in the location of the open project, then the user files path, then the path to the Origin application file. Script file sections are separated by [section names]. For example, [Graph]. This method can pass up to five arguments to a section. Arguments in the script can be referred to using the temporary string variables: %1, %2, %3, %4, and %5.
Note: When filename is not included, the current running script file is assumed. For example:

run.section( ,Init);

executes a subroutine Sub1 which is included in the currently running script file. This is a useful way to make a modular structure within a script file.

  • This script executes the script in the [SimpleFit] section of the LR.OGS file and performs a linear fit of the data in the current graph window.

run.section(lr.ogs,SimpleFit);

Run

The run object executes script from a script file. Origin tools use the run.section() method to execute sections of the appropriate *.OGS file.

Object type: Utility

Properties:

Methods:

Examples:


Sort

Property | Access | Description
sort.c1 | Read/write, numeric | The column number of the beginning range for sorting. If this number is zero, then all columns in the worksheet are sorted.
sort.c2 | Read/write, numeric | The column number of the end range for sorting. This is ignored if c1 is zero.
sort.cNamen$ | Read/write, string | An enumerated string specifying the sort sequence (primary, secondary, etc.) and order (ascending or descending). The syntax is: sort.cnamen$ = {A|D}: ColumnName; The space between : and ColumnName is required. n is 1, 2, etc. for the primary, secondary, etc. sort sequence. A for ascending order and D for descending order. ColumnName is the name of the column.
sort.missing | Read/write, numeric | Missing values: 0 = treat missing values as the smallest values within a column, 1 = treat missing values as the largest values within a column.
sort.r1 | Read/write, numeric | The row number of the beginning range for sorting.
sort.r2 | Read/write, numeric | The row number of the end range for sorting.
sort.wksName$ | Read/write, string | The name of the worksheet to be sorted.
Method | Description
sort.rank(Dataset1, Dataset2[, n]) | Dataset1 is the dataset to be ranked. Dataset2 is the dataset that will hold the ranking results. If n = 0, rank in ascending order. If n = 1, rank in descending order. If n is not included, rank in ascending order. When this method is executed, Origin internally sorts Dataset1 in ascending (or descending, n = 1) order. It then finds the average rank (or row number) for each of the duplicate values. This average value is then appended to Dataset2 in each of the corresponding duplicate cells.
sort.toggle(index) | Changes the sort order for the sequence specified by index. Index is equivalent to n in the sort.cnamen$ property, so that index = 1 for the primary sort sequence, index = 2 for the secondary sort sequence, etc.
sort.wks() | Executes the sort.

  • This script sorts all columns in the Data1 worksheet from row 3 to row 11, using column B as the primary sort column (descending) and column A as the secondary sort column (ascending).

  • This script changes the secondary sort sequence from ascending to descending.

  • This script ranks Data1_A in descending order and places the ranking results in Data1_B.

sort.wksname$ = Data1; // For the worksheet Data1

sort.c1 = 0; // all columns

sort.r1 = 3; // from row 3 to

sort.r2 = 11; // row 11,

sort.cname1$ = D: B;

// using column B as the primary, sort in descending order

sort.cname2$ = A: A;

// and column A as the secondary, sort in ascending order

sort.wks() // execute sort

sort.toggle(2); // Changes the sort order for the

// secondary sorting sequence

// here, changes column A from ascending to descending.

sort.wks(); // execute sort

sort.rank(data1_a,data1_b,1);

Sort

The sort object controls the sorting sequence, order, and range within a worksheet.

See also: sort command, sort() function.

Object type: Utility

Properties:

Methods:

Examples:


Stat

Property | Access | Description
stat.adrsq | Read only, numeric | Adjust Coefficient of Determination (R squared).
stat.chiSqrErr | Read/write, numeric | Multiply the error on the parameters with the reduced chi-square value. 1 = enable, 0 = disable.
stat.cod | Read only, numeric | Coefficient of Determination (R squared).
stat.confLevel | Read/write, numeric | Confidence level for calculating confidence and prediction limits.
stat.errBarData$ | Read/write, string | Name of the error bar column to be used for calculating weights.
stat.fitxData$ | Read/write, string | Name of the X column to be fitted.
stat.fityData$ | Read/write, string | Name of the Y column to be fitted.
stat.fValue | Read only, numeric | F test value (MSR/MSE).
stat.lclData$ | Read/write, string | Name of the lower control line.
stat.lplData$ | Read/write, string | Name of the lower prediction line.
stat.makeX.fitnpts | Read/write, numeric | Number of points for the fitted curve.
stat.makeX.fitX1 | Read/write, numeric | First X value to be used when making the FitX$ dataset with the MakeX() method.
stat.makeX.fitX2 | Read/write, numeric | Last X value to be used when making the FitX$ dataset with the MakeX() method.
stat.makeX.margin | Read/write, numeric | Percent of the raw data's range, of which to extend the fit X dataset beyond.
stat.MSE | Read only, numeric | Mean sum of squares of residuals.
stat.MSR | Read only, numeric | Mean sum of squares due to regression.
stat.npts | Read only, numeric | Number of valid data points.
stat.pvalue | Read only, numeric | P-value for F test.
stat.r | Read only, numeric | Correlation coefficient.
stat.resData$ | Read only, string | Name of the residual column.
stat.sd | Read only, numeric | Standard deviation of the fit.
stat.SSE | Read only, numeric | Residual sum of squares.
stat.SSR | Read only, numeric | Sum of squares due to regression.
stat.SSTO | Read only, numeric | Total sum of squares.
stat.uclData$ | Read/write, string | Name of the upper control line.
stat.uplData$ | Read/write, string | Name of the upper prediction line.
stat.wTotal | Read only, numeric | Total weight.
stat.xMean | Read only, numeric | Mean value of the X column.
stat.yMean | Read only, numeric | Mean value of the Y column.
Method | Description
stat.makeX() | Make an X dataset in fitX$ that spans from FitX1 to FitX2.
stat.name(CtrlBit, WksName_ColName, NewColNam1[, NewColNam2, ..., NewColNamn]) | CtrlBit is either 1 or 0. When CtrlBit = 1, concatenate WksName_ColName to WksNameColName. This becomes the name of the new worksheet. Scan for already existing datasets: WksNameColName_NewColNam1, WksNameColName_NewColNam2, ..WksNameColName_NewColNamn. If a dataset already exists, then generate a new worksheet name (WksNameColNamen, where n = 1, 2, etc.) and scan again. When no duplicate names are found, set stat.name.worksheet$ to WksNameColName or WksNameColNamen. When CtrlBit = 0, concatenate WksName_ColName to WksNameColName. Do not search for previously existing datasets with identical names. Set stat.name.worksheet$ to WksNameColName.
stat.reset() | Reset all parameter values to their initial, unassigned values.
Property | Access | Description
stat.lr.a | Read only, numeric | Intercept.
stat.lr.ap | Read only, numeric | P-value for the t test of a.
stat.lr.ase | Read only, numeric | Standard error of a.
stat.lr.b | Read only, numeric | Slope.
stat.lr.bp | Read only, numeric | P-value for the t-test of b.
stat.lr.bse | Read only, numeric | Standard error of b.
stat.lr.t | Read only, numeric | t value corresponding to the confidence level.
Method | Description
stat.lr([z]) | Linear regression for given datasets. When “z” is specified, the fitting line goes through the origin. For example:

stat.data$ = %H_B;

stat.errbardata$ = %H_C;

stat.lr();

stat.lr.a = ;

//Display intercept in Script window

stat.lr.b = ;

//Display slope in Script window

Property | Access | Description
stat.pr.a, stat.pr.b1, etc. | Read only, numeric | Fitted parameters (a is the intercept).
stat.pr.ap | Read only, numeric | P-value of the t-test for parameter a.
stat.pr.ase, stat.pr.bse1, etc. | Read only, numeric | Standard error of a and b[i].
stat.pr.bp1, stat.pr.bp2, etc. | Read only, numeric | P-values of the t-tests for parameters bi.
stat.pr.order | Read/write, numeric | Order of the polynomial.
stat.pr.t | Read only, numeric | t value according to the confidence level.
Method | Description
stat.pr() | Polynomial regression for given datasets. For example:

stat.data$ = %H_B;

stat.fitxdata$ = %H_D; //(optional)

stat.fitydata$ = %H_E; //(optional)

stat.pr();

Property | Access | Description
stat.mr.a | Read only, numeric | Intercept.
stat.mr.ap | Read only, numeric | P-value of t-test for parameter a.
stat.mr.ase | Read only, numeric | Intercept's error.
stat.mr.bestr2wks$ | Internal use only | Not implemented in Origin.
stat.mr.bi | Read only, numeric | Fitting parameters (i = 1 .. 9).
stat.mr.bpi | Read only, numeric | P-values of t-test for parameters bi (i = 1 ..9).
stat.mr.bsei | Read only, numeric | b[i]’s errors (i = 1 .. 9).
stat.mr.NumX | Read only, numeric | The total number of X columns.
stat.mr.pIn | Read only, numeric | Critical P-value to enter a variable in stepwise regression.
stat.mr.pOut | Read only, numeric | Critical P-value to remove a variable in stepwise regression.
stat.mr.t | Read only, numeric | t value according to confidence level.
stat.mr.XDatai$ | Read/write, string | X column names (i = 1 ..9).
stat.mr.YData$ | Read/write, string | Y column name.
Method | Description
stat.mr() | Multiple regression for the given datasets. For example:

stat.mr();

Property | Access | Description
stat.DS.ad | -- | Not currently implemented.
stat.DS.CIL | Read only, numeric | Lower confidence limit about the mean (the percentage is set with stat.ds.confLev).
stat.DS.CIU | Read only, numeric | Upper confidence limit about the mean (the percentage is set with stat.ds.confLev).
stat.DS.cName1$ | -- | Not currently implemented.
stat.DS.confLev | Read/write, numeric | Confidence level (set to 0.95 by default). Set this property to load stat.ds.ciu and stat.ds.cil.
stat.DS.data$ | Read/write, string | Name of dataset used to calculate descriptive statistics.
stat.DS.geoMean |  | Not currently implemented.
stat.DS.interpolate | Read/write, numeric | Use interpolation when finding the quartiles/percentiles. 1 = enable, 0 = disable.
stat.DS.kurt | Read only, numeric | Kurtosis of the data. Kurtosis measures the long-tailedness or peakedness of the distribution of a random variable relative to the normal or Gaussian distribution with the same mean and variance.
stat.DS.max | Read only, numeric | Maximum of the data.
stat.DS.mean | Read only, numeric | Mean value of the data.
stat.DS.medCIL | -- | Not currently implemented. Lower confidence limit about the median.
stat.DS.medCIU | -- | Not currently implemented. Lower confidence limit about the median.
stat.DS.median | -- | Read only, numeric. Median of the data.
stat.DS.min | Read only, numeric | Minimum of the data.
stat.DS.missing | Read only, numeric | Number of missing values in the dataset.
stat.DS.more | Read/write, numeric | Perform advanced statistics. 1 = enable, 0 = disable.
stat.DS.percent | Read/write, numeric | The percentile to calculate when stat.ds() is performed. The percentile is loaded into stat.ds.percentile.
stat.DS.percentile | Read only, numeric | Percentiles of the data.
stat.DS.quart75 | Read only, numeric | The upper quartile (75th percentile).
stat.DS.quartl25 | Read only, numeric | The lower quartile (25th percentile).
stat.DS.quartl50 | Read only, numeric | The second quartile (50th percentile).
stat.DS.range | Read only, numeric | Range of the data.
stat.DS.sd | Read only, numeric | Standard deviation.
stat.DS.se | Read only, numeric | Standard error of the mean.
stat.DS.size | Read only, numeric | Number of data points in the dataset.
stat.DS.skew | Read only, numeric | Skewness of the data.
stat.DS.ssq | Read only, numeric | Sum of squares.
stat.DS.sum | Read only, numeric | Sum of the data.
stat.DS.testNorm | -- | Not currently implemented.
stat.DS.var | Read only, numeric | Sample variance.
Method | Description
stat.DS() | Descriptive and basic statistics for given dataset.

  • This script performs a second order polynomial regression. It assumes that a Data1 worksheet is active and contains four columns: an X column with data, a Y column named B with data, an empty column named fitx, and an empty column named fity.

First create a script file containing the following script and save this file as PolyNom.OGS to your Origin software folder:

//Performs polynomial regression

//%1 = order

//%2 = name of dataset to fit (y variable)

//%3 = name of dataset to store fitted x data

//%4 = name of dataset to store fitted y data

//%5 = number of points to create fitted curve

[main]

stat.reset(); //Reset the DLL

stat.pr.order = %1; //order

stat.data$ = %2; //dataset to fit

stat.fitxdata$ = %3; //dataset to store fitted x values

stat.fitYdata$ = %4; //dataset to store fitted y values

stat.makeX.fitnpts = %5; //number of points of regression curve

limit %2; //finds limiting values for the dataset to fit

stat.makex.fitx1 = limit.xmin;

stat.makex.fitx2 = limit.xmax;

stat.makex();

stat.PR();

Then execute the following script to run the script file and perform the polynomial regression:

run.section(polynom.ogs, main, 2 data1_b data1_fitx data1_fity 100);

Stat

The stat object provides for the following operations:

  • Linear regression.

  • Polynomial regression.

  • Multiple regression.

  • Descriptive statistics.

Object type: External

Common Stat Object Properties:

Common Stat Object Methods:

Stat Object Properties Specific to Linear Regression:

Stat Object Methods Specific to Linear Regression:

Stat Object Properties Specific to Polynomial Regression:

Stat Object Methods Specific to Polynomial Regression:

Stat Object Properties Specific to Multiple Regression:

Stat Object Methods Specific to Multiple Regression:

Stat Object Properties Specific to Descriptive Statistics:

Stat Object Methods Specific to Descriptive Statistics:

Examples:


Sum

Property | Access | Description
sum.max | Read only, numeric | The maximum value in the selected dataset.
sum.mean | Read only, numeric | The mean value in the selected dataset.
sum.min | Read only, numeric | The minimum value in the selected dataset.
sum.n | Read only, numeric | The number of points in the dataset.
sum.sd | Read only, numeric | The standard deviation in the selected dataset.
sum.total | Read only, numeric | The sum of all the values in the selected dataset.

  • This script uses the sum() function to perform statistics on data1_b. The associated values are saved in sum object properties. These values are printed to the Script window.

sum(data1_b);

type "max = $(sum.max)";

type "mean = $(sum.mean)";

type "min = $(sum.min)";

type "n = $(sum.n)";

type "sd = $(sum.sd)";

type "total = $(sum.total)";

Sum

The Analysis:Statistics on Columns menu command and the sum() function save statistics to the sum object. When multiple columns are selected, the sum object holds the statistics from the last column.

Object type: Utility

Properties:

Examples:


System

axis, circle, copypage, dash, datadisplay, date, dialog, display, excel, fileext, font, graph, grid, line, line4, math, notes, numeric, operations, page, path, polygon, polyline, print, project, rect, script, symbol, tick, toolbar, and wks.

Property | Access | Description
system.bits | Read only, numeric | The bit value of Origin. Returns 16 or 32.
system.date | Read only, numeric | The current date and time in numeric format. Equivalent to the @D system variable. To display the information as a date or time, use $(system.date,D#) where # is an index to the Origin date formats. See also system.date().
system.debug | Read/write, numeric | Debug mode executes LabTalk statements that begin with #!. 1 = enable, 0 = disable.
system.explorer | Read/write, numeric | Controls the type of Open and Save As dialog boxes used in 32 bit Origin in Windows 95: 1 = Standard Explorer dialog boxes, 0 = Origin dialog boxes including a Show Info check box (and associated Comments text box). The fdlog object controls the display of the Show Info check box. Note: 16 bit Origin returns a missing value.
system.extBackColor | Read/write, numeric | Background color index, outside of page. Default color is gray. To set, use the color() function. For example: system.page.outColor.color(white) To surround the page with a background color, use the page.viewpaper property.
system.level | Read only, numeric | Starting menu level.
system.pageCol | Read/write, numeric | Current page column number in worksheet printing.
system.pageRow | Read/write, numeric | Current page row number in worksheet printing.
system.priority | Read/write, numeric | Controls the Origin EXEs Windows process priority: 64 = low, 32 = normal, 128 = high, 256 = realtime. Realtime is strongly discouraged.
system.product | Read only, numeric | OriginLab product code. The first bit of this property indicates whether the product is Origin or OriginPro: 0 = Origin and 1 = OriginPro. Thus, to determine if the product is Origin or OriginPro, you must do a bitwise AND of system.product and the value 1 using the bitwise AND operator "&". For example:
system.pureColor | Read/write, numeric | Display control: 0 = use dithered color, 1 = use pure color.
system.resolution | Read only, numeric | X resolution of the page and is dependent on the resolution of the printer driver in dots per inch (dpi). For related information, see page.resX and page.resY.
system.saveControl | Read only, numeric | File type to be saved: 0 = project, 1 = template.
system.sigDigitsL | Read/write, numeric | Maximum number of significant digits displayed to the right of the decimal place for small numbers. Should be specified in negative numbers, i.e. -3 specifies 3 significant digits to the right of the decimal place.
system.sigDigitsU | Read/write, numeric | Maximum number of significant digits for large numbers. For example, if this property is set to 4, 1234567.0 displays as 1.234 E 6.
system.templatepath |  | Not currently in use.
system.version | Read only, numeric | The version number of the Origin software. This is the same as the @V system variable.
system.winViewFSize | Read/write, numeric | Font size scalar for display in Window View mode. This is the same as the @W system variable.

if (system.product&1 == 1)

{

type -b "OriginPro";

}

else

{

type -b "Origin";

};

Method | Description
system.date() | Returns the current date and time in numeric format. To display the information as a date or time, use $(System.Date(),D#) where # is an index to the Origin date formats.
system.loadPref([FileName]) | Load Origin’s preferences from the specified FileName. If no file name is provided, then the OPTION.CNF file is used. If “1” is specified for FileName, then the internal defaults are loaded. The internal defaults are the values used in the event that the OPTION.CNF file doesn’t exist.
system.savePref([FileName]) | Save Origin’s preferences to the specified FileName. If no file name is specified, then the OPTION.CNF file is used.

  • This script displays the present date in MM/DD/YY format on an existing text label named Today.

Today.text$ = $(system.date,D0);

//uses the label.text$ property

System

The system object properties allow you to read and alter a variety of settings which are maintained in the OPTION.CNF file.

Object type: Utility

Note: The system object includes the following sub-objects:

Properties:

Methods:

Examples:


Property | Access | Description
system.axis.color | Read/write, numeric | Axis color. Numbers from the color list or set with the color() function. For example: system.axis.color(blue);
system.axis.oldDialog | Read/write, numeric | Use pre-version 5.0 axis dialog boxes. 1 = enable, 0 = disable.
system.axis.width | Read/write, numeric | Axis width in points.
system.axis.useUpdateDlg | Read/write, numeric | Control the display of the Apply To dialog box that opens when switching the editing axis in the Options dialog box. 1 = display Apply To dialog box, 0 = do not display Apply To dialog box (changes are made automatically when switching axes in the Options dialog box).

System.Axis

The axis object is a sub-object of the system object. The axis object properties allow you to read and alter axis-related settings which are set in the OPTION.CNF file. These settings can also be accessed in the Options dialog box.

Object type: Utility

Properties:


System.Circle

Property | Access | Description
system.circle.backcolor | Read/write, numeric | Fill color following the Origin color palette: 1 = black, 2 = red, 3 = green, 4 = blue, etc.
system.circle.color | Read/write, numeric | Border color following the Origin color palette: 1 = black, 2 = red, 3 = green, 4 = blue, etc.
system.circle.fillPattern | Read/write, numeric | Fill pattern by order on the Fill Pattern tab of Object Properties: 1 = none, 2 = dense, 3 = medium, etc.
system.circle.fillWidth | Read/write, numeric | Fill pattern width in point size.
system.circle.forecolor | Read/write, numeric | Pattern color following the Origin color palette: 1 = black, 2 = red, 3 = green, 4 = blue, etc.
system.circle.linetype | Read/write, numeric | Border type by order on the Border tab of Object Properties: 0 = solid, 1 = dash, 2 = dot, etc.
system.circle.width | Read/write, numeric | Border width in point size.

System.Circle

The circle object is a subobject of the system object. The circle object properties allow you to read and set circle format options stored in the SYSTEM.CNF file. These properties are set in the user interface through the Object Properties dialog box. Note that setting these properties through script will overwrite the values in SYSTEM.CNF when the Origin session terminates.

Object type: Utility

Properties:


System.CopyPage

Property | Access | Description
system.copyPage.clipBorderW | Read/write, numeric | ClipBorderW and Closeness are related properties. Both properties affect the amount of the page in the graph window that is copied or exported. By default, all the objects within a “bounding box” plus a “border” are copied/exported. ClipBorderW allows you to set a value for the “border” around the “bounding box”. This value is the percent of the width of the “bounding box”. The default value is 6. Enable or disable the “border” with the Closeness property. (See the Examples section.)
system.copyPage.closeness | Read/write, numeric | Closeness and ClipBorderW are related properties. Both properties affect the amount of the page in the graph window that is copied or exported. When closeness = 1 (default), copy/export the page within the “bounding box” plus add the “border” set by clipBorderW. When closeness = 2, copy/export only the page within the “bounding box”. When closeness = 4, copy/export the entire graph page. (See the Examples section.)
system.copyPage.preview | Read/write, numeric | Printer driver used when copying/exporting the page. 1 = Use the current printer driver, regardless of the current view mode. 0 = Use the driver applicable to the current view mode. All view modes except Print View use the screen driver. Print View uses the printer driver. Character positioning is superior using the printer driver, however, a Postscript driver can take longer to generate the image.
system.copyPage.ratio | Read/write, numeric | Size of the copied/exported page when pasted/inserted into another application. Specify as a percent of the page size in Origin. Set to 100 for 100%, etc.
system.copyPage.redraw | Read/write, numeric | Redraw the page after copying/exporting: 1 = enable, 0 = disable.

  • This script sets the border around the graph page “bounding box” to 10% of the bounding box width. It then sets the Copy Page and File:Export Page menu commands to copy/export the bounding box plus the border when selected.

system.copypage.clipborderw = 10;

system.copypage.closeness = 1;

System.CopyPage

The copypage object is a sub-object of the system object. The copypage object properties allow you to read and alter copy page and graphic export-related settings which are set in the OPTION.CNF file. These settings can also be accessed in the Options dialog box.

Object type: Utility

Properties:

Examples:


Property | Access | Description
system.dash.definen$ | Read/write, string | Set the dash definition for line, line+symbol, and scatter graphs. Corresponds to the dash line types in the Plot Details dialog box.
system.dash.hatchGap | Read/write, numeric | The gap between hatch lines in a column or bar data plot or hatch-filled object. Units in 1/10 of a millimeter. To display the default Windows hatch lines, set system.dash.hatchGap = 0.
system.dash.hatchWidth | Read/write, numeric | Width of hatch lines in a column or bar data plot or hatch-filled object. If system.dash.hatchWidth = 1, use 1 pixel black lines to draw the hatch lines. If system.dash.hatchWidth = 0, use the same line style as the border of the box.
system.dash.scaleByWidth | Read/write, numeric | Scale the dash pattern according to the line width: 1 = enable, 0 = disable. When disabled, the dash pattern is the same for all line widths.
system.dash.softInPgView | Read/write, numeric | Source for dashed line: 1 = use Origin’s dashed line, 0 = use the device driver’s dashed line.

System.Dash

The dash object is a sub-object of the system object. The dash object properties allow you to read and alter dash line-related settings which are set in the OPTION.CNF file. These settings can also be accessed in the Options dialog box.

Object type: Utility

Properties:


Property | Access | Description
system.dataDisplay.autoFit | Read/write, numeric | Automatically display all text in the Data Display tool, independent of the tool’s size. 1 = enable, 0 = disable. When autofit = 0, the display of text with in the tool is controlled by the resize property.
system.dataDisplay.bkColor | Read/write, numeric | Background color of the Data Display tool. Numbers from the color list or set with the color() function.
system.dataDisplay.docking | Read/write, numeric | Control the Data Display tool’s view: 1 = enable docking view, 0 = disable docking view. If docking view is enabled, the tool can be docked on the edge of the workspace.
system.dataDisplay.font$ | Read/write, numeric | Name of font used for text display in the Data Display tool.
system.dataDisplay.resize | Read/write, numeric | Control the display of the Data Display tool’s text when autofit = 0. 0 = fix the size of the tool’s text to the current size. 1 = fix the size of the tool’s text so that all the text displays within the horizontal constraints. 2 = fix the size of the tool’s text so that all the text displays within the vertical constraints.
system.dataDisplay.txtColor | Read/write, numeric | Text color for the Data Display tool. Numbers from the color list or set with the color() function.

System.DataDisplay

The dataDisplay object is a sub-object of the system object. The dataDisplay object properties allow you to read and alter Data Display tool settings.

Object type: Utility

Properties:


Property | Access | Description
system.date.customFormat1$ | Read/write, string | Read or set the first custom date format. Two custom date formats are available at the bottom of the Date Format drop-down list in the Worksheet Column Format dialog box.
system.date.customFormat2$ | Read/write, string | Read or set the second custom date format. See system.date.customFormat1$.

System.Date

The date object is a sub-object of the system object. The date object property allows you to read and alter the default custom date formats. This setting can also be accessed in the Options dialog box.

Object type: Utility

Properties:


Property | Access | Description
system.dialog.activePageNum | Read/write, numeric | Set the active tab on the Options dialog box. 1 = File Locations, 2 = Axis, 3 = Graph, 4 = Text Fonts, 5 = Page, 6 = Miscellaneous, 7 = Excel, 8 = Open/Close, and 9 = Numeric Format.
system.dialog.closePrompt | Read/write, numeric | Control the display of the “Save as Origin’s startup options?” prompt after making changes and closing the Options dialog box. 1 = display prompt, 0 = do not display prompt.
system.dialog.saveOnClose | Read/write, numeric | If the ClosePrompt property = 0, then this property is active. Automatically save settings in the Options dialog box to the OPTION.CNF file. 1 = enable, 0 = disable.

System.Dialog

The dialog object is a sub-object of the system object. The dialog object properties allow you to read and alter Options dialog box opening and closing settings which are set in the OPTION.CNF file. These settings can also be accessed with in the Options dialog box.

Object type: Utility

Properties:


Property | Access | Description
system.display.balloonHelp | Read/write, numeric | Dsplay balloon help: 1 = enable, 0 = disable. To view balloon help, hold the mouse pointer over a toolbar button or tool element.
system.display.noWinUpdate | Read/write, numeric | Do not update the window if it is more than noWinUpdate% covered by another window(s).
system.display.pasteMeta | Read/write, numeric | Paste the Clipboard image as a bitmap or a metafile. 1 = metafile, 0 = bitmap.
system.display.selBlink | Read/write, numeric | Control the blinking of the axis or tick labels when they are double-clicked. 1 = enable blink, 0 = disable blink.
system.display.wksGridNoShow | Read/write, numeric | Available for video displays that don't draw the worksheet grids correctly. 1 = enable, 0 = disable.

System.Display

The display object is a sub-object of the system object. The display object properties allow you to read and alter display-related settings which are set in the OPTION.CNF file. These settings can also be accessed in the Options dialog box.

Object type: Utility

Properties:


System.Excel

Property | Access | Description
system.excel.closeAfterPlot | Read/write, numeric | Close the Select Data for Plotting dialog box after plotting the workbook data. 1 = close the dialog box, 0 = do not close the dialog box. The Select Data for Plotting dialog box is only available when dlgPlot = 0.
system.excel.dlgPlot | Read/write, numeric | Plot by highlighting workbook data and assuming column designations appropriate to a selected graph type. 1 = enable, 0 = disable.
system.excel.dragDropPlot | Read/write, numeric | Drag-and-drop plot method for adding workbook data (and Origin worksheet data) to an existing graph. 1 = line, 2 = scatter, 3 = line+symbol, and 4 = current data plot style holder.
system.excel.legendTxtSel | Read/write, numeric | Automatically search the workbook for legend text. Origin searches for text in the cell immediately above the cell that contains the first Y data values, and then continues to search upward in the workbook. 1 = enable, 0 = disable.
system.excel.openAsExcel | Read/write, numeric | Control the selection in the Open Excel dialog box (when openAsPrompt = 1). 1 = open as Excel workbook, 0 = open as Origin worksheet.
system.excel.openAsPrompt | Read/write, numeric | Display the Open Excel dialog box after selecting File:Open Excel. This dialog box determines how Excel files are opened in Origin (as workbooks or as Origin worksheets). 1 = enable opening dialog box, 0 = disable opening dialog box and always open as a workbook.
system.excel.plotMulti | Read/write, numeric | When selecting multiple datasets for plotting in the Select Data for Plotting dialog box, control the display of the data plots. 0 = plot all data into single layer graph, 1 = plot each data plot into its own layer of the same graph window, 2 = plot each data plot into its own graph window.
system.excel.saveAsExcel | Read/write, numeric | Control how internal and external Excel workbooks are saved when you save the associated project. 0 = do not open the Save Excel Workbooks dialog box. External workbooks are automatically updated when the associated project is saved. 1 = Open the Save Excel Workbooks dialog box when you select File:Save Project or click the Save button on the Standard toolbar. 2 = Open the Save Excel Workbooks dialog box when you select File:Save Project As.

System.Excel

The excel object is a sub-object of the system object. The excel object properties allow you to read and alter settings related to using Excel in Origin, which are set in the OPTION.CNF file. Most of these settings can also be accessed in the Options dialog box.

Object type: Utility

Properties:


System.FileExt

Property | Access | Description
system.fileExt.activeGroup | Read/write, numeric | This property returns the index of the group that is currently active. If there are no groups, then this property will return zero. You can change the active group by setting this property to the index of the group you want to make active. Values used for setting this property must be in the range [1, numGroups]. Setting this property will be ignored when there are no groups.
system.fileExt.activeGroup$ | Read/write, string | This property returns the name of the group that is currently active. If there are no groups, then this property will return an empty string (""). You can change the active group by setting this property to the name of the group you want to make active. Setting this property will be ignored when there are no groups. This property and the Name$ property will always return the same value.
system.fileExt.defASCII$ | Read/write, string | This property is used for getting and setting the default extension to be appended to ASCII files when an extension is not specified by the user.
system.fileExt.defPath$ | Read/write, string | This property is used for getting and setting the default path for the file types of the active group.
system.fileExt.defType | Read/write, numeric | The extension type used by default in the Files of Type combination box in the file dialog box. This value must be in the range [1, numTypes].
system.fileExt.name$ | Read/write, string | The name of the active group. Setting this property allows you to rename the active group. The Name$ and ActiveGroup$ properties always return the same value.
system.fileExt.numGroups | Read/write, numeric | The number of extension groups currently defined. You can set this value to decrease or increase the number of groups to be handled by the System.FileExt object. While increasing NumGroups is a way to add more groups, it is highly recommended that you use the AddGroup() method instead.
system.fileExt.numTypes | Read/write, numeric | The number of extension types in the active group. 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]. While increasing NumTypes is a way to add more types, it is highly recommended that you use the AddType() method instead.
system.fileext.openPathMode | Read/Write, numeric | Path used by FDlog object 1 = User Path, 2 = Project Path, 3 = Origin Path.
system.fileext.savePathMode | Read/Write, numeric | Path used by FDlog object. 0 = Use Open Path, 1 = User Path, 2 = Project Path, 3 = Origin Path.
system.fileExt.tracking | Read/write, numeric | Tracking default file paths: 0 = no tracking, 1 = Track file dialog changes.
system.fileExt.typen$ | Read/write, string | This array property is used for getting and setting the nth extension type for the active group. The index must be in the range (1, NumTypes). 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 used to determine what files are displayed.
Method | Description
system.fileExt.addGroup(groupName) | Add (create) a new File Extension group. groupName is the name that will be used to identify the group and the types of files it will contain. Each group name must be unique. On success, the added group becomes the active group and the NumGroups property is incremented. Return value is zero for success and non-zero for error.
system.fileExt.addType(extensionType) | Add (create) a new Extension type. extensionType is the Extension type string. The string must be in the format: "[description] *.extension" where description is the text displayed in the Files of Type combination box and extension is the extension of the files to display in the file list box. On success, the NumTypes property is incremented. Return value is zero for success and non-zero for error.
system.fileExt.delGroup(groupName|groupIndex) | Delete a File Extension group by name or index. On success the NumGroups property is decremented. Return value is zero for success and non-zero for error.
system.fileExt.getType(extension) | Returns the index of the system.fileExt.typen$ property that represents the file type specified in extension. If no file type represents the extension then zero is returned. Example extension is BMP, EPS, JPG, etc. This is not case sensitive.
system.fileExt.reset() | Delete all File Extension groups. Numeric properties are set to zero and string properties are set to blank (""). Return value is always zero.
system.fileExt.setTypeExts(groupName, extension) | Set the extensions for the extension type system.fileExt.typen$. If groupName does not exist, it is added. For example:

If the active file extension group is set as follows:

system.fileExt.type1$ = "[Image (*.BMP)] *.BMP";

And then you execute the following:

system.fileExt.setTypeExts("Image", tif jpg);

Then the type will look as follows:

system.fileExt.type1$="[Image (*.TIF,*.JPG)] *.TIF;*.JPG";

System.FileExt

The fileExt object is a sub-object of the system object. The fileExt object property allows you to read and alter the file extension, file location, and file tracking settings, which are set in the OPTION.CNF file. These settings can also be accessed in the Options dialog box.

Object type: Utility

Definitions for this object:

  • 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".

  • 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)

  • Extension Group: A list of Extension Descriptions. Example: Images

Properties:

Methods:


System.Font

Property | Access | Description
system.font.default$ | Read/write, string | Font to be used when Default is selected from the font drop down list in the Text Control dialog box.
system.font.greekName$ | Read/write, string | Name of font to use for Greek characters in text labels.
system.font.horzEdit | Read/write, numeric | Text orientation for in-place editing. 0 = edit using label orientation, 1 = enable horizontal editing.
system.font.labelColor | Read/write, numeric | Default text label color. Numbers from the color list or set with the color() function.
system.font.labelName$ | Read/write, string | Name of font to use for a text label’s default font.
system.font.labelSize | Read/write, numeric | Text label default font size.
system.font.lineSpace | Read/write, numeric | The space between two lines of text in a text label, in percent of the currently selected font size.
system.font.noIpEdit | Read/write, numeric | In place editing behavior. 0=enable in place editing, 1=disable in-place editing.
system.font.pageViewAccurate | Read/write, numeric | Use the printer driver to display the text labels in the graph window when Page View is selected. 1 = enable, 0 = disable.
system.font.simpleSelect | Read/write, numeric | Simple selection mode for text. 0 = enable rotation and skewing (dragging handle to resize text), 1=disable rotation and skewing.
system.font.subOffset | Read/write, numeric | Position of subscript, in percent of the currently selected font size.
system.font.subSize | Read/write, numeric | Subscript and superscript font size, in percent of the currently selected font size.
system.font.supOffset | Read/write, numeric | Position of superscript, in percent of the currently selected font size.
system.font.tabSize | -- | Not currently implemented.

System.Font

The font object is a sub-object of the system object. The font object properties allow you to read and alter font-related settings which are set in the OPTION.CNF file. These settings can also be accessed in the Options dialog box. It should be noted that setting these properties through script does not trigger the save as Origin’s startup Options dialog, so the value in Options.CNF is not overwritten.

Object type: Utility

Properties:


System.Graph

Property | Access | Description
system.graph.barShowZero | Read/write, numeric | Display a line at Y = 0 (X = 0) for zero values in a bar (column) graph: 1 = enable, 0 = disable.
system.graph.bisectionPts | Read/write, numeric | Set the threshold to begin using a bisection search. Origin uses a bisection search when using the Data Reader tool or double-clicking on a data plot.
system.graph.closePrompt | Read/write, numeric | Display a prompt when closing a graph window: 0 = hide only, 1 = display prompt, 2 = delete without prompt.
system.graph.closeLayPrt | Read/write, numeric | Display a prompt when closing a layout page window: 0 = hide only, 1 = display prompt, 2 = delete without prompt.
system.graph.displayChar | Read/write, numeric | Display characters in the symbol gallery in the Plot Details dialog box.
system.graph.fillColor | Read/write, numeric | Fill color that displays when Automatic is selected from Fill Color drop-down list. Numbers from the color list or set with the color() function.
system.graph.log1IsFloor | Read/write, numeric | Establish Y = 1 as the “floor”, or the Y value which alters the direction of column/bar graphs displayed on a logarithmic scale. 1 = enable, 0 = disable.
system.graph.percInterp | Read/write, numeric | Percentile calculation for interpolation: 1 = enable, 0 = disable.

System.Graph

The graph object is a sub-object of the system object. The graph object properties allow you to read and alter graph-related settings which are set in the OPTION.CNF file. These settings can also be accessed in the Options dialog box.

Object type: Utility

Properties:


Property | Access | Description
system.grid.majorColor | Read/write, numeric | Major grid line color. Numbers from the color list, or transparent (0). The color() function can be used, as in: .majorColor = color(blue)
system.grid.majorType | Read/write, numeric | Major grid line type number: 1 = solid, 2 = dash, 3 = dot, etc., from the Line Type drop down list.
system.grid.majorWidth | Read/write, numeric | Width of the major grid lines in points.
system.grid.minorColor | Read/write, numeric | Minor grid line color. Numbers from the color list, or transparent (0). The color() function can be used, as in: .minorColor = color(blue)
system.grid.minorType | Read/write, numeric | Minor grid line type number: 1 = solid, 2 = dash, 3 = dot, etc., from the Line Type drop down list.
system.grid.minorWidth | Read/write, numeric | Width of the minor grid lines in points.

System.Grid

The grid object is a sub-object of the system object. The grid object properties allow you to read and alter grid-related settings which are set in the OPTION.CNF file. These settings can also be accessed in the Options dialog box.

Note: These grid-related properties only affect graph windows that are not created from a template. If a graph window is created from a template, the template properties take precedence over the grid object properties.

Object type: Utility

Properties:


System.Line

Property | Access | Description
system.line.arrowBeginLength | Read/write, numeric | Length of beginning arrow heads in point size.
system.line.arrowBeginShape | Read/write, numeric | Arrow head shape by order on Arrow tab of Object Properties: 0 = none, 1 = filled triangular, 2 = chevron, etc.
system.line.arrowBeginWidth | Read/write, numeric | Width of beginning arrow heads in point size.
system.line.arrowEndLength | Read/write, numeric | Length of ending arrows heads in point size.
system.line.arrowEndShape | Read/write, numeric | Arrow head shape by order on Arrow tab of Object Properties: 0 = none, 1 = filled triangular, 2 = chevron, etc.
system.line.arrowEndWidth | Read/write, numeric | Width of ending arrow heads in point size.
system.line.arrowPosition | -- | Not currently implemented.
system.line.color | Read/write, numeric | Line color following the Origin color palette: 1 = black, 2 = red, 3 = green, 4 = blue, etc.
system.line.linetype | Read/write, numeric | Line type: 0 = solid, 1 = dash, 2 = dot, etc.
system.line.width | Read/write, numeric | Line width in point size.

System.Line

The line object is a subobject of the system object. The line object properties allow you to read and set straight line and arrow format options stored in the SYSTEM.CNF file. These properties are set in the user interface through the Object Properties dialog box. Note that setting these properties through script will overwrite the values in SYSTEM.CNF when the Origin session terminates.

Note: Changing default arrow characteristics will affect only new objects created with the Arrow tool of the user interface.

Object type: Utility

Properties:


System.Line4

Property | Access | Description
system.line4.arrowBeginLength | Read/write, numeric | Length of beginning arrow heads in point size.
system.line4.arrowBeginShape | Read/write, numeric | Arrow head shape by order on Arrow tab of Object Properties: 0 = none, 1 = filled triangular, 2 = chevron, etc.
system.line4.arrowBeginWidth | Read/write, numeric | Width of beginning arrow heads in point size.
system.line4.arrowEndLength | Read/write, numeric | Length of ending arrows heads in point size.
system.line4.arrowEndShape | Read/write, numeric | Arrow head shape by order on Arrow tab of Object Properties: 0 = none, 1 = filled triangular, 2 = chevron, etc.
system.line4.arrowEndWidth | Read/write, numeric | Width of ending arrow heads in point size.
system.line4.arrowPosition | -- | Not currently implemented.
system.line4.color | Read/write, numeric | Line color following the Origin color palette: 1 = black, 2 = red, 3 = green, 4 = blue, etc.
system.line4.linetype | Read/write, numeric | Line type: 0 = solid, 1 = dash, 2 = dot, etc.
system.line4.width | Read/write, numeric | Line width in point size.

System.Line4

The line4 object is a subobject of the system object. The line4 object properties allow you to read and set curved line and arrow format options stored in the SYSTEM.CNF file. These properties are set in the user interface through the Object Properties dialog box. Note that setting these properties through script will overwrite the values in SYSTEM.CNF when the Origin session terminates.

Note: Changing default arrow characteristics will affect only new objects created with the Curved Arrow tool of the user interface.

Object type: Utility

Properties:


Property | Access | Description
system.math.angularUnits | Read/write, numeric | Angular units: 0 = radian, 1 = degree, 2 = grad.

  • This script prints a warning to an Attention box if radians are not being used as the angular units.

if (system.math.AngularUnits != 0)

{

type -b “Warning: units are not radians!” ;

};

System.Math

The math object is a sub-object of the system object. The math object property allows you to read and alter the angular unit setting which is set in the OPTION.CNF file. This setting can also be accessed in the Options dialog box.

Object type: Utility

Properties:

Examples:


Property | Access | Description
system.notes.closePrompt | Read/write, numeric | Display a prompt when closing a notes window: 0 = hide only, 1 = display prompt, 2 = delete without prompt.
system.notes.created$ | Read only, string | Returns the name of the last created Notes window.
system.notes.sizeCols | Read/write, numeric | Default width of the notes window in characters.
system.notes.sizeRows | Read/write, numeric | Default height of the notes window in characters.

System.Notes

The notes object is a sub-object of the system object.

To create a Notes window, see the window command. To redirect output to the Notes window, see the type object.

Object type: Utility

Properties:


Properties | Access | Description
system.numeric.numDecDigits | Read/write, numeric | Number of digits displayed after the decimal point. Data values that exceed this number are rounded off. However, the actual values are used in calculations.
system.numeric.separators | Read/write, numeric | Numeric separator for data display: 0 = Windows Settings, 1 = 1,000.0, 2 = 1.000,0, 3 = 1 000,0, and 4 = 1'000.0.
system.numeric.sigDigitsL | Read/write, numeric | Lower threshold for conversion from decimal to scientific notation.
system.numeric.sigDigitsU | Read/write, numeric | Upper threshold for conversion from decimal to scientific notation.

System.Numeric

The numeric object is a sub-object of the system object. The numeric object properties allow you to read and alter numeric settings which are set in the OPTION.CNF file. These settings can also be accessed in the Options dialog box.

Object type: Utility

Properties:


Property | Access | Description
system.operations.inPlace | Read/write, numeric | Use OLE in-place activation when editing an Origin object that is embedded in a destination application. Note: OriginLab does not recommend using in-place activation to edit objects.
system.operations.useSpacer | Read/write, numeric | Display a toolbar spacer below the menu bar. The toolbar spacer ensures that the toolbar area remains at a fixed width when changing the active child window. 1 = enable display, 0 = disable display.

System.Operations

The operations object is a sub-object of the system object. The operations object properties allow you to read and alter a toolbar spacer setting and an OLE in-place activation setting which are set in the OPTION.CNF file. These settings can also be accessed in the Options dialog box.

Object type: Utility

Properties:


Property | Access | Description
system.page.axisSpacing | Read/write, numeric | Set the spacing of the axis grid lines. The grid sizes are in 1/1000 of the page width.
system.page.objSpacing | Read/write, numeric | Set the spacing of the object grid lines. The grid sizes are in 1/1000 of the page width.

System.Page

The page object is a sub-object of the system object. The page object properties allow you to read and alter axis and object grid-related settings which are set in the OPTION.CNF file. These settings can also be accessed in the Options dialog box.

Object type: Utility

Properties:


System.Path

The path object is a sub-object of the system object. The path object is provided for backward compatibility only. For information on this object, see your Origin 5 LabTalk documentation. For new scripts, use the system.fileExt object.


System.Polygon

Property | Access | Description
system.polygon.backcolor | Read/write, numeric | Fill color following the Origin color palette: 1 = black, 2 = red, 3 = green, 4 = blue, etc.
system.polygon.color | Read/write, numeric | Border color following the Origin color palette: 1 = black, 2 = red, 3 = green, 4 = blue, etc.
system.polygon.fillPattern | Read/write, numeric | Fill pattern by order on the Fill Pattern tab of Object Properties: 1 = none, 2 = dense, 3 = medium, etc.
system.polygon.fillWidth | Read/write, numeric | Fill pattern width in point size.
system.polygon.forecolor | Read/write, numeric | Pattern color following the Origin color palette: 1 = black, 2 = red, 3 = green, 4 = blue, etc.
system.polygon.linetype | Read/write, numeric | Border type by order on the Border tab of Object Properties: 0 = solid, 1 = dash, 2 = dot, etc.
system.polygon.width | Read/write, numeric | Border width in point size.

System.Polygon

The polygon object is a subobject of the system object. The polygon object properties allow you to read and set polygon format options stored in the SYSTEM.CNF file. These properties are set in the user interface through the Object Properties dialog box. Note that setting these properties through script will overwrite the values in SYSTEM.CNF when the Origin session terminates.

Object type: Utility

Properties:


System.Polyline

Property | Access | Description
system.polyline.arrowBeginLength | -- | Not currently implemented.
system.polyline.arrowBeginWidth | -- | Not currently implemented.
system.polyline.arrowEndLength | -- | Not currently implemented.
system.polyline.arrowEndWidth | -- | Not currently implemented.
system.polyline.arrowPosition | -- | Not currently implemented.
system.polyline.color | Read/write, numeric | Line color following the Origin color palette: 1 = black, 2 = red, 3 = green, 4 = blue, etc.
system.polyline.width | Read/write, numeric | Line width in point size.

System.Polyline

The polyline object is a subobject of the system object. The polyline object properties allow you to read and set polyline format options stored in the SYSTEM.CNF file. These properties are set in the user interface through the Object Properties dialog box. Note that setting these properties through script will overwrite the values in SYSTEM.CNF when the Origin session terminates.

Object type: Utility

Properties:


System.Print

Property | Access | Description
system.print.fontBaseline | Read/write, numeric | Align the bottom of the letters and symbols in a line of a text label. 1 = enable, 0 = disable.
system.print.keepDevColor | Read/write, numeric | Print non-white colors on a gray scale when printing to a black and white printer. 1 = enable, 0 = disable.
system.print.landscape | Read/write, numeric | Page orientation for printing worksheets or matrices. 2 = landscape, 1 = portrait. Note: The graph template setting takes precedence over this property setting.
system.print.maxPlotPoints | Read/write, numeric | The number of data points displayed in a graph printout when skipPlotPoint = 1.
system.print.printControl | Read/write, numeric | Page numbers currently being printed.
system.print.skipPlotPoint | Read/write, numeric | Control the number of data points displayed in the printed graph. 1 = enable, 0 = disable. When enabled, Origin prints maxPlotPoints data points in the printout.
system.print.XscaleFactor | Read/write, numeric | X scale adjustment for printing. Control this property if your printed graph is not the exact scale set on the Size/Speed tab of the layer's Plot Details dialog box. For example, if you specify a width of 6 inches, and the graph prints 6.0625 inches wide, set system.print.XscaleFactor = 1010 (because (6.0625*1000) / 6 = 1010).
system.print.YscaleFactor | Read/write, numeric | Y scale adjustment for printing. See system.print.XscaleFactor.

  • This script checks the landscape property and types the printer orientation to the Script window.

if (system.print.landscape == 2)

type "The printer is in Landscape mode.";

else

type "The printer is in Portrait mode.";

System.Print

The print object is a sub-object of the system object. The print object properties allow you to read and alter print-related settings which are set in the OPTION.CNF file. These settings can also be accessed in the Options dialog box.

Object type: Utility

Properties:

Examples:


Property | Access | Description
system.project.backup | Read/write, numeric | Backup the project file to BACKUP.OPJ (in the Origin directory) before saving: 1 = enable, 0 = disable.
system.project.iconizedAsHidden | Read/write, numeric | Control how windows that are saved as minimized in pre-version 6 projects open in Origin 6: 0 = hidden, 1 = minimized, 2 = prompt.
system.project.showInDataList | Read/write, numeric | Show datasets from worksheets in nonactive Project Explorer folder in Layer n dialog box data list: 1 = show, 0 = don't show.
system.project.showInNLSFDataList | Read/write, numeric | Show datasets from worksheets in nonactive Project Explorer folder in NLSF Select Dataset dialog box: 1 = show, 0 = don't show.
system.project.startup | Read/write, numeric | Select the child window or project you want to display when you open a new project. 1 = worksheet, 2 = Excel workbook, 3 = graph, 4 = matrix, 5 = project (worksheet and graph), and 6 = none.
system.project.viewwindows | Read/write, numeric | Control how the workspace view is effected by the Project Explorer folder selection: 0 = don't show any windows, 1 = show only windows in active Project Explorer folder, 2 = show windows in active folder and subfolders.

System.Project

The project object is a sub-object of the system object. The project object properties allow you to create project file backups and to control the child window that displays when you open a new project. Both options are set in the OPTION.CNF file. These settings can also be accessed in the Options dialog box.

Object type: Utility

Properties:


System.Rect

Property | Access | Description
system.rect.backcolor | Read/write, numeric | Fill color following the Origin color palette: 1 = black, 2 = red, 3 = green, 4 = blue, etc.
system.rect.color | Read/write, numeric | Border color following the Origin color palette: 1 = black, 2 = red, 3 = green, 4 = blue, etc.
system.rect.fillPattern | Read/write, numeric | Fill pattern by order on the Fill Pattern tab of Object Properties: 1 = none, 2 = dense, 3 = medium, etc.
system.rect.fillWidth | Read/write, numeric | Fill pattern width in point size.
system.rect.forecolor | Read/write, numeric | Pattern color following the Origin color palette: 1 = black, 2 = red, 3 = green, 4 = blue, etc.
system.rect.linetype | Read/write, numeric | Border type by order on the Border tab of Object Properties: 0 = solid, 1 = dash, 2 = dot, etc.
system.rect.width | Read/write, numeric | Border width in point size.

System.Rect

The rect object is a subobject of the system object. The rect object properties allow you to read and set rectangle format options stored in the SYSTEM.CNF file. These properties are set in the user interface through the Object Properties dialog box. Note that setting these properties through script will overwrite the values in SYSTEM.CNF when the Origin session terminates.

Object type: Utility

Properties:


System.Script

The script object is a sub-object of the system object. The script object property allows you to control a Script window setting which is set in the OPTION.CNF file. This setting can also be accessed in the Options dialog box.

Object type: Utility

Properties:


Properties | Access | Description
system.symbol.borderWidth | Read/write, numeric | Control the border width of hollow or open symbols in a scatter or line and symbol data plot. Set to n to set the width of the symbol border to n% of the symbol’s half diameter.
system.symbol.lineGap | Read/write, numeric | Control the line and symbol gap on a line and symbol data plot. Set to n to set the line and symbol gap to n% of the symbol diameter. 0 = no gap. Maximum allowable value is 256. Note: To display the line and symbol gap, enable the associated check box in the data plot’s Plot Details dialog box.

System.Symbol

The symbol object is a sub-object of the system object. The symbol object properties allow you to read and alter symbol-related settings which are set in the OPTION.CNF file. These settings can also be accessed in the Options dialog box.

Object type: Utility

Properties:


System.Tick

Properties | Access | Description
system.tick.gapAxTitle | Read/write, numeric | Distance between the tick labels and the axis title. In percent of system.tick.majorLen. 50 = no gap
system.tick.gapInside | Read/write, numeric | When the ticks are displayed inside the axis, this is the distance between the tick labels and the ticks. In percent of system.tick.majorLen.
system.tick.gapOutside | Read/write, numeric | When the ticks are displayed outside the axis, this is the distance between the tick labels and the ticks. In percent of system.tick.majorLen.
system.tick.labelColor | Read/write, numeric | Tick label color, when creating a graph from scratch (no template). Numbers from the color list or use the color() function, as in: system.tick.labelColor = color(blue) (Note: This property is not available in the Options dialog box.)
system.tick.log1As10E | Read/write, numeric | Control display of tick labels when using Scientific notation on a logarithmic scale. 1 = display 10^0 as 1 and display 10^1 as 10. 0 = display 10^0 as 10^0 and display 10^1 as 10^1.
system.tick.maxNumeric | Read/write, numeric | Maximum number of major ticks allowed when Numeric is selected from the Type drop down list on the Tick Labels tab of the Axis dialog box.
system.tick.maxText | Read/write, numeric | Maximum number of major ticks allowed when ‘Text from dataset’, Time, Date, etc. is selected from the Type drop down list on the Tick Labels tab of the Axis dialog box.
system.tick.minorLen | Read/write, numeric | Minor tick length, when creating a graph from a template. In percent of the template's major tick length setting. This property is not available in the Options dialog box.

System.Tick

The tick object is a sub-object of the system object. The tick object properties allow you to read and alter tick-related settings which are set in the OPTION.CNF file. Some of these settings can also be accessed in the Options dialog box.

Object type: Utility

Properties:


System.Toolbar

Property | Access | Description
system.toolbar.names$ | Read only, string | A list of the names of all the toolbars.
Method | Description
system.toolbar.create(category[, toolbarName]) | Open a toolbar from a user-defined category.
system.toolbar.delete(toolbarName) | Delete a toolbar, including from the Registry.
system.toolbar.exists(toolbarName) | Returns 1 if the toolbar exists. Otherwise, returns 0.
system.toolbar.isOpen(toolbarName) | Returns 1 if the toolbar is open. Otherwise, returns 0.
system.toolbar.open(toolbarName) | Open a toolbar. Returns 0 if OK. Otherwise, returns 1.
system.toolbar.close(toolbarName) | Close a toolbar. Returns 0 if OK. Otherwise, returns 1.

System.Toolbar

The toolbar object is a subobject of the system object. The toolbar object controls the display of toolbars.

Object type: Utility

Properties:

Methods:


Property | Access | Description
system.wks.autoDelCol | Read/write, numeric | Automatically delete datasets from a worksheet when closing the worksheet. 1 = enable, 0 = disable (display a prompt).
system.wks.closeExlPrt | Read/write, numeric | Display a prompt when closing an Excel workbook window: 0 = hide only, 1 = display prompt, 2 = delete without prompt.
system.wks.closeMatPrt | Read/write, numeric | Display a prompt when closing a matrix window: 0 = hide only, 1 = display prompt, 2 = delete without prompt.
system.wks.closePrompt | Read/write, numeric | Display a prompt when closing a worksheet window: 0 = hide only, 1 = display prompt, 2 = delete without prompt.
system.wks.numericData | Read/write, numeric | Set all columns in all new worksheets to Text & Numeric (default) or to Numeric: 1 = Numeric, 0 = Text & Numeric.
system.wks.transpDelEmptyCols | Read/write, numeric | Controls whether columns are deleted after transposing the worksheet. 0 = always delete columns, 1 = never delete columns, 2 = prompt for delete.

System.Wks

The wks object is a sub-object of the system object. The wks object properties allow you to read and alter worksheet-related settings which are set in the OPTION.CNF file. These settings can also be accessed in the Options dialog box.

Object type: Utility

Properties:


Type

Property | Access | Description
type.notes$ | Read/write, string | When outputting with the type.wks() method, this property contains the name of the notes window that will receive the output if specified by type.redirection.
type.notesRemainIcon | Read/write, numeric | When outputting with the type.wks() method, if the notes window specified in type.notes$ is minimized before output, then this property determines whether of not it remains minimized after output. 0 = restore the notes window (default). 1 = keep the notes window minimized.
type.notesState | Read only, numeric | Get the state of the notes window specified by type.notes. The return value is bit oriented. Bit = 0, Value = 1: the window exists. Bit = 1, Value = 2: the window is not hidden. Bit = 2, Value = 4: the window contains data. Bit = 3, Value = 8: the window has been modified since it was last saved. Bit = 4, Value = 16: the window is minimized.
type.numCols | Read/write, numeric | The number of columns in the current output window as determined by type.redirection. After executing the type.wks(wksName) method, if the actual number of worksheet columns exceeds the value specified by numCols, then subsequent columns display below the first set of columns in the output window.
type.redirection | Read/write, numeric | Set the current output window. Bit = 0, Value = 1: the output goes to the Script window (default). Bit = 1, Value = 2: the output goes to the Notes window specified by type.notes$. Bit = 2, Value = 4: always send error messages to the Script window. Bit = 3, Value = 8: append a carriage-return to the data sent to the current output window. Bit = 4, Value = 16: the output goes to the Results Log. When you use the type.wks(wksName) object method to output the worksheet to the Results Log: All cell contents are output, not just the visible contents. Column names or labels not displayed in the worksheet, are ignored in the output. A cell found with "--", will output "-" to the column width.
type.repeatCol | Read/write, numeric | If the number of columns in a worksheet exceeds the number of columns in the current output window as specified by type.numCols, then this property controls whether or not the first worksheet column is repeated for each block when outputting with the type.wks(wksName) method. 1 = repeat the first column (default) for each block. 0 = start the next block with the next column.
type.state | Read only, numeric | Get the state of the Script window. The return value is bit oriented (see type.notesState).
type.tab | Read/write, numeric | The number of characters in a tab field in the current output window. If type.tab = 0, then the individual worksheet column widths are maintained in the output window after executing the type.wks(wksName) method.
Method | Description
type.addKey(keyname) | Add a key to the type object.
type.beginResults([keyname]) | Notify the Results Log of a block of results. When the Results Log receives this notification, it appends a header in the log. Headers are used to separate different blocks of results. If a keyname is passed, it will appear in the result's header with an index. The index is tracked by the type object.
type.clearResults([keyname[, firstindex[, lastindex]]]) | Clear the Results Log. If a keyname is passed, then only the results with the keyname will be cleared. If no keyname is passed, then all results will be cleared. Examples:
type.delKey(keyname) | Delete a key from the type object.
type.endResults() | Notify the Results Log that the block of results has ended. It is necessary to notify the Results Log that a block of results has ended so it can separate the logs with headers.
type.msgBox(Msg ,Title[, Button, Icon]) | Display a modal Windows message box. Msg displays as the message in the window. Title displays as the title. Button: 0 = OK, 1 = OK and Cancel, 2 = Yes and No, 3 = Yes, No, and Cancel. Icon: 0 = None, 1 = Question, 2 = Information, 3 = Stop, and 4 = Exclamation. Returns the value of the button clicked on: 0 = Cancel, 1 = OK, 2 = Yes, and 3 = No.
type.outputLog(header) | Appending a header to the Results Log. Values for header: 1 = Notify the Results Log of a block of results. When the Results Log receives this notification, it appends a header to the Results Log. Headers are used to separate different blocks of results. Headers contain the date, time, and active window. 0 = Notify the Results Log that the block of results has ended. It is necessary to notify the Results Log that a block of results has ended so it can separate the logs with headers.
type.redirection(on, off) | This method allows you to turn on and off the bits for the type.redirection property. The first argument switches the bits on and the second argument switches them off. This method returns the current setting of type.redirection.
type.showScript(value) | Control the display of the Script window. value: 1 = show, 0 = hide.
type.showStatus(value) | Control the display of the status bar. value: 1 = show, 0 = hide.
type.wks(wksName) | Copy the contents of the specified worksheet to the current output window as determined by type.redirection.

type.clearResults(FIT);

// delete all results with FIT keyname

type.clearResults(FIT3);

// delete results with FIT keyname and index 3

type.clearResults(FIT,3);

// same as type.clearResults(FIT3)

type.clearResults(FIT,3,8);

// delete results with FIT keyname and index from 3 to 8

  • This script sets the Results Log as the current output window. It clears the Results Log and then outputs "Start My Output" followed by the data in the data1 worksheet, maintaining the column widths in the output.

old = type.redirection;

type.redirection = 16;

type.clearResults();

type "Start My Output";

type.repeatCol = 0;

type.tab = 0;

type.wks(data1);

type.redirection = old;

Type

The type object provides output control to the Script window, Results Log, status bar, and notes window.

Object type: Utility

Properties:

Methods:

Examples:


Worksheet (wks)

The wks object is accessed using the following syntax:

[winName!]wks.property =

WinName! is optional. If winName! is not specified, the active worksheet is affected.

Property | Access | Description
wks.cNameMode | Read/write, numeric | Its value determines the columns that wks.cnamen$ operates on. Set wks.cnamemode to the following values: 0 = all columns, 1 = numeric columns, 2 = text columns, 4 = text and numeric (mixed) columns, and 64 = columns in the selection range. Set wks.cnamemode = 128 to return the full dataset name to wks.cnamen$.
wks.cNamen$ | Read only, string | Read the name of the nth worksheet column. See wks.cnamemode to operate on specific column types.
wks.col | Read/write, numeric | Current column. See the col object for column object properties.
wks.col# | -- | Not in use.
wks.colWidth | Read/write, numeric | Column width. Refresh the window after changing this property value.
wks.font | Read/write, numeric | Font index number as returned by the font(fontname) function.
wks.fSize | Read/write, numeric | Font size.
wks.hGrids | Read/write, numeric | Display horizontal grid: 1 = enable, 0 = disable.
wks.joinMode | Read/write, numeric | Set/get the worksheet join mode. Values may be the following: 0 = enumerate when column names match. Append when matching rows are not found. 1 = drop when column names match. Append when matching rows are not found. 2 = enumerate when column names match. Drop when matching rows are not found. 3 = drop when column names match. Drop when matching rows are not found. See the wks.join() method.
wks.maxRows | Read only, numeric | Maximum row index number that contains a value.
wks.multiX | Read/write, numeric | Multiple X columns: 1 = enable, 0 = disable.
wks.nCols | Read only, numeric | Number of columns in the worksheet.
wks.nRows | Read only, numeric | Number of rows in the worksheet.
wks.r1, r2, c1, c2 | Read only, numeric | Selection range. First and last columns and rows.
wks.rhw | Read/write, numeric | Row heading width in units of 1/10 of cell height.
wks.sel | Read only, numeric | Selection flags. The hex return number indicates what is selected in the worksheet. Values may be the following, or a combination of these bits: 0 = none, 1 = editing cell, 2 = column, 4 = row, 8 = range, and 16 = 1 column.
wks.useFont | Read/write, numeric | Font usage: 1 = use selected font, 0 = use system font.
wks.vGrids | -- | Read/write, numeric. Display vertical grid: 1 = enable, 0 = disable.

Method

Description

wks.addCol(name)

Add a single named column to the end of the worksheet. If name is not specified, a generic name is chosen.

wks.colSel(colNum, n)

Column selection. If n = 1, select the colNum column. If n = 0, deselect the colNum column.

wks.copy(strVarLetter, Col, Row)

Copy(Z): copy entire wks into %Z. (It is recommended that you use %Z for strVarLetter as %Z can hold up to 6,290 characters.) When the data is pasted, it is pasted into one row.
Copy(Z, n): copy all rows of column n.
Copy(Z, 0, n): copy all columns of row n.

wks.insert(name list)

Insert the list of columns at the current location. The current column position is specified by wks.col. The list consists of one or more desired column names separated by spaces. If a column name is already used, it is automatically enumerated.

wks.isColSel([colNum])

If colNum is included as an argument, the method returns the selection state of colNum. 0 = the column isn't selected. 1 = entire column is selected. 2 = a range of the column is selected. If colNum is not included as an argument, this method returns the number of columns selected (partial and entire selections).

[ToWks!]wks.join(FromWks)

Join the worksheet specified by FromWks to the worksheet specified by ToWks. This method adds the columns of FromWks to ToWks. If ToWks is not specified, then the currently active worksheet is used. For the join conditions, see the wks.joinmode property.

wks.labels()

Display worksheet column labels. No argument = display labels, 0 as argument = do not display labels.

wks.paste(strVarLetter, Col, Row)

Paste the contents of a string variable (specified without the %) into the cell beginning at (Col, Row).

wks.template(FileName[, [WinName], NumRows])

Open a template. For example, open the Count template and name it MyCount: wks.template(Count,MyCount);

  • This script moves a row of text into the worksheet column labels. The script includes a prompt to enter the row number and a command that removes the row after moving the labels.

thisrow = 1;

getnumber [Enter row (1 to $(wks.nrows))] thisrow (Move row to Labels);

loop (jj,1,wks.ncols)

{

wks.col$(jj).label$ = %(%H,jj,thisrow);

}

wks.labels();

mark -d %(%H,1) -b thisrow -e thisrow;

Worksheet (wks)

The wks object provides access to general worksheet manipulation. It includes three sub-objects: col, export, and import.

Object type: Window

Properties:

Methods:

Examples:


Wks.Col

The col object is accessed using the following syntax:

[winName!]wks.col[n].property =

WinName! is optional. If winName! is not specified, the named object in the active window is affected.

n is the column number starting from 1. If n is not provided, the leftmost column is assumed.

Property | Access | Description
wks.col.digitMode | Read/write, numeric | Set the digit display: 0 = display all, 1 = set the decimal places, and 2 = set the significant digits. When wks.col[n].digitmode = 0, wks.col[n].digits is set to 0. When wks.col[n].digitmode = 1, wks.col[n].digits is set to 3. When wks.col[n].digitmode = 2, wks.col[n].digits is set to 6.
wks.col.digits | Read/write, numeric | Number of decimal places when wks.col.digitMode = 1, number of significant digits when wks.col.digitmode = 2: 0 = display all, n = display n.
wks.col.format | Read/write, numeric | Column format: 1 = Numeric, 2 = Text, 3 = Time, 4 = Date, 5 = Month, 6 = Day of Week, and 7 = Text and Numeric as listed in the Format drop-down list in the Worksheet Column Format dialog box.
wks.col.justify | Read/write, numeric | Set the justification for worksheet cell values. 1 = right, 2 = left, and 3 = center.
wks.col.label$ | Read/write, string | Column label. To read, assign the value to a string variable.
wks.col.name$ | Read/write, string | Column name. To read, assign the value to a string variable.
wks.col.subformat | Read/write, numeric | Subformat options as listed in the Display drop down list of the Worksheet Column Format dialog box.
wks.col.tWidth | Read/write, numeric | Number of characters allowed in a text column.
wks.col.type | Read/write, numeric | Column type: 1 = Y, 2 = disregard, 3 = Y Error, 4 = X, 5 = Label, 6 = Z, and 7 = X Error.
wks.col.width | Read/write, numeric | Column width, in units of characters.

  • This script sets column 1 of the active window to be an X column.

wks.col1.type = 4;

  • This script loops over the selected columns in the Data1 worksheet. The script prints the names of all of the columns to the Script window.

loop (var, Data1!wks.c1,Data1!wks.c2)

{

%A = Data1!wks.col$(var).name$;

type “%A”;

};

Wks.Col

The col object is a sub-object of the wks object.

Object type: Window

Properties:

Examples:


Wks.Export

The export object is accessed using the following syntax:

[winName!]wks.export.property =

WinName! is optional. If winName! is not specified, the active worksheet is affected.

Property | Access | Description
wks.export.c1 | Read/write, numeric | First column in the data range to be included with the data file. Set to 1, 2, ... n. To include all data, set to 1 (default).
wks.export.c2 | Read/write, numeric | Last column in the data range to be included with the data file. Set to 2, 3, ... n. To include all data, set to 0 (default).
wks.export.cntrl | Read/write, numeric | Include or exclude column names and labels with the data file and export a range of data. The value of this property controls export of Column Names, All Data, and Column Labels as follows:
wks.export.r1 | Read/write, numeric | First row in the data range to be included with the data file. Set to 1, 2, ... n. To include all data, set to 1 (default).
wks.export.r2 | Read/write, numeric | Last row in the data range to be included with the data file. Set to 2, 3, ... n. To include all data, set to 0 (default).
wks.export.separator$ | Read/write, string | Specify the separator for use in the data file. The default separator is “\t”. The syntax is as follows: wks.export.separator$ = “,” for a comma separator.

* The range selected by the C1, C2, R1, and R2 properties will be used as long as there is no selection or only a single cell selected in the worksheet. If any other selection is active in the worksheet, that selection will be used.

* If exported, column names are copied to the first line of the data file with the designated separator, followed by <CR>, then the labels (if exported), then the data.

Value | Column Names | All Data | Column Labels
0 | NO | NO* | NO
1 | YES* | NO* | NO
2 | NO | YES | NO
3 | YES* | YES | NO
4 | NO | NO* | YES
5 | YES* | NO* | YES
6 | NO | YES | YES
7 | YES* | YES | YES

  • This script specifies the column range, row range, and separator for data export. It also specifies that the column names be exported with the file.

wks.export.c1 = 2;

wks.export.c2 = 4;

wks.export.r1 = 2;

wks.export.r2 = 12;

wks.export.cntrl = 1;

wks.export.separator$ = ",";

getfile *.dat; // get a file name to use

save -wh %H %A; // export the active window (must be wks)

Wks.Export

The export object is a sub-object of the wks object.

Object type: Window

Properties:

Examples:


The import object is accessed using the following syntax:

[winName!]wks.import.property =

WinName! is optional. If winName! is not specified, the active worksheet is affected.

Property | Access | Description
wks.import.maxTest | -- | Not currently implemented.
wks.import.minBlock | -- | Not currently implemented. The number of lines to be used for data file structure testing.
wks.import.partial | Read/write, numeric | When importing an ASCII file using open -w fileName, open the Import Verification dialog box before importing the file: 1 = enable, 0 = disable.

Wks.Import

The import object is a sub-object of the wks object.

Object type: Window

Properties:


Function Reference

Introduction to Functions

Utility Functions

Mathematical Functions

Statistical Functions


Introduction to Functions

Each function returns either a single value or a range of values (a dataset), depending on the type of function and the arguments supplied. Unless otherwise specified, all functions will return a range if the first argument passed to the function is a range, and all functions will return a value if a value is passed.

Note: LabTalk now accepts any space intervals except for those in function names. For example,

col ( c ) = col ( a ) - col ( b ); is now supported,

but

col ( c ) = c ol ( a ) - co l ( b ); is not supported.


Utility Functions

Basic Worksheet Functions

Dataset Generation Functions

Dataset Manipulation Functions

Dataset Information Functions

Miscellaneous Functions


Basic Worksheet Functions

col(colName)

col(colName)[rowNum]

col(colName)[rowNum]$

wcol(colNumVariable)

wcol(colNumVariable) [rowNum]$

cell(rowNum, colNum)


col(colName)

The col(colName) function returns the dataset which has the column name colName in the active worksheet. The column number can be specified instead of the column name. For example, if column A is the first column in the worksheet, col(1) and col(A) both return the dataset in column A.

Example:

col(C) = (1+col(A)) / (1-col(B));


col(colName)[rowNum]

The col(colName)[rowNum] function returns the numeric value of a single dataset element. The column name (or column number) is indicated in parentheses, while the row number is included in brackets. Origin returns the value of the cell specified by the given row and column numbers.

Example 1:

myVar=col(B)[3];

In this example, the variable myVar is assigned the value in the third row of column B.

Example 2:

col(B)[4]=9;

In this example, the fourth cell of column B is assigned the value 9.


col(colName)[rowNum]$

The col(colName)[rowNum]$ function returns a single text dataset element. Indicate the column name or column number in parentheses and the row number in brackets. Origin returns the text of the cell specified by the given row and column numbers.

Example:

%W = col(A)[3]$;

In this example, the variable %W is assigned the text element in the third row of column A.


wcol(colNumVariable)

The wcol(colNumVariable) function returns the dataset from the active worksheet that corresponds to the given column number set in colNumVariable (counting from left to right with the first column as 1). This function is different from the col(colName) function in that colNumVariable is always interpreted as a value, such that you can use any expression to specify the column number.

Example:

for (ii = 1; ii <= 10; ii += 1)

{

wcol(ii) = data(ii, ii+10);

};


wcol(colNumVariable) [rowNum]$

The wcol(colNumVariable)[rowNum]$ function sets or returns a single text dataset element. Indicate the column name (using a variable) or the explicitly specified column number in parentheses and the row number in brackets. Origin returns the text of the cell specified by the given row and column numbers.

Example 1:

%W=wcol(k)[3]$;

In this example, the variable %W is assigned the value in the third row of column k.

Example 2:

wcol(k)[4]$="Apples";

In this example, the fourth element of column k is assigned the value "Apples".


cell(rowNum, colNum)

The cell(rowNum, colNum) function gets or sets values in the active worksheet or matrix. Indicate the row number and column number in parentheses.

Note: To specify a worksheet other than the active worksheet, use the notation: wksName!cell(rowNum, colNum). This notation is not supported for other worksheet functions.

Example 1:

%W = cell(50, 3)$;

In this example, the variable %W is assigned the value in row 50 of the third column in the active worksheet.

Example 2:

Data3!cell(5, 2) = 100;

In this example, the fifth cell of second column in the Data3 worksheet is assigned the value 100.


Dataset Generation Functions

data(x1, x2, inc)

{v1, v2, ...vn}

Fit(Xdataset)

Table(Dataset1, Dataset2, Dataset3)


data(x1, x2, inc)

The data(x1, x2, inc) function creates a dataset with an initial value of x1, a final value of x2, and an increment equal to inc. If x1 is set equal to x2, inc number of points with values equal to x1 are returned. If inc is omitted, inc = 1 is assumed.

Example 1:

col(A) = data(10, 10, 5);

This function fills the first five rows of column A with the number 10.

Example 2:

col(A) = data(1,100);

This function fills column A with 100 numbers from 1 to 100, with an increment of one.


{v1, v2, ...vn}

The {v1, v2, ...vn} ‘function’ returns a range that consists of the specified values. Note that v1, v2,...vn are literal values, meaning the actual values are entered.

Example:

col(A)={1, 2, 4, 5, 12, 13};

In this example, the first six elements in column A are assigned the corresponding ‘function’ values. If column A had more than six elements, only the first six elements would be changed.


Fit(Xdataset)

The Fit(Xdataset) function creates a dataset corresponding to the fitted line generated during nonlinear fitting. The parameters and equation used in the most recently performed nonlinear fitting session are applied to the specified X dataset. The function returns a value for each element of the X dataset.

For example, if you perform a fit on data with an X range from 0 to 100, then you could generate a new fit curve using the following lines of script:

Data1_C = data(0, 100, 20);

//Make dataset corresponding to same range

//but with different increment

Data1_D = fit(data1_C);

//Employ last fit parameters to this X dataset


Table(Dataset1, Dataset2, Dataset3)

The Table(Dataset1, Dataset2, Dataset3) function is used after performing linear or nonlinear fitting and returns a dataset of X or Y values, depending on the order of the dataset arguments.

Example 1: The following script returns new Y values from a fit curve:

linearfit_Ynew = Table(linearfit_a, linearfit_data1b, linearfit_b)

where linearfit_a is the X fit dataset, linearfit_data1b is the Y fit dataset, and linearfit_b holds the X values for predicting Y values.

Example 2: The following script returns new X values from a fit curve:

linearfit_Xnew = Table(linearfit_data1b, linearfit_a, linearfit_b)

where linearfit_data1b is the Y fit dataset, linearfit_a is the X fit dataset, and linearfit_b holds the Y values for predicting X values.


Dataset Manipulation Functions

sort(dataset)

diff(dataset)

peaks(dataset, width, minHeight)

corr(dataset1, dataset2, k[, N])

tReplace(dataset, value1, value2 [, condition])


sort(dataset)

The sort(dataset) function returns a dataset that contains dataset, sorted in ascending order. This function only affects dataset. It has no effect on other datasets in the worksheet.

This function contrasts with the Sort menu command in that the Sort menu command will rearrange the corresponding values in other columns in the worksheet.

See also: sort command and the sort object.


diff(dataset)

The diff(dataset) function returns a dataset that contains the difference between adjacent elements in dataset. If there are N elements in dataset, the returned range will have N-1 elements. The first element in the returned range is equal to the difference between the second and the first element of the given range.


peaks(dataset, width, minHeight)

The peaks(dataset, width, minHeight) function returns a dataset containing indices of peaks found using width and minHeight as a criteria. Width is the number of points on either side of the test point and minHeight is in Y axis units. A peak at a given index i is minHeight greater than the data value at i-width or i+width.


corr(dataset1, dataset2, k[, N])

The corr(dataset1, dataset2, k[, N]) function returns the correlation between two datasets using a lag size of k and an optional number of points N.

For example, let f and g be two datasets. The cross correlation between the two datasets for the first N points using a lag size of k is defined as:

If f and g are identical datasets, then the result is the auto-correlation.

Example 1:

col(3) = corr(col(1), col(2), data(1, 10), 50);

This script results in the cross correlation of the first 50 points of col(1) with col(2) using lag sizes from 1 to 10.

Note: The lag argument (k) can be a scaler or a vector. When k is a vector, the correlation function returns a vector. Similarly, when k is a scaler, the correlation function returns a scaler.


tReplace(dataset, value1, value2 [, condition])

Data1_result = treplace(Data1_A, 1.5, 999, condition);

Values of Data1_Result for various conditions:

Data1_A | 1 | 2 | 3 | 5 | 13 | 14
2 | 2 | 2 | 2 | 999 | 999 | 999
1.5 | 1.5 | 999 | 999 | 1.5 | 1.5 | 999
1 | 999 | 1 | 999 | 999 | 999 | 1
0 | 999 | 0 | 999 | 999 | 999 | 0
-1 | 999 | -1 | 999 | 999 | 999 | -1
-1.5 | 999 | -1.5 | 999 | 999 | -1.5 | 999
-2 | 999 | -2 | 999 | 999 | 999 | 999
Data1_A | 22 | 25 | 32 | 36 | 49 | 63
2 | 999 | 2 | -- | 999 | -- | 999
1.5 | 999 | 1.5 | -- | -- | -- | 999
1 | 1 | 999 | -- | -- | 999 | --
0 | 0 | 999 | -- | -- | 999 | --
-1 | -1 | -999 | -- | -- | -999 | --
-1.5 | -1.5 | -1.5 | -- | -- | -999 | -999
-2 | -2 | -2 | -- | -- | -999 | -999

If you assign the results to the same dataset as the first argument, the original data may be changed.

The treplace() function is designed to be much faster than the similar ternary operator.

tReplace(dataset, value1, value2 [, condition])

The Threshold Replace function treplace(dataset, value1, value2 [, condition]) returns a dataset. Each value in dataset is compared to value1 according to the condition. When the comparison is true, the value may be replaced with value2 or -value2 depending on the value of condition. When the comparison is false, the value is retained or replaced with a missing value depending on the value of condition.

The condition argument is optional and represents a sum of the following bit values (Bit, Value, Condition):

Bit | Value (bit value) | Condition | Result
0 | 1 | 1 | 1 = Use Less Than in the comparison; 0 = Do not consider Less Than.
1 | 2 | 2 | 2 = Use Equal in the comparison; 0 = Do not consider Equal.
2 | 4 | 4 | 4 = Use Greater Than in the comparison; 0 = Do not consider Greater Than.
3 | 8 | 8 | 8 = Use the absolute value of dataset in the comparison; 0 = Use value of dataset.
4 | 16 | 16 | 16 = Keep original sign when replacing; 0 = Use value2 regardless of original sign.
5 | 32 | 32 | 32 = When comparison fails, replace dataset with a missing value; 0 = Leave dataset alone.

You can calculate the value of condition by adding the Value number (above) for all those conditions which should apply. Note that the first four bits affect the way the comparison is made, while the last two bits affect the action as a result of the comparison.

If value1 is a missing value, then testing will only look at the Equal bit (bit value = 2) and ignore bit values 1, 4, and 8. If this bit is set to 2, then each value in dataset is tested to see if it is a missing value. All missing values in dataset are replaced with value2. If this bit is set to 0, then each value in dataset is tested to see if it is not a missing value. All non missing values in dataset are replaced with value2.

When the optional condition is not specified, the function assumes its value is 12 which is the sum of 4 and 8: Replace dataset with value2 if the absolute value of dataset is greater than value1.

When the first three bits of condition are all zero (0, 8, 16, 24, 32, 40, 48 and 56), the comparison is always false.

When the first three bits are all one (7, 15, 23, 31, 39, 47, 55 and 63), the Less Than condition is ignored.

When Less Than and Greater Than are both set and Equal is not (5, 13, 21, 29, 37, 45, 53 and 61), the comparison is equivalent to Not Equal.

Example:


Dataset Information Functions

IsMasked(index, dataset)

FindMasks(dataset)

hasx(dataset)

xof(dataset)

errof(dataset)

xvalue(i, dataset)

xindex(x, dataset)

xindex1(x, dataset)

list(value, dataset)


IsMasked(index, dataset)

The IsMasked(index, dataset) function returns the number of masked points in dataset if index = 0. If index is supplied, this function returns the "mask state" of the index number data point: 1 = masked, 0 = not masked.


FindMasks(dataset)

The FindMasks(dataset) function returns a dataset that contains the indexes of the masked data points.


hasx(dataset)

When a graph window is active, the hasx(dataset) function returns 1 if dataset is plotted against an X dataset in the active layer. If not, this function returns 0.

Note that dataset may be plotted against an X dataset in one layer, but may be plotted against row number or incremental values in another layer. Thus, the active layer can affect the return value of this function.


xof(dataset)

The xof(dataset) function returns a string containing the X values of dataset.


errof(dataset)

The errof(dataset) function returns the dataset (error column) containing the error values of dataset.


xvalue(i, dataset)

The xvalue(i, dataset) function returns the corresponding X value for dataset at row number i in the active worksheet.


xindex(x, dataset)

The xindex(x, dataset) function returns the index number of the first cell in the X dataset associated with dataset, where the cell value is less than or equal to x.

Requirements:

  • dataset must be a designated Y dataset.

  • The Y dataset name must correspond to an actual Y dataset.

  • The X dataset must be sorted in ascending order.


xindex1(x, dataset)

The xindex1(x, dataset) function returns the index number of the first cell in the X dataset associated with dataset, where the cell value is greater than or equal to x.

Requirements:

  • dataset must be a designated Y dataset.

  • The Y dataset name must correspond to an actual Y dataset.

  • The X dataset must be sorted in ascending order.


list(value, dataset)

The list(value, dataset) function returns the index number in dataset where value first occurs. If there is no match, the function returns 0. Note that this function makes an “exact” comparison using the equal (==) operator.


Miscellaneous Functions

colnum(colName)

color(name)

date(MM/DD/YY HH:MM)

exist(name)

exist(fileName, n)

exist(winName, n)

hex(string)

asc(character)

font(name)


colnum(colName)

The colnum(colName) function returns the column position number of the column specified by colName.

Example:

Variable = ColNum(B);

This script sets Variable to 2 if column B is the second column of the current worksheet.

The argument for this function can also be a dataset name. For example, Data1_B or Book1_B@2 (for a dataset in a workbook). When supplying a workbook dataset name as the argument, the dataset need not be in the active workbook sheet. It also need not be in the active workbook. If the dataset exists in a workbook that isn't active, this function sets the associated workbook layer active but doesn't set the workbook active.


color(name)

The color(name) function returns a number corresponding to the index in the color list of the color specified by name.


date(MM/DD/YY HH:MM)

The date(MM/DD/YY HH:MM) function returns the Julian-day value which Origin uses internally to represent dates. The format of the date (shown here as MM/DD/YY) is determined by the short date format of your Windows regional setting. The integer part is the number of Julian days and the fractional part is the fraction of a 24 hour day.

The date() function will accept time arguments of fractional seconds, such as:

n = date(11/3/1999 08:07:06.54321);

However, due to the small magnitude of fractions of a second, the large magnitude of the Julian date value for dates in the 20th century, and the limited (8 byte) memory for numbers, round-off errors limit the entry of fractional seconds to about 4/100000 of a second (40 microseconds).

Example:

col(2)[3] = date(5/7/99);

This script sets the third cell of the second column to 5/7/99 if the column format is set to date.


exist(name)

The exist(name) function returns a single value indicating what ‘object type’ the given name is associated with:

Value | Object type
0 | None. Name is not defined.
1 | dataset
2 | worksheet
3 | graph window
4 | variable
5 | matrix
6 | macro
7 | tool
9 | notes window

Note: A matrix is also a dataset. If you delete a matrix window without deleting the data, the exist(name) function will return 5 before deleting the matrix window, and 1 after deleting the matrix window.


exist(fileName, n)

Use the exist(filename, n) function to check the version number and date of a DLL. If n = 1, 2, 3, or 4, this function returns the first, second, third, or fourth byte from the version resource. Thus, if the version is 6.107 and n = 3, the function returns 0.

To return the date (in double) of the DLL, set n = 5. This is the same unit as the @D system variable.


exist(winName, n)

The exist(winName, n) function provides information about window activity.

If n = 0, this function returns a non-zero value if the specified window is active and is not hidden. Otherwise, it returns 0.

If n = 10, this function returns a non-zero value if the specified window is active. Otherwise, it returns 0.


hex(string)

The hex(string) function returns the base 10 equivalent to the hexadecimal value represented by the given string. The maximum number of hex characters in the given string is 4.

Example:

hex(A2) = 162;


asc(character)

The asc(character) function returns the ASCII value of the uppercase character in parentheses.


font(name)

The font(name) function returns a number corresponding to the font list index of the font specified by name.


Mathematical Functions

Basic Mathematical Functions

Multi-parameter Functions

Special Functions

Random Number Generators


Basic Mathematical Functions

The basic mathematical functions can be used on datasets as well as on a single variable.

prec(x, p)

round(x, p)

abs(x)

angle(x, y)

exp(x)

sqrt(x)

ln(x)

log(x)

mod(x, y)

rmod(x, y)

int(x)

nint(x)

sin(x), cos(x), tan(x)

asin(x), acos(x), atan(x)

sinh(x), cosh(x), tanh(x)


prec(x, p)

The prec(x, p) function returns a value (or a dataset) such that the numbers contain p places of significance.

Example 1:

This script returns the value 1.23E6 for n.

x = 1234567;

n = prec(x, 3);

Example 2:

In this example, the values in data1_C are assigned to data1_B to 3 places of significance.

data1_B = prec(data1_C, 3);


round(x, p)

The round(x, p) function returns a value (or a dataset) with p decimal places accuracy. See the prec(x, p) function for help with syntax.


abs(x)

The abs(x) function function returns the absolute value of x.

Note: The LabTalk abs function is prototyped as double abs(double x), while the Origin C abs function is prototyped as int abs(int x).


angle(x, y)

The angle(x, Y) function returns the angle in radians measured between the positive X axis and the line joining the origin (0,0) with the point given by (x, y). The returned values range from zero to 2p. Note that angle(0, 0) returns a missing value because the result is undefined.


exp(x)

The exp(x) function returns the exponential value of x. (If x is greater than 667, this function returns a missing value.)


sqrt(x)

The sqrt(x) function returns the square root of x.


ln(x)

The ln(x) function returns the natural logarithm value of x.


log(x)

The log(x) function returns the base 10 logarithm value of x.

Note: The LabTalk log function is based on 10 while the Origin C log function is based on e. The Origin C base 10 logarithmic function is log10.


mod(x, y)

The mod(x, y) function returns the integer modulus (the remainder from division) of integer x divided by integer y.


rmod(x, y)

The rmod(x, y) function returns the real modulus (the remainder from division) of real number x divided by real number y.

Example:

rmod(4.5, 2) = 0.5;


int(x)

The int(x) function returns the truncated integer of x. For example, int(7.9) = 7.


nint(x)

The return value of the nint(x) function is identical to round(x, 0). Therefore, a value of 0.5 gets rounded up (nint(0.5) = 1 and nint(-0.5) = -1).


sin(x), cos(x), tan(x)

The sin(x), cos(x), and tan(x) functions return values of sine, cosine, and tangent for each value of the given x. These and other trigonometric functions can take values in radians, degrees, and gradian. The units are determined by the system.math.angularunits object property (which can also be set in the Options dialog box).


asin(x), acos(x), atan(x)

The asin(x), acos(x), and atan(x) functions return the inverse of the corresponding trigonometric function. x must be within -1 and 1 for asin and acos, or a missing value is returned. x can be any value for atan. Values returned are in radians, degree or gradian, depending on the system.math.angularunits object property (which can also be set in the Options dialog box).


sinh(x), cosh(x), tanh(x)

The sinh(x), cosh(x), and tanh(x) functions are the hyperbolic forms of sin(x) , cos(x), and tan(x), respectively.


Multi-parameter Functions

Multi-parameter functions are used as built-in functions for Origin’s nonlinear fitter. You can view the equation, a sample curve, and the function details for each multi-parameter function by opening the NLSF (Analysis:Non-linear Curve Fit:Advanced Fitting Tool). Then select the function of interest from the Select Function page. Radio buttons are provided to view the equation, sample curve, and details.

For additional documentation on all the multi-parameter functions available from Origin's nonlinear curve fitter, see this PDF on the OriginLab website. This document includes the mathematical description, a sample curve, a discussion of the parameters, and the LabTalk function syntax for each multi-parameter function.

Gaussian Function

Lorentzian Function

Logistic Dose Response Function

Exponential Decay 3 with Offset Function

Exponential Growth 2 with Offset Function

Exponential Associate Function

Boltzmann Function

Hyperbola Function

Double Rectangular Hyperbola Function

Pulse Function

Polynomial Function


Gaussian Function

The formula for the Gauss(x, y0, xc, w, A) function is:

y=y0 + (A/(w*sqrt(PI/2)))*exp(-2*((x-xc)/w)^2)

where:

y0 is the baseline offset.

xc is the center of the peak.

w equals 2 times the standard deviation of the Gaussian distribution (2*s) or approximately 0.849 the width of the peak at half height

A is the area under the peak.


Lorentzian Function

The formula for the Lorentz(x, y0, xc, w, A) function is:

y = y0 + (2*A/PI)*(w/(4*(x-xc)^2 + w^2))

where:

y0 is the baseline offset.

xc is the center of the peak.

w equals the width of the peak at half height.

A is the area under the peak.


Logistic Dose Response Function

The formula for the Logistic(x, A1, A2, x0, p) function is:

y = A2 + (A1-A2)/(1 + (x/x0)^p)

This function produces a sigmoidal curve. See the Boltzmann function for details.


Exponential Decay 3 with Offset Function

The formula for the ExpDecay3(x, y0, x0, A1, t1, A2, t2, A3, t3) function is:

y = y0 + A1*exp(-(x-x0)/t1) + A2*exp(-(x-x0)/t2) + A3*exp(-(x-x0)/t3)


Exponential Growth 2 with Offset Function

The formula for the ExpGrow2(x, y0, x0, A1, t1, A2, t2) function is:

y = y0 + A1*exp((x-x0)/t1) + A2*exp((x-x0)/t2)


Exponential Associate Function

The forumula for the ExpAssoc(x, y0, A1, t1, A2, t2) function is:

y = y0 + A1*(1 - exp(-x/t1)) + A2*(1 - exp(-x/t2))


Boltzmann Function

The formula for the Boltzmann(x, A1, A2, x0, dx) function is:

y = A2 + (A1-A2)/(1 + exp((x-x0)/dx))

where:

A1 is the initial value.

A2 is the final value.

x0 is the center.

dx is a time constant.


Hyperbola Function

The formula for the Hyperbl(x, P1, P2) function is:

y = P1*x/(P2 + x)


Double Rectangular Hyperbola Function

The formula for the Dhyperbl(x, P1, P2, P3, P4, P5) function is:

y = P1*x/(P2 + x) + P3*x/(P4 + x) + P5*x


Pulse Function

The formula for the Pulse(x, y0, x0, A, t1, P, t2) function is:

y = 0 (x < x0)

y = y0 + A*(1-exp(-(x-x0)/t1))^P * exp(-(x-x0)/t2) (x >= x0)


Polynomial Function

The formula for the Poly(x, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) function is:

y = a0 + a1*x + a2*x^2 + ... + a9*x^9

This function evaluates an nth order polynomial for the given x and polynomial coefficients. The order of the polynomial is always assumed to be 9, but you can pass fewer coefficients to the function. All higher order coefficients are set to zero.

Example:

poly(2,1,3);

Returns:

1 + 3 * 2 = 7

In a second form of the function, a dataset is expected to contain the coefficients: Poly(x, dataset)


Special Functions

Bessel Function of Order n

Zero Order Bessel Function

First Order Bessel Function

Bessel Function of Second Kind

Zero Order Bessel Function of Second Kind

First Order Bessel Function of Second Kind

Natural Log of the Gamma Function

Incomplete Beta Function

Beta Function

Incomplete Gamma Function


Bessel Function of Order n

The Bessel function of order n (where n is an integer) has the following form:

Jn(x, n)

The formula for the equation is:

See the gammaln(x) function for the definition of Γ.


Zero Order Bessel Function

The zero order Bessel function has the following form:

J0(x)


First Order Bessel Function

The first order Bessel function has the following form:

J1(x)


Bessel Function of Second Kind

The Bessel function of second kind has the following form:

Yn(x, n)

The formula for the equation is:

where


Zero Order Bessel Function of Second Kind

The zero order Bessel function of second kind has the following form:

Y0(x)


First Order Bessel Function of Second Kind

The first order Bessel function of second kind has the following form:

Y1(x)


Natural Log of the Gamma Function

The natural log of the Gamma function has the following form:

gammaln(x)

This function returns the natural log of the gamma function Г(x), where Г(x) is given by:


Incomplete Beta Function

The incomplete Beta function has the following form:

incbeta(x, a, b)

The formula for the equation is:


Beta Function

The Beta function has the following form:

beta(a, b)

The formula for the equation is:


Incomplete Gamma Function

The incomplete Gamma function has the following form:

incgamma(a,x)

The formula for the equation is:


Random Number Generators

Two functions in this category, rnd() and grnd(), return a value. All the other functions in this category return a range.

rnd(seed) and ran(seed)

grnd( )

normal(npts, seed)

Poisson(npts, mean, seed)

uniform(npts, seed)


rnd(seed) and ran(seed)

The rnd(seed) and ran(seed) functions return a value between 0 and 1 from a uniformly distributed sample. The initial starting value in the range is determined by seed. If seed is a positive integer, the random number generator returns a particular value. For example, if seed = 1, the functions return 0.1711484. If seed is zero or no argument is provided, the random number generator returns the next number in the random number sequence.


grnd( )

The grnd() function returns a value from a normally (Gaussian) distributed sample, with zero mean and unit standard deviation. The initial value returned, and the sequence of values, are the same for each Origin session.

No argument is needed. To obtain a random number from a normal distribution with mean = m and standard deviation = sd, use grnd()*sd+m.


normal(npts, seed)

The normal(npts, seed) function returns a range with npts number of values. The initial starting value in the range is determined by seed. The values are random numbers with a normal (zero mean and unit standard deviation) distribution respectively. If seed is omitted, a different seed is used each time the function is called.

Example:

col(1) = normal(100)*2+5;

This script fills column 1 with 100 random numbers with a mean = 5 and a sd = 2.


Poisson(npts, mean, seed)

The poisson(npts, mean, seed) function returns npts number of random integers having a Poisson distribution with mean mean. Seed is optional.

The algorithm for the Poisson distribution is from Numerical Recipes in C, 2nd edition, pages 293-295.


uniform(npts, seed)

The uniform(npts, seed) function returns a range with npts number of values. The initial starting value in the range is determined by seed. The values are random numbers with uniform (between 0 and 1) distribution. If seed is omitted, a different seed is used each time the function is called.


Statistical Functions

Statistics on Datasets or a Set of Values

Statistical Distributions


Statistics on Datasets or a Set of Values

All of the following functions except ss(), min(), and max() return a range.

max(values)

min(values)

histogram(dataset, inc, min, max)

sum(dataset)

ave(dataset, size)

percentile(dataset1, dataset2)

ss(dataset, ref)

ss(dataset)

ss(dataset, 4)

ss(dataset1, dataset2)

ss(dataset, A+B.x)

cov(dataset1, dataset2, ave1, ave2)


max(values)

The max(values) function returns the maximum value from a set of values. This function can take up to 10 arguments. For example:

y = max(1, 2, 3, 4, 5, 6);


min(values)

The min(values) function returns the minimum value from a set of values. This function can take up to 10 arguments. For example:

y = min(1, 2, 3, 4, 5, 6);


histogram(dataset, inc, min, max)

The histogram(dataset, inc, min, max) function generates data bins from dataset in the specified range from min to max. The bin width is equal to inc. The function will include values that fall on the lower edge of the bin, however the function will put data that falls on the upper edge into the next higher bin.


sum(dataset)

The sum(dataset) function returns a range whose ith element is the sum of the first i elements of the dataset dataset. Therefore, the last element of the range returned by sum(dataset) is the sum of all elements in dataset. This value is also returned in sum.total.

The sum(dataset) function also automatically assigns values to the following sum object properties: sum.mean, sum.total, sum.min, sum.max, sum.sd, sum.n.

Example:

sum(DATA1_A);

If DATA1_A contains 4 values (1, 2, 3, 4), this script returns the range (1, 3, 6, 10) where the second value in the returned range (3) is the sum of the first two values in DATA1_A, etc. The last value in the returned range (10) is the sum of all the values in DATA1_A. The value of 10 is also returned in sum.total.

This function can also be used across worksheet columns using the following syntax:

sum(WorksheetName, col1, col2);

A range is returned that equals the sum of all the columns from col1 to col2. Statistical values are also returned to the sum object properties.


ave(dataset, size)

The ave(dataset, size) function breaks dataset into groups of size size, finds the average for each group, and returns a range containing these values.


percentile(dataset1, dataset2)

The percentile(dataset1, dataset2) function returns a range comprised of the percentile values for dataset1 at each percent value specified in dataset2.

Example:

DATA1_A = normal(1000);

DATA1_B = {1, 5, 25, 50, 75, 95, 99};

DATA1_C = percentile(DATA1_A, DATA1_B);

The result contains the percentiles of a normal distribution at 1%, 5%, .. and 99%.


ss(dataset, ref)

The ss(dataset, ref) function is the sum of squares function. The following equation is used to calculate a value for each value in dataset:

The resulting values are added, and a single value is returned. This function can take one of four forms, depending on the reference value ref.


ss(dataset)

The ss(dataset) function is the sum of squares function in which ref is omitted. The function assumes the mean of the data as the reference value.


ss(dataset, 4)

The ss(dataset, 4) function is the sum of squares function in which ref is a constant. The function uses the constant as the reference value.


ss(dataset1, dataset2)

The ss(dataset1, dataset2) function is the sum of squares function in which ref is a dataset. The function uses the corresponding element in dataset2 as the reference value for each dataset1.


ss(dataset, A+B.x)

The ss(dataset, A+B.x) function is the sum of squares function in which ref is an expression involving i or x. If x, the corresponding X value for each element in dataset is used to calculate the reference value. If i, the corresponding row number for each element in dataset is used to calculate the reference value.

Example:

ss(dataset, A+B.x);

This script will calculate the sum of squares for the straight line formed by Y with intercept A and slope B.


cov(dataset1, dataset2, ave1, ave2)

The cov(dataset1, dataset2, ave1, ave2) function returns the covariance between two datasets. Let X and Y be two datasets and [image] and [image] their respective means, then the covariance between the two is defined as:


Statistical Distributions

Ttable(x, n)

invt(value, n)

Ftable(x, m, n)

IncF(x, m, n)

invf(value, m, n)

erf(x)

inverf(x)

prob(x)

invprob(x)

QCD2(n)

QCD3(n)

QCD4(n)


Ttable(x, n)

The Ttable(x, n) function is Student's t distribution with n degrees of freedom.

Student's t distribution is used in calculating the confidence bands in linear regression. x is usually called the significance level.

Examples:

Ttable(0.95, 15) = 1.753

Ttable(0.99, 10) = 2.764


invt(value, n)

The invt(value, n) function is the inverse t distribution function with n degrees of freedom. This function is used to calculate the p-value involving t distributions.

Examples:

invt(1.753, 15) = 0.95

invt(2.764, 10) = 0.99


Ftable(x, m, n)

The Ftable(x, m, n) function is the F distribution function with m and n degrees of freedom. x is usually called the significance level.

The F distribution is used in calculating confidence limits for parameters in nonlinear regression.

Examples:

Ftable(0.95, 2, 15) = 3.68232

Ftable(0.95, 4, 10) = 3.47805


IncF(x, m, n)

The incf(x, m, n) function is the incomplete F-table function. X is the upper limit of integration. M and n are the degrees of freedom.


invf(value, m, n)

The invf(value, m, n) function is the inverse F distribution function with m and n degrees of freedom. This function is used to calculate the p-value involving F distributions.

Example:

invf(3.682, 2, 15) = 0.94999


erf(x)

The erf(x) function is the error function (or normal error integral). The function has the limiting values erf(0) = 0, and erf(∞) = 1. Mathematically:

erf(x) =

Note that erf(-x) = -erf(x) is an even function of x and erf(x) = 2*(Normal Distribution Function evaluated at [image] ) - 1, where the Normal Distribution Function is:


inverf(x)

The inverf(x) function is the inverse error function.


prob(x)

The prob(x) function is the Probability Density (for a normal distribution) integrated from -x to +x.

It has the limiting values prob(0) = 0, and prob(∞) = 1. Mathematically:

Prob(x) =

Note that prob(-x) = -prob(x), prob(x)=erf( [image] ), or prob(x) = 2 * Normal Distribution Function -1.


invprob(x)

The invprob(x) function is the Inverse Probability Density function.

Examples:

prob(1.8) = 0.92814

invprob(0.92814) = 1.8

invprob(prob(1.8)) = 1.8


QCD2(n)

The QCD2(n) function returns a factor (Quality Control D2 Factor) which is used to estimate the standard deviation of a parent distribution (or population) from an average range when the sample size (or subgroup size) n is given.

The standard deviation of the parent distribution = average range/factor.

The returned factors assume sampling from a normal population.

Example:

QCD2(4) = 2.05952

This script returns the factor for a sample size of 4.


QCD3(n)

The QCD3(n) function returns a factor (Quality Control D3 Factor) for determining the 3-sigma lower control limit for R charts (Range of Sample Charts) from the average range when the sample size (or subgroup size) n is given.

The Lower Control Limit for R = (factor)*(Average Range).

The calculations for the factors are based on the normal distribution.

Example:

QCD3(11) = 0.25474

This script returns the factor for a sample size of 11.


QCD4(n)

The QCD4(n) function returns a factor (Quality Control D4 Factor) for determining the 3-sigma upper control limit for R charts (Range of Sample Charts) from the average range when the sample size (or subgroup size) n is given.

The Upper Control Limit for R = (factor)*(Average Range).

The calculations for the factors are based on the normal distribution.

Example:

QCD4(11) = 1.74704

This script returns the factor for a sample size of 11.


Macro Reference

Introduction to Macros

Defining and Displaying Macros

Executing LabTalk Macros

Listing and Deleting Macros

Special Event Driven Macros

Predefined System Macros


In Origin, there is a limit of the number of tokens that can be included between the set of curly braces which enclose a script. This limit is currently set at 1140 bytes (after substitution). If a script exceeds this limit it can be shortened by replacing a portion of its code with a macro command name that has been previously associated with the replaced code. This works because when calculating the number of tokens included between the curly braces of a script, Origin counts the length of any included macro name and not the length of the macro's associated script.

Modular code is beneficial for many reasons. Modular code can improve script readability by replacing unwieldy blocks of code with mnemonic macro names. The readability and maintainability of a script can also be improved by replacing repetitive or similar blocks of code with multiple calls of the same macro. Different arguments can be passed to each macro call, if need be, to individually tailor the code that gets executed. Macros improve the maintainability of scripts by reducing the number of possible modifications required in the future. If modifications to a script are required it is easier to change the code in one reused macro rather than the code in many repeated blocks of code. Macro libraries can also be created which might reduce future development time and costs. Once a macro is written and thoroughly debugged, it can confidently be used to perform its objective anywhere in any script.

Since macros are executed prior to predefined LabTalk commands, if you want to override a LabTalk command (implement your own version of the command) you can accomplish this by creating a macro with the same name as the predefined command. The overriding macro command can be deleted at any time and the predefined command will automatically be restored.

Introduction to Macros

A macro is a convenient method of aliasing a LabTalk script. When you define a macro you are associating an entire script with a specific name. This name can then be used as a command that invokes the associated script. Macros are useful for a number of reasons:

  • Macros can be used to overcome the 1140 byte token limit between curly braces in your script.

  • Macros can also be a useful device when attempting to develop modular code.

  • Macros can be used to override predefined LabTalk commands.


Defining and Displaying Macros

def hello {

loop (ii, 1, 3) {

type "$(ii). Hello World";

};

};

Executing the command define hello in the Script window, after having defined the hello macro as described above, will cause the following text to be printed in the Script window:

define hello;

{

loop(ii, 1, 3) {

type "$(ii). Hello World";

};

}

The script uses the macro.nArg object property to determine the number of times the loop should iterate.

def goodbye {

%Z=%1 %2 %3 %4 %5;

for (ii = 1; ii <= macro.nArg; ii++) {

type "$(ii). Goodbye %[%Z,#$(ii)]";

};

};

Defining and Displaying Macros

To define a new macro or to re-define an existing macro, use the define command. Since macros are defined by executing the define command, macros can be defined anywhere in Origin that allows LabTalk scripts to be executed. However, macros are generally defined in *.CNF files which get executed when Origin is started or in the Script window at run time.

The syntax for the define command is:

define macroName {script}

The define command defines a macro named macroName and associates it with a script {script}. MacroName can then be used like a command which, when executed, invokes the script.

This script defines a macro named hello that uses a loop to print a text string three times in the Script window:

To display a script that has been previously associated with a defined macro, use the define command without the {script} argument:

define macroName

For example:

Macros can be passed up to five arguments. Use the %1, %2, %3, %4, and %5 notation within the script definition to indicate that the macro expects one or more arguments. A macro can accept a number, string, variable, dataset, function, or even a script as an argument. Arguments to an Origin macro function similarly to MS-DOS batch arguments. An executing macro can access the number of arguments passed to it at run time via the macro.nArg object property.

This script defines a macro named goodbye that uses a loop to print out a goodbye message to the Script window for each argument string (up to five) it is passed.


Executing LabTalk Macros

This includes the Script window, the Worksheet Script dialog box, the Label Control dialog boxes, *.OGS files, user-defined Y-script fitting functions, and even other macros.

To execute the script associated with a defined macro inside the Script window:

  1. Type the macro name and press ENTER (see example).

If you type the hello macro command into the Script window and press ENTER (as defined here), the script associated with the hello macro executes and prints the following in the Script window:

hello;

1. Hello World

2. Hello World

3. Hello World

To pass a macro arguments, type the macro name followed by a space separated list of the arguments into the Script window and then press ENTER. The values of the arguments passed will be accessible to the executing script through the use of the variables %1, %2, %3, %4, and %5 (see example).

If you type the macro command goodbye Liane Sarah Amanda into the Script window and press ENTER (after having defined the goodbye macro), the script associated with the goodbye macro executes and prints the following in the Script window:

goodbye Liane Sarah Amanda;

1. Goodbye Liane

2. Goodbye Sarah

3. Goodbye Amanda

  1. Place the macro name along with any arguments you are passing to it in the calling script (terminated with a semicolon) just as you would any other LabTalk command (see example).

To execute the hello macro from inside an OGS file, you include the line

hello;

inside the OGS file.

To execute the goodbye macro from inside a Label Control dialog box, include the line

goodbye Liane Sarah Amanda;

inside the Label Control dialog box.

This script defines a macro named test that takes an argument, types OK if the argument is greater than 2, and then terminates its execution with the return command. If the argument is less than or equal to 2, the macro types Not OK and continues executing until it reaches its last statement.

def test {

if (%1 > 2) {

type "OK";

return;

};

type "Not OK";

type "Keep running until you reach the end!";

};

If you type the command test 3 and press <ENTER>, the macro will print OK and then terminate its execution.

test 3;

OK

If you type test 1 and press <ENTER>, the macro types Not OK and continues to run until it reaches the end of the macro.

test 1;

Not OK

Keep running until you reach the end!

Executing LabTalk Macros

Key points...

  • Macros can be called or executed anywhere that LabTalk scripts can be executed.

  • A script associated with a macro name can be passed up to five arguments.

  • To call or execute a macro from someplace other than the Script window:

  • If you want to design a macro that terminates its execution on a testable condition and then returns control back to the Script window or its calling script, use the return command (see example).


Listing and Deleting Macros

To print a list of all macros currently defined in the Script window, use the List m (without the -) command. To delete a defined macro named macroName, use the Delete -m macroName (with the -) command.


Special Event Driven Macros

There are a number of special events in Origin which trigger the execution of prenamed macros at precise moments in time. The names of the event driven macros are predetermined but the associated script of each event driven macro must be defined by you before the macro is triggered or no code will be executed. You can program the triggered macro to execute any LabTalk commands you want.

AutoExec

BeginSave

DocBegin

DocEnd

EndOpen

EndToolbox

ErrorProc

PointProc

QuitToolbox

TimerProc


AutoExec

To automatically open a file (of a supported file type) when starting Origin you specify the file name at the end of the command line in the Window's Start:Run dialog box or in the Target text box of an Origin shortcut's Properties window. The supported file types include: graph templates (*.OTP), graphs (*.OGG), worksheets (*.OGW), matrices (*.OGM), projects (*.OPJ and *.ORG) and Excel files (*.XLS).

If Origin is not directed to open a specified file at start up and the AutoExec macro is defined, the AutoExec macro is triggered at the end of the Origin start up sequence. The AutoExec macro is generally used to override internal default settings. A minimal and commented out definition of the AutoExec macro can be found in the MACROS.CNF file (found in the Origin software folder). Caution is advised when defining this macro as not defining this macro is part of the normal and recommended start up sequence of Origin.


BeginSave

The BeginSave macro is triggered when the current document (project) or a child window is saved. The BeginSave macro is not triggered when a template is saved. Saving a project or a child window by selecting File:Save Project, File:Save Project As, or File:Save Window As from the Origin main menu or by issuing the save command triggers the execution of the BeginSave macro. Exiting Origin by selecting File:Exit from the Origin main menu, by clicking the Origin close window system icon, or by issuing the exit command (and then electing to save the modified project before exiting) also triggers the execution of the BeginSave macro.


DocBegin

The DocBegin macro is triggered just prior to opening an existing document (project). The DocBegin macro is executed by:

  • Clicking the Open [image] button.

  • Opening an existing project by selecting File:Open from the Origin main menu.

  • Issuing the doc -o or doc -of commands.

The DocBegin macro is unique in that a define statement for the DocBegin macro is contained in the file ORGSYS.CNF (found in the Origin software folder) which gets executed when projects are opened. Since ORGSYS.CNF is executed just prior to the triggering moment for DocBegin, you must either comment out this definition or modify it to define DocBegin as you wish. Otherwise, the default definition of DocBegin (which happens to do nothing) will be the one that gets executed upon being triggered.


DocEnd

Exiting Origin by

  • selecting File:Exit,

  • clicking the Origin close window [image] system icon,

or

  • issuing the exit command,

...triggers execution of the DocEnd macro.

Origin only allows one project to be open at a time, so opening a new project necessitates closing the current project. Consequently, opening a new project by

  • selecting File:New or File:Open from the Origin main menu,

  • clicking the New Project [image] button or the Open [image] button,

or

  • issuing the doc -d, doc -n, doc -o or doc -of commands,

... triggers execution of the DocEnd macro.

DocEnd

The DocEnd macro is triggered by closing the current document (project), either...

  • when you exit Origin.

  • when a new project is opened.

The DocEnd macro is unique in that a define statement for the DocEnd macro is contained in the file MACROS.CNF (found in the Origin software folder). MACROS.CNF is read when Origin starts. The definition for DocEnd (the default definition does nothing) can be commented out or modified as desired.


EndOpen

The EndOpen macro is triggered when Origin is directed to start by opening a specific project (files of type *.OPJ or *.ORG). To automatically open a specific project when starting Origin you specify the project name

  • in the Windows Start:Run dialog box.

  • in the Target text box of an Origin shortcut's Properties window.

For example, typing

C:\...\Origin70.exe MyProject.opj

in the Windows Start:Run dialog box and clicking OK, starts Origin and automatically opens the project MYPROJECT.OPJ.

When Origin is directed to start by opening a specific project, the EndOpen macro is executed immediately after Origin is started and the specified project is fully opened. The EndOpen macro is unique in that a define statement for the EndOpen macro must be contained in a configuration file (files of type *.CNF) and be executed during the Origin start up procedure to ensure that the macro is defined in time for its triggering event. The file MACROS.CNF (found in the Origin software folder) contains a commented out define statement for the EndOpen macro which can be uncommented and modified to insure timely definition.


EndToolbox

The EndToolbox macro is triggered after the getpts [options] npts [(message)] command has been issued and npts points have been selected. A point is selected when you (a) double-click or (b) select with the left or right ARROW key and press ENTER

  • on a data point of the active dataset (for the Data Reader tool).

  • on any point in the active graph window (for the Screen Reader tool).

If you choose to define your own PointProc macro after issuing the getpts command, you must call the EndToolbox macro yourself after npts points have been selected or it will not be triggered. This is because the call for the EndToolbox macro is contained in the PointProc macro that is defined by Origin when the getpts command is issued. The EndToolbox macro is deleted immediately after it is triggered and executed. For more information, see the getpts command.


ErrorProc

The ErrorProc macro is triggered

  • when the LabTalk interpreter detects a #Command Error.

  • when you click the Cancel button in any dialog box.

  • when you click the No button in dialog boxes that do not have a Cancel button.

The ErrorProc macro is deleted immediately after it is triggered and executed. The ErrorProc macro is useful for error trapping.


PointProc

The Data Reader tool or the Screen Reader tool must first be selected before the PointProc macro can be triggered. These tools can be selected by

  • clicking on the Data Reader [image] or Screen Reader [image] buttons (on the Tools toolbar).

  • executing the getpts [options] npts (message)] or dotool tool# commands.

Note that the getpts command defines the PointProc macro for use when it is executed. Consequently, if you use the getpts command and you want to define your own PointProc macro, you must define your version of the PointProc macro after you issue the getpts command.

After the Data Reader tool or the Screen Reader tool is selected, the PointProc macro is triggered whenever you (a) double-click on or (b) select with the left or right ARROW key and press ENTER

  • on a data point of the active dataset (for the Data Reader tool).

  • on any point in the active graph window (for the Screen Reader tool).

The PointProc macro is deleted immediately after it is triggered and executed. For more information, see the getpts and dotool commands.


QuitToolbox

The QuitToolbox macro is triggered whenever a new Tools toolbar tool (other than the Data Reader tool, the Screen Reader tool, or the Data Selector tool) is selected and used.

The QuitToolbox macro is deleted immediately after it is triggered and executed. For more information, see the getpts command.


TimerProc

The TimerProc macro is triggered every cycleLength seconds after executing the timer <cycleLength> command.

Use the timer -k command to turn off the timer and disable the TimerProc trigger.


Predefined System Macros

When Origin starts up it predefines a number of system macros. The define commands for most of these macros are contained in *.CNF files (for example ORGSYS.CNF, MACROS.CNF, etc.) which can be found in the Origin software folder. You can re-define system macros, though it is not recommended because Origin uses them as well. At the very least, you should proceed with extreme caution when you modify a system macro so that no unintended consequences are created.

Some predefined system macros are specialized and are intended to only be used by Origin. Predefined macros that have no practical value to you, that are anachronistic, or that are not entirely functional are not documented in the following Help topics.

Some predefined macros may have practical value to you. These macros can be called by your own scripts:

ArrangeLayers numrows numcols

BeforeIterate

BeginSave

CheckMargins

CheckVar varname value

CheckWksSelection

ClearWorksheet worksheetName

Clr

DBCPage

DoButton objectName

Enlarger.Ctrl

FilterImport fileExtType

FormatFilterImport fileExtType fileExtType

GetEnumTempWks templatewinName

GetEnumWin winName

GetEnumWks winName

GetNamedPlot winName template

GetNamedWin winName

GetNamedWks winName template

Graph dataset

HelpMarker

HideMarker

IconizeNamedWks winName

LSqFit

MvPts dataset

New dataset numPoints

NewFunction

NotReady

NoYOffset

OneQCLine lineNameValue

Pick1Pt

QCLines average

Rescale

Separator numberOfTabs

SetDataRange dataset

SetXYOffset minimumOffset

TestColSet

TimerError

Watch


ArrangeLayers numrows numcols

Arranges all unlinked layers and linked layers having units % of linked layer into numrows rows and numcols columns. Sets units of all layers to % of page. Assumes that the CheckMargins macro is executed just prior to its execution. Will not add layers to pad out up to numrows*numcols layers.

Def ArrangeLayers {

x = 100 - Left - Right - (%2-1)*xGap;

x/=%2; // calculate width in % of page

y = 100 - Top - Bottom - (%1-1)*yGap;

y/=%1;// calculate height in % of page

if (x < 5 || y < 5) {

ty -b "Resulting layers are too small, operation aborted!";

break 1;

};

k = 0;

for (i = 1; i <= %1; i+=1) { // loop for %1 rows of layers

for (j = 1; j <= %2; j+=1) { // loop for %2 columns of layers

for (k+=1;k <=page.nlayers;k+=1) {

// loop through all layers in page

#!k=;

layer -s k;

if (layer.link == 0 || layer.unit != 7) break;

// select unlinked layers

}; // or linked layers having units

// % of linked layer

layer -u 1;

if (%2==1) { // if only 1 column

layer x y [Left+(j-1)*(x + xGap)] [Top+(%1 - i)*(y + yGap)];

}

else { // if more than 1 column

layer x y [Left+(j-1)*(x + xGap)] [Top+(i-1)*(y + yGap)];

}; // end else

}; // end columns for loop

}; // end rows loop

}; // end def

Example:


BeforeIterate

Sets the active layer in the active window to 1.

Def BeforeIterate {Layer -S 1};

Example:


BeginSave

Moves the active window to the end of the Window menu window list.

Def BeginSave {Win -L 0};

Example:


This script separately initializes the variables Left and Bottom to 10, initializes the variables Top, Bottom, xGap, and yGap to their default values described above, and then executes the ArrangeLayers macro.

Left=10;

Bottom=10;

CheckMargins;

ArrangeLayers 4 3;

CheckMargins

Checks to see if the variables Top, Left, Right, Bottom, xGap, and yGap are initialized. If they are not initialized, it initializes them to the values 10, 15, 10, 15, 5, and 5 respectively. CheckMargins is intended to be executed just prior to executing the ArrangeLayers macro.

Def CheckMargins {CheckVar Top 10;

CheckVar Left 15;

CheckVar Right 10;

CheckVar Bottom 15;

CheckVar xGap 5;

CheckVar yGap 5;

};

Example:


CheckVar varname value

Checks to see if the variable varname exists. If it does exist, Checkvar does nothing. If it does not exist, Checkvar creates the variable varname and assigns it the value value.

Def CheckVar {if (exist(%1) != 4) %1=%2;};

Example:


CheckWksSelection

Checks to see if you have selected all or part of a single Z column in the active worksheet. If not, an error message is printed to a message box. If so, it sets the variables nZcol, nYcol, and nXcol to their respective column number designations.

Def CheckWksSelection {

if (wks.c1!=wks.c2 || wks.c1==0 || wks.col$(wks.c2).type!=6) {

type -b "You must select a single Z column";

break 1;

};

nZCol=wks.c2; // z col is selected z col

nYCol=%(%H,@Y-,wks.c2);

// y col is immediately to left of z col

nXCol=%(%H,@X,nYCol);

// x col is first x col in worksheet

};

Example:


ClearWorksheet worksheetName

Clears the worksheet worksheetName and sets the number of rows to 30.

Def { win -o %1 {work -s}; set %1 -er 30; set %1 -begin 0;set %1 -end 0;

set %1 -Update;doc -LP %1;

};

Example:


The following script forces an update of the active graph window. This is the equivalent of the Window:Refresh command.

Clr;

Clr

Forces an update of the active graph window.

Def CLR {plot -CLEAR};

Example:


DBCPage

Opens the Plot Details dialog box with the page icon selected on the left side of the dialog box.

Def DBCPage {Page};

Example:


DoButton objectName

Run the associated script of the object objectName.

Def DoButton {

draw -n %1 -r;

};

Example:


Enlarger.Ctrl

Creates the ZoomRect object in the active graph window. It also creates a graph window named Enlarged. The Enlarged window represents the portion of the original active graph window covered by the ZoomRect object. You can alter the portion of the original graph window that is covered by the ZoomRect object by clicking on the Enlarger tool while pressing CTRL and then dragging out the desired rectangle in the window.

Def Enlarger.Ctrl {

%B=%H;

layer -c; //count datasets in active layer, concat names into %Z

active = page.active;

doc -e Open (win -i); // iconize non minimized windows

GetNamedWin Enlarged; // create or activate graph window

layer -i;

// clean stored style to ensure proper plot info to be added

UserPlot.text$="%B";

// Store User's Plot name into a memory object

layer -i %Z; // plot all layers into Enlarged graph window

win -a %B; // activate unenlarged graph window

layer -s active; // activate layer active

label -p 50 50; // create label in middle of layer

draw -n ZoomRect -File Read ZoomRect.OGO; // read object

win -system Tile;

ZoomRect.script=0;

ZoomRect.dx=(v3-v1);

ZoomRect.dy=(v4-v2);

ZoomRect.x=(v1+zoomrect.dx/2);

ZoomRect.y=(v2+zoomrect.dy/2);

ZoomRect.script=4;

draw -n ZoomRect -Run;

};

Example:


FilterImport fileExtType

Opens the File Open dialog box with the default file extension fileExtType and then imports the selected file. This macro only works with Lotus *.WK? files, *.DIF files, and Quatro *.WKQ files.

Def FilterImport {

GetFileName *.%1;

open -WF %A

};

Example:


FormatFilterImport fileExtType fileExtType

Opens the File Open dialog box with the default file extension fileExtType and then imports the selected file. This macro only works with Excel *.XLS? files and dBASE *.DBF? files. You must type fileExtType twice.

Def FormatFilterImport {

GetFileName *.%2;

open -WE %1 %A

};

Example:


GetEnumTempWks templatewinName

Assuming that no worksheet windows exist which begin with the name MyData, the following script creates three worksheets named MyData1, MyData2, and MyData3 from the template ORIGIN.OTW.

GetEnumTempWks Origin MyData;

GetEnumTempWks Origin MyData;

GetEnumTempWks Origin MyData;

GetEnumTempWks template winName

Counts the number of worksheet windows that exist and match exactly or begin with the name winName. If no worksheet exists, it creates a worksheet with the name winName1 from the worksheet template template. If n worksheets exist, it creates a worksheet with the name winName$(n+1) from the template template.

Def GetEnumTempWks {

doc -cw %2;

%A=%2$(count+1); //Set %A to be the name of the new window

win -th Wks %1 %A;

};

Example:


Assuming that no graph windows exist which begin with the name MyGraph, the following script creates three graph windows named MyGraph1, MyGraph2, and MyGraph3 from the template ORIGIN.OTP, unless MYGRAPH.OTP exists, in which case it will be used.

GetEnumWin MyGraph;

GetEnumWin MyGraph;

GetEnumWin MyGraph;

GetEnumWin winName

Counts the number of graph windows that exist and match exactly or begin with the name winName. If no graph window exists, it creates one with the name winName1. If n graph windows exist, it creates one with the name winName$(n+1). If winName also happens to be the name of a graph template, it will create the graph window from the template WINNAME.OTP. Otherwise, it will use the default template ORIGIN.OTP.

Def GetEnumWin {

doc -cp %1;win -T Plot %1 %1$(count+1)

};

Example:


Assuming that no worksheet windows exist which begin with the name MyData, the following script creates three worksheet windows named MyData1, MyData2, and MyData3 from the template ORIGIN.OTW, unless MYDATA.OTW exists, in which case it will be used.

GetEnumWks MyData;

GetEnumWks MyData;

GetEnumWks MyData;

GetEnumWks winName

Counts the number of worksheet windows that exist and match exactly or begin with the name winName. If no worksheet window exists, it creates one with the name winName1. If n worksheet windows exist, it creates one with the name winName$(n+1). If winName also happens to be the name of a worksheet template, it will create the worksheet window from the template WINNAME.OTW. Otherwise, it will use the default template ORIGIN.OTW.

Def GetEnumWks

{

stat.name(1,%1);

%A = stat.name.worksheet$;

win -T Wks %1 %A;

}

Example:


Assuming that no graph window with the name MyGraph1 exists, the following script creates the graph window MyGraph1 from the template MYTEMPLATE.OTP. After making the graph window SomeOtherGraph the active window, the script re-activates the graph window MyGraph1.

GetNamedPlot MyGraph1 MyTemplate;

Win -a SomeOtherGraph;

GetNamedPlot MyGraph1 MyTemplate;

GetNamedPlot winName template

Checks to see if the graph window winName exists. If so, it makes the graph window winName the active window. If not, it creates a graph window named winName from the template template.

Def GetNamedPlot {

if (exist(%1)==3) win -active %1; else win -T Plot %2 %1;

};

Example:


Assuming that no graph window with the name MyGraph1 exists, the following script creates the graph window MyGraph1 from the default template ORIGIN.OTP. After making the graph window SomeOtherGraph the active window, the script re-activates the graph window MyGraph1.

GetNamedWin MyGraph1;

Win -a SomeOtherGraph;

GetNamedWin MyGraph1;

GetNamedWin winName

Checks to see if the graph window winName exists. If so, it makes the graph window winName the active window. If not, it creates a graph window named winName from the default template ORIGIN.OTP.

Def GetNamedWin {

if (exist(%1)==3) win -active %1; else win -T Plot %1 %1;

};

Example:


Assuming that no worksheet window with the name MyData1 exists, the following script creates the worksheet window MyData1 from the template MYTEMPLATE.OTW. After making the worksheet window SomeOtherWks the active window, the script re-activates the worksheet window MyData1.

GetNamedWks MyData1 MyTemplate;

Win -a SomeOtherWks;

GetNamedWks MyData1 MyTemplate;

GetNamedWks winName template

Checks to see if the worksheet window winName exists. If so, it makes the worksheet window winName the active window. If not, it creates a worksheet window named winName from the template template.

GetNamedWks {

if (exist(%1)==2) win -active %1; else win -T WKS %2 %1;

};

Example:


Graph dataset

Adds the dataset dataset to the layer contents in the active layer of the active graph window. In effect, this plots the dataset dataset in the active layer of the active graph window.

Def Graph {

set %1 -s 1;layer -i %1

};

Example:


HelpMarker

Puts instructions on how to use the Data Selector tool on the status bar.

Def HelpMarker {

doTool -h Move with Ctrl-ArrowKeys, shift with ArrowKeys, hit Enter when\ OK;doToolbox -next;

};

Example:


HideMarker

Removes the Data Markers from the active graph window. This macro is currently not operational.

Def HideMarker {MkS1=-1};


IconizeNamedWks winName

Checks to see if a worksheet named winName exists. If a worksheet with the name winName exists, it minimizes it. If a worksheet with the name winName does not exist, it creates one and then minimizes it.

Def IconizeNamedWks {

if (exist(%1)==2) {

win -o %1 {win -i};

}

else {

win -n data %1;

win -i;

};

};

Example:


LSqFit

Performs a nonlinear least squares fit of the active dataset. The fitting function must be previously specified using the NLSF -f (select the fitting function specified by funcName) command. Depending on the type of fit, additional parameters may also need to be specified.

Def LSqFit {

nlsf -H %C;nlsf -1;nlsf -2;nlsf -3;if(step > 4) (step/=2;nlsf -1;nlsf -2);

if (step>1) (step=1;nlsf -2);nlsf -2;nlsf -t;

};

Example:


MvPts dataset

Opens the Data Reader tool and places it in the active graph window. Writes usage information on the status bar. If the dataset dataset has moveable points, it will allow you to move its data points by clicking and dragging them with the Data Reader tool.

Def MvPts {

def PointProc {{EndToolbox};doTool 0};

doTool -cntrl 3 (Move with arrow keys, hit Enter when OK);

doToolbox -r %1;doToolbox -key;

};

Example:


New dataset numPoints

Creates an empty dataset named dataset having numPoints data points. To verify the existence of the dataset dataset, use the list s command in the Script window. To create a worksheet from the dataset dataset, use the edit dataset command in the Script window.

Def New {

create %1 -n %2;

set %1 -e %2;

};

Example:


NewFunction

Counts the number of datasets that begin with the letter F (function datasets) and opens the function's Plot Details dialog box to create a new function named Fn where n is one more than the number of datasets counted. If the FUNCTION.OTP graph template is not opened before executing NewFunction, then the function dataset Fn is created but not plotted.

Def NewFunction {

doc -cs F;%B=F$(count+1);create %B -f 10;

def ErrorProc [del %B];set %B;del -m ErrorProc;

};

Example:


NotReady

Displays the message "This operation is still under development..." in a dialog box with an OK button.

Def NotReady {

ty -b "This operation is still under development...";

};

Example:


NoYOffset

Initializes the variables p1 and pv1 to zero.

Def NoYOffset {

p1=0;pv1=0

};

Example:


OneQCLine lineNameValue

Draws a horizontal line at Y = lineNameValue across the active graph window. The line is labeled with its given name and its value (i.e. lineNameValue = $(lineNameValue) or CL = $(lineNameValue) ). Window:Refresh or the doc -uw command should be executed after OneQCLine is run to update the graph window. OneQCLine is used by the template QC.OTW which is used to create QC charts.

Def OneQCLine {

draw -Name QC.%1 -L %1;

if (page.active==2&&%1=="Ave")

label -Offset 2 (-10) -Coor X2 %1 -s -n TQC.%1 (CL = $(%1,*4*));

else

label -Offset 2 (-10) -Coor X2 %1 -s -n TQC.%1 (%1 = $(%1,*4*));

}

Example:


Pick1Pt

The following script executes the macro Pick1Pt.

Pick1Pt;

Executing the script:

XPOS=_XPOS;

INDX=_INDX;

edit XPOS;

edit INDX;

immediately after executing the Pick1Pt macro, copies the temporary datasets into permanent datasets and then displays the permanent datasets.

Pick1Pt

Opens the Data Reader tool and places it in the active graph window. Writes usage information on the status bar. If you click on a data point and press ENTER (or double-click on a data point), the temporary datasets _INDX and _XPOS are created. The dataset _INDX contains the row index of the data point clicked on and the dataset _XPOS contains the X value of the data point clicked on.

Def Pick1Pt {

GetPts 1 $EXEmessage.Pick1Pt

};

Example:


QCLines average

Draws, names, and labels three horizontal lines (in the active graph window) at Y = Ave = average, Y = UCL, and Y = LCL. This macro is used by the QC.OTW worksheet template which is used to create QC charts. The value Ave is passed as a parameter to the QCLines macro and the values UCL and LCL are normally calculated by invoking Plot:Statistical Graphs:QC (X bar R) Chart menu command.

Def QCLines {

Ave = %1;

OneQCLine Ave;

OneQCLine UCL;

OneQCLine LCL;

};

Example:


The following script sets layer 2 as the active layer, plots the dataset MyData1_B into the layer, and then rescales the layer to show all data.

layer -s 2; // make layer 2 active

layer -i Mydata1_B; // add MyData1 to layer 2

Rescale; // rescale layer 2

Rescale

Rescales the X and Y axes of the active layer to show all data.

Def Rescale {layer -all};

Example:


Separator numberOfTabs

Prints a separating line consisting of a series of dashes across the Script window. NumberOfTabs is the approximate length of the line measured in tabs.

Def Separator {

repeat %1 {

type -L "---------------"

};

ty;

};

Example:


The following script creates a dataset named MyData1_B, fills it with data values starting at 10 and incrementing by 10 up to 1000, sets the X value for the first data point and the X increment for the dataset MyData1_B, and then displays the dataset in its worksheet.

Mydata1_B = data(10,1000,10);

fitX1 = 10;

fitX2 = 1000;

fitnpts = 100;

SetDataRange MyData1_B;

edit MyData1_B;

SetDataRange dataset

Sets the X value for the first data point and the X increment for the dataset dataset.

Def SetDataRange {

set %1 -f fitX1;

set %1 -i [(fitX2-fitX1)/(fitnpts-1)]

};

Example:


The following script computes and sets the minimum X and Y offsets. If the beginning X value or minimum Y value is less than 10 percent of the X (or Y) data range, then the minimum X (or Y) offset is set to zero.

SetXYOffset 0.1;

SetXYOffset minimumOffset

Computes and sets the minimum X offset (x0) and the minimum Y offset (y0). If the beginning X value or minimum Y value is less than minimumOffset*100 percent of the X (or Y) data range, then the minimum X (or Y) offset is set to zero.

Def SetXYOffset {

minoffset = %1;

x0 = limit.xmin;

if (abs(x0/(limit.xmax-x0)) < minoffset) {

x0 = 0

};

y0 = limit.ymin;

if (abs(y0/(limit.ymax-y0)) < minoffset) {

y0 = 0

};

del -v minoffset;

#!x0 =;y0 =;

};

Example:


TestColSet

The following script checks to see if a single dataset is selected. If so, it integrates the selected dataset and prints the results in the Script window. If not, an error message is printed out and the script is terminated.

TestColSel;

integ %C;

if (MkS1>=0) {

i1=MkS1;

i2=MkS2;

}

else

{

get %C -b i1;

get %C -e i2;

};

ty -a Integ of %C from zero;

ty "i = $(i1) --> $(i2)";

ty "x = $(integ.x1) --> $(integ.x2)";

ty "Area Peak at Width Height";

ty "$(integ.area) $(integ.x0) $(integ.dx) $(integ.y0)";

TestColSet

Checks to see if a single (or part of a single) dataset is selected. If so, nothing is done. If not, the currently executing script is terminated.

Def TestColSel {

if (exist(%C)!=1 || SelC2 > SelC1) {

type -b "$general.Only1YColumn";

break 1;

};

};

Example:


TimerError

Displays the message "Timer Stop" in the status bar, stops executing the TimerProc macro, and removes the current timer.

Def TimerError {ty -q $EXEmessage.TimerStop;timer -k};

Example:


Watch

Displays the elapsed time in seconds in the Script window since Windows startup, since the previous time Watch was run, or since the second -i command was executed, which ever is most recent.

Def Watch {seconds -e v1;type $EXEmessage.ElapsedTime};

Example:


Changes

This is a list of topics that have been changed in the help file. Click the link below to go to the topic, then search on "<*" (without the quotes) to find the specific change on the topic. If the change is in a DHTML drop-down text, there will be another "<*" within the drop-down to show what has changed.

String System Variables - %Y changed documentation

Loop Command

Matrix Command

Menu Command

Open Command

Run Command -p au switch has been added.

Set Command

Window Command

Ascimport Object - entirely new topic

FDlog Object

Ini Object

Layer.axis object

NLSF Object

Page Object

Run Object

Stat Object

System.Project Object


Utility Objects

Utility objects are generalized objects. These objects do not have a visual counterpart in the Origin project. Utility objects allow you to set preferences that affect the entire active Origin session. The default values for most of these properties are set in the OPTION.CNF file which is read when Origin is launched. Many of the default values may also be changed during an Origin session in the Options dialog box. To open the Options dialog box, select Tools:Options.