4.49 FAQ-685 How to configure the Custom Routine button to run your Origin C function?
Last Update: 7/9/2021
The Custom Routine button 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 (keyboard shortcut: ALT + F5).
For example, if you program the following function in the MyFile.c source file located in the /OriginC subfolder:
Then you could enter the following LabTalk code in the [Main] section to compile, link, and call your function:
type -b "Cannot load file";
Save the script file after adding your code.
Keywords:LabTalk, Origin C