Calculate (Expression)
Dynamic expressions may be used to calculate new field values from existing field values. For examples of the expressions you can write using the Calculate (Expression) function, refer to: Field Expressions.
This option is also available on the File tab, in the Edit Data group. Select the file you want to perform a dynamic expression calculation on.
File
Specify the Name and Type of the source file and optionally apply a filter.
Clear Result field
Selecting this option will ensure that any contents in the Result field will be cleared before new data is written there.
Overwrite Result field
Select this option to overwrite the existing contents of the Result field. When you clear this option, only those Result fields with blank values will be recalculated.
Modify Numeric Exceptions
If Numeric Exceptions are required, select the check box to enable them. This will enable the Numeric Exceptions button. Click the button to open the Numeric Exceptions dialog.
Detailed information on the options in the dialog are contained in Numeric Exceptions. Select the required configuration and click Close.
When the Modify Numeric Exceptions option is disabled, it is equivalent to enabling Ignore blank field values and Ignore records with a leading character in the dialog outlined above. In other words, this configuration ignores all non-numeric values.
In addition, character values are preserved as written, provided the output field is a Character field.
As outlined in the Expression Calculate form, # Result names are supported for storing temporary results. Any name in the range #0 - #999 can be used for a Result. A warning message will be displayed if the prefix is used for a result name outside of the range to alert users if/when the input is invalid.
Temporary variables are displayed in blue on light grey cell background and shown in the “Calculated Temporary Variables” list.
In the example which follows, the series of expressions processes wireframe names in the form “PB_Xaaa_Zbbb“ to extract aaa as the ExtractionNumber and bbb as BenchZ. #1 is a temporary variable an intermediate result that is not required in the output file.
Expressions
Use the Grid List to define the expressions you want to calculate. Use the buttons on the local toolbar to Manage the rows in the list.
To build an expression:
- Double-click on an Input row (or right-click on the row and select Edit Expression to open the Expression Editor.
A list of attribute and property variables, constants and functions are available for selection.
Created Result Fields, Input fields, Previous, Current, and Next field variable variants, and constants, are arranged into groups in the Variables pane.
Simply double-click on a heading (or click on the bullet to the left of a heading) to expand or contract the list for each group.
- Double click on a variable or a function to add it to the expression window at the left of the editor window.
- Click the Check button to perform a syntax check on the expression you have built.
- Once a syntactically correct expression has been built, click OK to return to the Calculate (Expression) form.
- Use the Run button to execute the expression you have created.
Result fields will be created if they do not exist. A field expression is evaluated for the current record in the file. If the result type is Numeric or Boolean, the type of the field is REAL. If the result type is String, the type of the field is CHARACTER. If the result type is Nil, the type of the field is determined by looking at the prefix: If the expression starts with the unary "#" operator, the field type is CHARACTER, otherwise it is REAL.
Referencing Previous and Next records
Previous, Current, and Next field variable variants, and constants, are arranged into groups in the Variables pane of the form. Simply double-click on a heading (or click on the bullet to the left of a heading) to expand or contract the list for each group.
To reference values in the previous record, select a field name prepended with "<".
To reference values in the next record, select a field name prepended with ">".
For example, for a field name "EAST", "<EAST" would reference the EAST value of the previous record and "EAST>" would reference the EAST value of the next record.
For the first record in the file, values on the previous record are undefined. For the last record, values on the next record are undefined (you can check this with the DEFINED() function).
For the newly created result fields, you can reference them on the previous record but not on the next record.