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
Quick HelpExpand Quick Help
ProgrammingExpand Programming

4.49 FAQ-685 How to configure the Custom Routine button to run your Origin C function?

Last Update: 2/3/2015

The Custom Routine button Button Custom Routine.png on Origin's Standard toolbar executes the LabTalk scripts located in the [Main] section of the Custom.ogs file which is located in your Origin folder. By default, the LabTalk script in the [Main] section is a type statement, which displays a message in an Attention dialog box. To initiate your custom program from this button, you must replace this type statement with a LabTalk call to your function.

To open the Custom.ogs file in Code Builder, press CTRL+SHIFT and click the Custom Routine button on Origin's Standard toolbar. The script file opens in Code Builder. (Alternatively, click the Open button in Code Builder and then select LabTalk Script File (*.OGS) from the Files of Type drop-down list and browse to and open Custom.ogs.)

Once the script file is open in Code Builder, replace the following LabTalk statement:

type -b $General.Userbutton;

with statements to compile, link, and call your source file. After making these changes, save the Custom.ogs file. You can now initiate your custom program by clicking the Custom Routine button in Origin.

For example, if you program the following function in the MyFile.c source file located in the /OriginC subfolder:

void test()
{
	printf("Hello World\n");
}

Then you could enter the following LabTalk code in the [Main] section to compile, link, and call your function:

if (run.LoadOC("MyFile")!=0)
	type -b "Cannot load file";
else
	test;

Save the script file after adding your code.


Keywords:LabTalk, Origin C

 

© OriginLab Corporation. All rights reserved.