System Variables
System-vars
Contents
-
1 Numeric System Variables
- 1.1 X1, X2, X3, Y1, Y2, Y3, Z1, Z2, Z3
- 1.2 MKS1, MKS2
- 1.3 ECHO
- 1.4 X, Y, Z, I, J, E, T, Count
- 1.5 SELC1, SELC2, SELR1, SELR2
-
1.6 V1–V9
- 2 @ System Variables@ System Variable
- 3 Automatically Assigned System Variables
Numeric System Variables
The following variables are reserved for internal use by Origin. Please do not use them as common variables in your script. However, you can read the values to obtain the information or change the values in the recommended way stated below.
X1, X2, X3, Y1, Y2, Y3, Z1, Z2, Z3
These variables can be used to access axis ranges of the active graph layer or the visible range of the active worksheet or matrix.
When a graph window is active, these variables contain the from, to, and increment values for X, Y, and Z axis scales in the active layer. Changing these values can rescale the layer. For example, entering the following script in the Command Window will set the X axis scale range from -3 to 12 incrementing by 3 and make the Y axis scale begin at 0.3:
X1 = -3; X2 = 12; X3 = 3; Y1 = 0.3
When a worksheet or a matrix is active, these variables indicate the columns and rows are visible in the workspace. X1 and X2 contain the index numbers of the first and last columns in view; while Y1 and Y2 contain the index numbers of the first and last rows in view. Thus, to specify the cell displayed in the upper-left corner of the worksheet or matrix, you just need to assign the column and row index of desired cell to X1 and Y1.
MKS1, MKS2
When data markers are displayed in the graph window, MKS1 and MKS2 are set to the index numbers of the data points that correspond to the first set of data markers. When there are no data markers on the graph, both variables are equal to -1. Use the mks X-Function to access all data markers.
ECHO
This variable prints scripts or error messages to the Script window.
To enable echo, type echo = Number in the Script window. Number can be 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 the command and the assignment scripts. Echo = 7, which is a combination of echo = 1, echo = 2, and echo = 4, is useful during menu command selection. |
To disable echo, type echo = 0 in the Script window.
X, Y, Z, I, J, E, T, Count
The variables X, Y, and Z contain the current X, Y, and Z coordinates of the Screen Reader, Data Reader, or Data Selector tools.
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};
The variable I is used to store the index number to a dataset. In most cases, this is the worksheet row number. The variable J is used to store the worksheet column index or worksheet column number (Similarly, the variable J is used for the column index in a matrix and I for row index). These two variables are often used in the Set Values dialog box and when used there, you must refer to them using lowercase letters. Uppercase I and J will be interpreted in Set Values or the F(x)= column label row, as worksheet column short names. When using I (i) or J (j) in your LabTalk scripts, case is not important.
System variable E and T is for internal use, better not to define a user variable by using these two names.
And Count is used by different Origin routines, for example, layer -c, doc -cl, etc.
SELC1, SELC2, SELR1, SELR2
These variables contain the column and row numbers that delineate the current worksheet selection range.
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. |
V1–V9
Variable names v1, v2, ..., v9 should not be used in your scripts.
V1, V1$–V4, V4$
These eight variable names -- v1, v2, v3, v4, plus v1$, v2$, v3$ and v4$ -- are used to store variables and associated values in the page object (see page.info), using this syntax:
page.info.system.formula.vN = x.xx; // N is 1 - 4 and x.xx is a number of type double
page.info.system.formula.vN$ = "string" // N is 1 - 4 and "string" is a string value.
Note that this adds a section named SYSTEM.FORMULA to page.info of the active workbook or matrix window. This section is visible when the window Organizer is displayed (see, for instance, The Workbook Organizer).
For convenience, values can be read or written to the SYSTEM.FORMULA section using the shorthand notation:
page.vN = x.xx;// adds a value to numeric variable vN
page.vN$ = "string";// adds a value to string variable vN$
@ System Variables@ System Variable
The @ system variables are used in Origin to control various behaviors, generally at a much lower level than settings found in Preference: Options. Usually, you will not need to access these variables, but if a change is suggested you can use the Preference: System Variables dialog to store the Variable, Value and Comment.
A complete list of @ System variables can be found in the system variable list.
Automatically Assigned System Variables
Origin automatically creates string variables with project-level scope when certain events occur. Their purpose is to help you keep track of the last-used value of a given object type, such as the last Worksheet used, or the last LabTalk script command that you issued.
If you issue the list vs command you can see the ones that are active in your current project. You can identify them because they are preceeded by a double underscore, as in __LASTWKS or __LastLTcmd.
A list of all such variables is found in the Last Used System Variables.
|