OriginPro – OriginLab - Programming

Programming Origin and OriginPro

Origin provides a number of tools to import, analyze, plot, represent, and export data. The more familiar you get with Origin, the more you might want to create customized programs in Origin, using these options. Origin contains two standard programming languages: Origin C and the scripting language LabTalk™, both of them aiming at making the definition of your own programs easier for you. Furthermore, Origin offers a structured programming environment, providing you with a framework for creating Origin tools - the so-called X-functions.

Origin C

A sample of typical Origin C code with syntax coloring in Code Builder

A sample of typical Origin C code with syntax coloring in Code Builder

Origin C is a powerful programming language, supporting ANSI C plus some functions of C++, including strings, complex, vector and matrix data types, as well as internal Origin objects, such as worksheets and graphs.

Origin C is ideal to create data processing and analysis routines, as well as to develop complicated algorithms. See examples and Origin C help file.

Programs written in Origin C are compiled and linked to internal Origin objects, which are executed during run-time. Although they are not as fast as machine-executed, actually compiler-created codes, they cause a considerable speed improvement compared to earlier programming options in Origin. Certain tasks, such as computation loops and curve fittings with user-defined fitting functions, are completed 20 times as fast than if executed using LabTalk™, Origin's standard scripting.

To achieve the highest possible speed, Origin C can be linked with (i.e., it can call exported functions from) external dynamic link libraries (DLLs), which are built by using third-party compilers as Microsoft® Visual C++. Origin C's link with DLLs allows to pass address references from Origin's data structures directly to external DLLs, requiring less overhead or unnecessary copying of data than usually when programming in Microsoft® Visual Basic.

Code Builder, the standard development environment of Origin C, provides users with a familiar programming language, including color-coding and state-of-the-art debugging functions.

Use Origin C for any programming task, including:

  • Developing analysis and simulation functions
  • Automating your data analysis and graphing tasks
  • Creating user-defined fitting functions to be used with Origin's curve fitting module, NLFit
  • Linking to external dynamic link libraries (DLL)
  • Calling computational routines from the NAG Library
  • Calling C or Fortran library routines, such as the IMSL library from DIGITAL Fortran, or other public-domain libraries
  • Constructing data acquisition solutions for RS-232, GPIB, and others


The Classic Script Window serves as both a command console and text editor.

The Classic Script Window serves as both a command console and text editor.

LabTalk is a full-fledged scripting language native to Origin, with syntax and structure similar, but not identical, to C. LabTalk incorporates DOS-style commands with option switches and arguments, as well as object properties and methods comparable to those in Visual Basic.

LabTalk is ideal for performing simple tasks, as well as writing and running quick scripts. You can even create customized LabTalk utilities that run by simply clicking a toolbar button.

In addition to the power of Origin C and the simplicity of LabTalk, the two programming languages are closely connected. This connection is responsible for making LabTalk commands and variables accessible for Origin C functions. You can even call Origin C functions from your LabTalk code. This way the possibility to create user-defined programs that can be accessed via toolbar buttons gets very useful. Origin's standard intercommunication between its two programming languages combines the best from both sides and turns the two languages into a robust and powerful programming platform for graphing and analyzing data.


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.

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.

Based on its closely connected programming languages, Origin 8 introduced a new programming mechanism, the X-function. The X-functions provide a framework for the construction of tools in Origin. Most of the tools for analysis and other data processing functions in Origin 8 were implemented using this new framework.

Basically, the X function is an XML file, which is saved and loaded as a special function type. The core of the XML file is an Origin C function, performing the computation of a desired operation. Most X-functions are accessible from the Origin GUI and from the LabTalk Scripting programming environment. A key benefit of X-functions is that an X-function can be called as a dialog, and this dialog is automatically generated by Origin. Thus, the user can focus on the actual data processing code and does not have to think about writing the script for the GUI.

For creating user-defined tools, which require advanced data processing or numerical computation or processing of large datasets, it proves to be a good idea to write this user-defined routine as an X-function. Once the X-function has been created, it is very simple to access it from the GUI and from LabTalk scripting.

NAG Library


O Origin includes the entire Mark 9 Library from the Numerical Algorithms Group, Inc. (NAG). This library offers a wide variety numerical algorithms covering many areas, including: Statistics, Fourier Transforms, Linear Algebra, Regression, Multivariate Analysis, and Principal Component Analysis. NAG functions are accessible from Origin C and allow you to develop applications that require advanced numerical computation.

Calling the NAG Library from Origin

Calling the NAG Library from Origin

The NAG Mark 9 Library includes these numerical computations and other utilities:

  • Complex Arithmetic
  • Zeros of Polynomials
  • Roots of One or More Transcendental Equations
  • Fourier Transforms
  • Wavelet Transforms
  • Quadrature
  • Ordinary Differential Equations
  • Partial Differential Equations
  • Mesh Generation
  • Interpolation
  • Curve and Surface Fitting
  • Minimizing or Maximizing a Function
  • Global Optimization of a Function
  • Linear Algebra
  • Matrix Factorizations
  • Eigenvalues and Eigenvectors
  • Determinants
  • Simultaneous Linear Equations
  • Linear Algebra Support Functions
  • Linear Equations (LAPACK)
  • Least-squares and Eigenvalue Problems (LAPACK)
  • Large Scale Linear Systems
  • Large Scale Eigenproblems
  • NAG Interface to BLAS
  • Simple Calculations on Statistical Data
  • Correlation and Regression Analysis
  • Multivariate Methods
  • Analysis of Variance
  • Random Number Generators
  • Univariate Estimation
  • Nonparametric Statistics
  • Smoothing in Statistics
  • Contingency Table Analysis
  • Survival Analysis
  • Time Series Analysis
  • Operations Research
  • Sorting and Searching
  • Approximations of Special Functions
  • Mathematical Constants
  • Machine Constants
  • Input/Output Utilities

Support for the NAG Library is available with ADDITIVE Professional Service.

For examples of how to call NAG functions from Origin C code, click here.


A Python dialog within Origin

A Python dialog within Origin

Origin provides an embedded Python environment so that you can either run Python in Origin, or use a PyOrigin module to access Origin from Python.

Developer Kit

Dialogs created with Origin C ( Developer Kit)

Dialogs created with Origin C ( Developer Kit)

The Developer Kit is a built-in capability in Origin that allows you to access complex dialog boxes, floating tools and wizard resources created using external compilers such as Microsoft Visual C++®. Resource elements can be accessed and controlled from Origin C.

Custom tools can be packaged with associated files using Origin's Package Manager tool for sharing. The package can simply be dragged and dropped onto another Origin installation to add the custom capability.

Automation Server

Excel calling Origin

Excel calling Origin

Origin can be accessed as an automation server from client applications such as Excel, LabVIEW, MATLAB, or custom tools built using Visual Basic® or Visual C++ .NET. Data can be streamed into Origin and graphed, and tools in Origin such as Gadgets can be used to perform analysis on the incoming data. Post analysis of data can also be performed by pushing data into Analysis Templates™.

A typical client application may involve some, or many, of the following steps:

  1. Launching the Origin application.
  2. Opening a previously customized Origin project or preparing the default project to receive data from the client application.
  3. Sending data (collected from hardware) to Origin workbooks and matrices.
  4. Sending commands to Origin to process the data or have Origin update result columns using the recalculate analysis feature.
  5. Getting results back from Origin worksheets and matrices.
  6. Getting images of graphs and layout pages back from Origin.
  7. Saving the Origin project.
  8. Closing the Origin application.

Once the client closes the connection, the user could later launch Origin and just re-open the saved project for further processing.

A network (server/client) installation of Origin is ideal for taking advantage of this feature. Origin gets installed as a server on one computer and as a client on multiple computers, using a FlexLM license manager. Then, any technician who uses a client machine can be provided with a simple interface, such as an Excel worksheet or in-house Visual Basic application, by the company. These simple interfaces can then use the Origin client installation on their local machine to call the Origin server. In doing so, the technician does not have to learn how to use Origin itself, since all required controls would be on the customized interface.

OriginPro provides additional methods to handle multiple client applications.

© ADDITIVE GmbH. All rights, errors and amendments reserved.

Impressum  /  Datenschutz  /  AGB