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


X-Functions provide a structured programming environment that offers a framework for building Origin tools. Different from previous GetN box, creating tools by using X-Functions allows the user to focus on the actual data processing code and not have to worry about codes for the user interface.

Most of the dialogs/functions in Origin 8.1 are X-Functions, and many of them can be run from both menu and command line mode. The flexibility of running X-Functions makes them an attractive approach to customizing Origin.

Running X-Functions in Origin

You might ask "Where are the X-Functions and how can I run them?" Actually, X-Functions are everywhere in Origin. Many dialogs in Origin are X-Function based, and according to the X-Function settings, you can either run it on the menu or in the Command Window.

Running the X-Function in GUI mode and in the command window are consistent. All the settings and inputs in GUI are X-Function variables and can be set in command line mode. Because the command line mode prevents popping up the dialog, it will make the X-Functions run faster when inputting large datasets.

In Origin 8.1, we have introduced the range concept into X-Functions, this mechanism makes the X-Functions data sensitive. For example, the image process X-Functions are only available when a Matrix window is active.

Because most of the X-Functions are LabTalk accessible, they actually extend the functionality of LabTalk. For example, to import data and plot a scatter graph, you can write script using LabTalk commands like:

string fn$ = system.path.program$;
fn$ += "Samples\Curve Fitting\Gaussian.dat";
open -w %(fn$);
worksheet -s 2 0 2 0;
worksheet -p 201 scatter;
set %C -c 4;

Or you can also include X-Functions in your script:

string fn$ = system.path.program$;
fn$ += "Samples\Curve Fitting\Gaussian.dat";
impasc fn$;
plotxy i:=Col(B) p:=201 s:=10 c:=4;

Illustrated in the above script, X-Functions are more powerful than LabTalk commands. For example, the plotxy X-Function allows the user to create graphs, set the plot type, specify symbol size and color in one line. Furthermore, you don't need to look up the command reference often, simply typing xfname -h will show you a brief description about the X-Function.

Creating User-defined X-Functions

It is quite easy for users to create their own tools. The X-Function Builder has a graphical interface for users to set-up a X-Function framework. Once you confirm the settings, things such as input/output variables, code for GUI or script programming capability are already done for you. With X-Functions, you can focus on the core functionality coding.

For example, if you set the X-Function as accessible from the main menu and save it to a valid folder like Mathematics or Statistics, you can run your own X-Function on the Origin main menu.


The X-Function Builder

Set the X-Function as menu accessible in the X-Function builder and save it in the Mathematics folder, then you can run this Function on the Origin main menu.

Once the X-Function was created, you can go further to make this X-Function perfect. For example, use the xf2doc command to generate a Microsoft® Word file, and edit the usages, description and detail algorithm about this function. Later, use the doc2xf command to push this document back to the X-Function. Then other users can easily get help from the document when sharing this X-Function.

Sharing X-Functions

The X-Function framework makes sharing X-Functions quite easy. One can simply drag-and-drop the X-Function file (.OXF) into Origin workspace, the X-Function will be compiled and installed automatically.

For group licence users, sharing the X-Functions will be even more convenient. For example, if there are new X-Functions on the server, once a user opens Origin on a client machine, Origin will automatically pop up a message to ask the user to install the new X-Functions.


Microsoft® Word is a registered trademark of Microsoft Corporation.

Skip Navigation Links.
© OriginLab Corporation. All rights reserved.