184.108.40.206 From Set Values Dialog
Set Values Dialog is useful when calculations on a column of data are based on functions that may include references to other datasets.
The column designated by Set Values is filled with the result of an expression that you enter (the expression returns a dataset). The expression can be made to update automatically (Auto), when requested by the user (Manual), or not at all (None).
For more complex calculations, where a single expression is not adequate, a Before Formula Scripts panel in the dialog can include any LabTalk script.
Auto and Manual updates create lock icons, and respectively, at the top of the column. A green lock indicates updated data; A yellow lock indicates pending update; A red lock indicates broken functionality.
In cases where the code is self-referencial (i.e. the column to be set is included in the calculation) the Auto and Manual options are reset to None.
Below are two examples of script specifically for the Set Values Dialog. Typically short scripts are entered in this dialog.
Expression using another column
While limited to expressions (the right side of an equation) as in:
// In column 3
// Scale a column - useful for fitting where very large
//or very small numbers are problematic
the conditional expression can be useful in some situations:
// Set negative values to zero
Using Before Formula Scripts Section
In the Before Formula Scripts section of the Set Column Values dialog, a script can be entered that will be executed by Origin just before the formula itself is executed. This feature is useful for carrying out operations that properly setup the formula itself. The following example demonstrates the use of such a script:
// In column BaseNormal
// In the expression section ..
// In the Before Formula Scripts section ..
range raR = col(Reading); // The signal
range raB = col(Baseline); // The Baseline
BN = raR - raB; // Subtract the baseline from the signal
stats BN; // Get statistics of the result
BN /= (stats.max / 100); // Normalize to maximum value of 100
The following image is a screenshot of the code above entered into the Set Column Values dialog: