1.1 Basic Features
Language Basic FeaturesOrigin C is a high level programming language closely based on the ANSI C programming language. In addition, Origin C supports a number of C++ featuresC++ 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#C# Features 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 BuilderCode 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 FunctionHello 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.
- Click the Code Builder button on Origin's Standard toolbar to open Code Builder.
- In Code Builder, click the New button on Code Builder's Standard toolbar to open the New File dialog.
- Select C File from the list box of the dialog, and then type HelloWorld in the File Name text box.
- Click OK and the new file will be opened in Code Builder's Multiple Document Interface (MDI).
- 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
}
- Click the Build button on Code Builder's Standard toolbar to compile and link the HelloWorld.C source file. The Output window of Code Builder should display as
- Functions, ExecutionNow 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.
- 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.
- 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.
|
|