Use the [Startup] section of the Origin.ini to define global constants, variables and functions for use any time you run Origin.
See these topics for more information on scope:
See FAQ-286 for information on defining constants and variables for use across Origin sessions.
[Main] @global = 1; // This function calculates the cube root of a number function double dCubeRoot(double dVal) { double xVal; if(dVal<0) xVal = -exp(ln(-dVal)/3); else xVal = exp(ln(dVal)/3); return xVal; } @global = 0;
FileN=myLTFuncs.ogs
... where N is 1,2,3,etc.
dCubeRoot(8)=
Origin returns:
dCubeRoot(8)=2
See this topic for more information on the Scope of Functions.
When the Origin application is launched, there are multiple events that are triggered. Your LabTalk script can be set to execute with each event using the OEvents.OGS file. This OEvents.OGS file includes several sections that indicate when to run the script, such as, [AfterCompileSystem], [BeforeOpenDoc], and [OnExitOrigin].
The following example demonstrates cleaning the history panel of Command Window on existing Origin.
(Note that Origin C functions can not be run in the [OnExitOrigin] section. If you want to trigger events on exiting Origin, always use LabTalk commands.)
// Delete the files, which keep the history of command window, from the User File folder del -f "%YUpDown_Buffer.txt"; del -f "%YLTHistory.txt";
Ogs1 = OEvents ; Ogs2 = OEvents ; Origin can trigger multiple system events ; Uncomment this line and implement event handlers in OEvents.ogs
Note: More than one event handler file may exist in Origin.ini and the name is not restricted to OEvents.OGS. |
![]() | Origin C functions can be run from other sections of OEvents.OGS such as [BeforeOpenDoc]. View the Compiling, Linking and Loading page in Origin C Programming Guide for an example. Please note that If you need to call Origin C functions from your custom script associated with events, you need to ensure that the Origin C file is compiled and the functions are available for script access. See Loading and Compiling Origin C Functions for details. |