Open X-Function Builder by clicking Tools: X-Function Builder.
Input the X-Function name in the X-Function edit box.
![]() | Do not give your X-Function the same name as an existing LabTalk macro, OGS file, LabTalk command, or LabTalk callable Origin C function. If two or more of these have the same name, the priority order of calling is: LabTalk macros > LabTalk OGS > X-Function > LabTalk callable Origin C functions > LabTalk commands. |
Name |
Specify the name of the variable. When the X-Function is executed by script, you have to assign values to variables using their names. Therefore, we recommend that you use shorter names and begin them with different characters. |
---|---|
Label |
Specify a label for the variable. Special characters and white space are allowed. Displays on the X-Function dialog as control label. If not specified, variable name will be used. |
Input/Output |
Specify whether the variable is used for input, output or both. |
Data Type |
Specify the variable data type. More details can be referred to below in the Variable Data Type and Default Value section. |
Data |
Specify the default value for the variable. More details can be referred to below in the Variable Data Type and Default Value section. |
Control |
Specify the control for the variable in the dialog box (combo box, slider, etc.). More details can be referred to below in the Control Types section. |
Option String |
Specify an option string for the variable. You can apply advanced settings with option strings, such as grouping several variables together, enabling recalculation, etc. More details can be referred to below in the Option String section. |
Theme ID |
Specify the Theme ID for the variable. If not assigned, the Theme ID of the variable will refer to the index of the variable. The Theme ID is used in the theme file for the X-Function dialog. More details can be referred to below in the Theme ID section. |
X-Functions provide dozens of data types, as below.
After specifying the different control strings in the variables grid Control column in the X-Function Builder, we can easily create different types of user interface controls in the X-Function dialog.
Usage | Data Type | Control String |
---|---|---|
Numeric Edit Box | double | |
Text Edit Box | string | |
Check Box | int | 0|1 |
Combo Box | int |
|
Editable Combo Box | string | Keep empty in the Control column in the Variables grid, but add the codes below to the xfname_before_execute function to set the var variable control as an editable combo box.
if( nGetNDialog > 0 ) trGetN.var.SetAttribute(STR_COMBO_ATTRIB, "|aa|bb|cc"); |
Radio Box | int | Radio:string1|string2|string3 |
Slider | int/double | slider:start|end|nstep |
Color List | int |
|
Graph Browser | string |
Origin supports interface settings for the Graph Browser in an OriginC function, using the control string GraphBrowserFilter. See X-Function Graph Browser Dialog Example for details. |
Text Edit Box with File Browser Button | string |
|
Text Edit Box with Path Browser Button | string |
Note: Set system variable @FBL = 0 will toggle new/old folder browser, i.e. ...Path to open the browse folder dialog, while ...Path2 to open the select folder dialog. |
Text Edit Box with Save As Browser Button | string | ...Save |
We can set the special string in the Option String column to specify the action of a variable. For example, setting the recalculate default mode, setting the number of decimal digits for a numeric control, or setting the default name of an output object. For more details, see Reference: X-Function Option Strings.
The Theme ID is used in the X-Function dialog theme file, and the default value is 0. If you keep the Theme ID of all the variables at 0(default), the Theme ID in the theme file will be converted according to the index of the variable, beginning from 1.
When you want to insert a variable into an existing X-Function (to append a variable as the last, there's no need do this), in order to remain compatible with the existing theme file, you need to:
Click the Tree View button to switch to tree view. The settings in Tree View are mainly used to create X-Function dialogs, add X-Functions to the Origin menu, and add documentation. See the next chapter, Customizing an X-Function, for details.