2.4.2.4 Using Origin C Functions
Using-OC-Functions
Besides define LabTalk function, you can also define an Origin C function (see Creating and Using Origin C Code for details) which returns a single value, and call the function from command window. For example,
- Open Code Builder by menu View: Code Builder.
- In Code Builder, create a new *.c file by menu File: New. In the New File dialog, give a file name, MyFuncs for example, and click OK.
- Start a new line at the end of this new file, and add the following code.
double MyFunc (double x)
{
return sin(x) + cos(x);
}
- Click menu item Build: Build to compile and link the file.
- If no error, the function defined above is now available in LabTalk. Run the following script in the Command Window.
newbook; // create a new workbook
col(A) = data(1, 32); // fill row number
col(B) = MyFunc(col(A)); // call the Origin C function, result is put to column B