2.14.2.15 op_change
Brief Information
Get/set/execute operation using a tree
 
Additional Information
This X-Function is not designed for Auto GetN Dialog.
 Minimum Origin Version Required: 8.1 SR2
 
Command Line Usage
1. op_change ir:=FitNL1! tr:=mytr;  // output the tree of an operation.
 2. op_change ir:=col(2) tr:=mytr op:=run; // Set the operation by a tree and run. 
 
X-Function Execution Options
Please refer to the page for additional option switches when accessing the x-function from script
 
Variables
Display Name
 | 
Variable Name
 | 
I/O and Type
 | 
Default Value
 | 
Description
 |  
| 
 | 
ir
 | 
 Input
 Range
 
 | 
 <optional>
 | 
 Specifies the range that contains operation. This X-Function gets treenodes from or triggers the recalculation using settings specified in treenodes in this range.
 |  
| 
 | 
tr
 | 
 Input/Output
 TreeNode
 
 | 
 <none>
 | 
 Specifies the tree name to get or set operation settings.
 |  
| 
 | 
op
 | 
 Input
 int
 
 | 
 0
 | 
 Specified the operation performed on the tree node
 Option list:
 
- get:Get Tree
- Gets settings from input operation object and store them in tree node
 
  
- run:Set and Execute
- Sets and executes the operation settings stored in tree node
 
  
- set:Set Tree Only
- Sets operation settings to tree node only
 
   
 |  
| 
 | 
result
 | 
 Output
 int
 
 | 
 <unassigned>
 | 
 Shows whether the execution succeeds or not. If result = 1, execution succeeds. If result = 0 or -1, execution fails.
 |   
Description
After getting results of an operation, which allows recalculation, it is usually wanted to get access to the operation settings, change some of them and trigger a new recalculation. This X-Function allows you to obtain the operation settings from the input object and store them into a user-defined tree. You can reset the settings and execute the operation again. It is especially useful when you load an Analysis Template and want to change some settings for a new run of analysis.
 
Examples
This example shows how do a smoothing and then modify input and some parameters and update the result with op_change X-Function.
 
newbook;
col(1)={1:32}; //Fill first column with numbers from 1 to 32
col(2)=col(1)+rnd(); //Fill second column with column 1's value plus random numbers.
col(3)=col(1)+3*rnd(); //Create and fill third column with column 1's values plus 3 times random numbers
worksheet -s 2 0; //select 2nd column
smooth -r 2; //do smoothing on selected column and set recalculation mode to manual
op_change ir:=col(4) tr:=mytree; //get smooth settings to mytree 
mytree.xfGetN.iy.Range1.Y$="[%H]Sheet1!C"; //change input Y value to be column C. Note: User can run mytree.= to see the contents in tree
mytree.xfGetN.npts=10; //change npt variable (points of window) to be 10
op_change ir:=col(4) tr:=mytree op:=run; //recalculate smoothing by using changed settings in mytree: col C as input and npts=10
This example modifies the polynomial fitting's settings with op_change X-function.
 
newbook name:="Curves" result:=bkn$;
// import file from Origin EXE path.
string fn$= system.path.program$ + "\Samples\Curve Fitting\Polynomial Fit.dat" ;
impASC fname:= fn$
options.sparklines:=0 
options.FileStruct.NumericSeparator:=0 
options.Names.FNameToSht:=0 
options.Names.FNameToBk:=0 
options.Names.FNameToBkComm:=0;
// use fitpoly X-function to carry out polynomial fit for the XY dataset in the first two columns.
// use the "-r" switch option to set the recalculation mode to "Auto". 
fitpoly iy:=[%(bkn$)]!(1,2) polyorder:=2 
        coef:=<new> oy:=[<Input>]<new>!<new> 
        AdjRSq:=arsq RSqCOD:=rsq -r 1;
// get a range variable that contains this operation, which will be used later. 
range r1 = [%(bkn$)]%(page.active$)!col(1);
// get the setting in the operation as the tree variable mytree. 
op_change ir:=r1 tr:=mytree;
// change the settings of the operation.
// change the input data
mytree.xfGetN.iy.Range1.Y$ = "[%(bkn$)]1!C";
// change the polynomial order
mytree.xfGetN.polyorder = 3;
// execute the operation again with the modified settings. 
op_change ir:=r1 tr:=mytree op:=run;
             |