Dialog generated by X-Function

This example shows how to automate the dialog generating procedure by creating X-Function with X-Function builder. You can open X-Function Builder by choosing X-Function Builder on the Tools menu or by pressing F10:


Creating X-Function

The steps below will walk you through the creation of an X-Function that will perform the task of copying data from one column to another column:

  1. With the X-Function builder opened, name the X-Function "CopyCol" and add a second variable by right-clicking on the Variables list and choosing "Add variable". Change the variable names, labels, and other values to match the settings in the dialog below.


2. After you make the necessary changes to the variables, save the X-Function by clicking the Save OXF file button Savebutton.png. When the Save As dialog appears click the Save button.

3. Now we need to write the Origin C code that will do the work for our X-Function. Click on the Code Builder button Cb.png. This will open the X-Function in Code Builder where we can write our Origin C code. In the main function, add the following Origin C code:

ocol = icol;

4. Click the Compile button and then click the Return to Dialog button to go back to X-Function Builder. Click the Save OXF file button.

Launch the X-function dialog

We can test our X-Function now:

  1. Create a new a worksheet with two columns. Fill column A with row numbers and select the whole column by clicking on its heading.
  2. In the Script or Command Window enter "CopyCol -d", without the quotes, and press Enter.
  3. When the dialog appears, keep the default values and click the OK button.

After the X-Function executes, the worksheet will contain a third column which will contain a copy of the data from column A.