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
All BooksExpand All Books
Origin CExpand Origin C
Origin C Programming GuideExpand Origin C Programming Guide

1.1 Basic Features

Origin C is a high level programming language closely based on the ANSI C programming language. In addition, Origin C supports a number of C++ features including classes, mid-stream variable declarations, overloaded functions, references, and default function arguments. Origin C also supports collections, and the foreach and using statements from the C# programming language.

Origin C programs are developed in Origin's Integrated Development Environment (IDE) named Code Builder. Code Builder includes a source code editor with syntax highlighting, a workspace window, compiler, linker, and a debugger. Refer to Help: Programming: Code Builder for more information about Code Builder.

Using Origin C allows developers to take full advantage of Origin's data import and handling, graphing, analysis, image export capabilities, and much more. Applications created with Origin C execute much faster than those created with Origin's LabTalk scripting language.

Hello World Tutorial

This tutorial will show you how to use Code Builder to create an Origin C function, and then access the function from Origin. Though the function itself is very simple, the steps provided here will help you get started with writing your own Origin C functions.

  1. Click the Code Builder button Button Code Builder.png on Origin's Standard toolbar to open Code Builder.
  2. In Code Builder, click the New button Newfile button.png on Code Builder's Standard toolbar to open the New File dialog.
  3. Select C File from the list box of the dialog, and then type HelloWorld in the File Name text box.
    Ocguide helloworld newfiledlg.png
  4. Click OK and the new file will be opened in Code Builder's Multiple Document Interface (MDI).
  5. Copy or type the following Origin C code beneath the line that reads // Start your functions here.
    int test()          
        printf("hello, world\n"); // Call printf function to output our text
                                  // \n represents the newline character
        return 0; // Exit our function, returning zero to the caller
  6. Click the Build button Button Build.png on Code Builder's Standard toolbar to compile and link the HelloWorld.C source file. The Output window of Code Builder should display as
  7. Now you can use this function in Origin. For example, you can call this function in Origin's Script Window. If the Script Window is not open, select the Window: Script Window menu item from the Origin menu to open it.
  8. Type the function name test in the Script Window and then press the ENTER key to execute the command. The Origin C function will be executed and hello, world will be displayed in the next line.
    Run helloworld in script wnd.png
  9. Besides the Script Window, the function can also be called from the LabTalk Console Window in Code Builder. Select View:LabTalk Console in Code Builder if this console window is not open.

Once an Origin C file has been successfully compiled and linked, all functions defined in the file can be called as script commands from anywhere in Origin that supports LabTalk script during the current Origin session. The function parameters and return value need to meet certain criteria for the function to be accessible from script and there are techniques to make such functions always avaliable. To learn more, please refer to the LabTalk Programming: LabTalk Guide: Calling X-Functions and Origin C Functions: Origin C Functions chapter of the LabTalk help file. This help file is accessible from the Help: Programming: LabTalk main menu in Origin.


© OriginLab Corporation. All rights reserved.