13.1 X-Function in OriginXF-Technology
The X-Function Technology
The core component of an X-Function is an Origin C function that performs the specific operation that the function was designed to do. In addition to the Origin C code, the X-Function contains related information such as name, description and default value properties of the input and output variables; whether the X-Function should be accessible from menu and if so, for what Origin window types; and whether the function should be accessible from script and if so, help information on syntax for script access to the X-Function.
A key aspect of building tools using X-Functions is that the person building the tool does not have to be concerned about the tool's graphical user interface. They only need to concern themselves with the function details such as the various input and output variables and their default values, and the core Origin C code that performs the actual data processing. Once the X-Function has been defined and programmed, Origin automatically provides the means for the end user to access the X-Function from the graphical user interface as well as from the programming environment.
Different ways in which the end user can access the X-Function:
- X-Functions can be rendered as dialog boxes which make use of a uniform set controls and like functionality across all functions. Once the X-Function has been defined, the dialog box is auto-generated each time the function is invoked.
- X-Functions can be accessed from the Origin menu such as Analysis or Statistics menu, or can be added to a custom menu created by the user.
- X-Functions can be programmatically accessed from LabTalk script and thus can be executed for example from the Command Window or from script behind a label button.
- The X-Function dialog can be rendered in a special X-Function Panel, as part of a Workbook, Matrixbook, or Graph window.
Accessing X-Functions from Origin Menus
Many of the menu commands in Origin -- particularly those related to data manipulation, analysis, and statistics -- are based on X-Functions. When you invoke one of the associated menu commands, the X-Function is rendered as an interactive dialog allowing you to flexibly specify input data, parameters for the operation, where the results/output should be written, and so forth.
Some Origin menus -- for instance the Analysis and Statistics menus -- are automatically populated with available X-F based tools. Each time you run Origin, the X-Function subfolders in the Origin program folder and your User Files folder are scanned and these menus are populated with X-Functions found in those areas. Each X-Function can also have multiple associated Theme files that contain custom settings for the parameters of the function. Many X-Function driven tools feature fly-out menus, allowing you to select a particular Theme from among pre-saved Themes. This figure shows the Analysis: Signal Processing: Smoothing fly-out menu with two user-defined Themes -- "<Last used>" and "MySmooth."
The creator of the X-Function can set flags in the X-Function definition file that control whether an X-Function should be accessible from the menu and whether a Theme fly-out submenu should be displayed for that item.
Insert Graph shortcut menu item opens an X-Function dialog box that allows you to embed an Origin graph in a worksheet cell.
The Origin menus can also be programmatically controlled, allowing you to create custom menu items that call user-defined X-Functions. For more information on programmatically customizing the menus, please refer to the Programming area of the OriginLab website.
Accessing X-Functions from Script
Most of the System X-Functions that with Origin can be accessed from the script programming environment, for instance, (1) from the Command Window, (2) from sections in OGS script files, and (3) from scripts stored in objects such as a label buttons. Whether an X-Function is callable from LabTalk script is determined by the status of a LabTalk checkbox under the Usage Context node of the X-Function tree. For more information on Usage Context, please refer to the X-Function Builder dialog box.
The new Command Window provides a powerful interface for accessing X-Functions from script, with features such as auto completion and command history. Please refer to the Command Window chapter for further details.
Further details about accessing X-Functions from script. can be found in the Programming Help file.
|