Creating Custom Logic (VBScript) Calculations
All calculations that are configured and saved are stored in a library so you can reuse them on other variables. Keep in mind that when a calculation from the library is applied to another variable, the calculation should be renamed and saved as a new calculation if any changes are made to the calculation template.
VBScript functions are ideal for intermediate type calculations if you know how to write in Microsoft VBScript. (For more information on VBScript, click here to go to Microsoft's site).These calculations support program flow logic, such as If, While, and For statements. All inputs must be defined, whether they originated from a variable or a constant. Only one result can be obtained from an equation calculation.
All scripts must set a variable called "Result" equal to the value that should be returned for the calculation. Variables names A - Z are used as aliases to inputs, with "A" being the first input, "B" being the second input, and so on.
You can use the following operators in your equations:
+ (addition)
- (subtraction)
* (multiplication)
/ (division)
The following VBScript functions are available for use within equations:
Function |
Description |
Abs |
Returns the absolute value of a specified number |
Atn |
Returns the arc tangent of a specified number |
Cos |
Returns the cosine of a specified number (angle) |
Exp |
Returns e raised to a power |
Hex |
Returns the hexadecimal value of a specified number |
Int |
Returns the integer part of a specified number |
Fix |
Returns the integer part of a specified number |
Log |
Returns the natural logarithm of a specified number |
Oct |
Returns the octal value of a specified number |
Rnd |
Returns a random number less than 1 but greater or equal to 0 |
Sgn |
Returns an integer that indicates the sign of a specified number |
Sin |
Returns the sine of a specified number (angle) |
Sqr |
Returns the square root of a specified number |
Tan |
Returns the tangent of a specified number (angle) |
To create a VBScript calculation
-
Create a new variable or select an existing variable.
-
Right-click on the variable and select Create Standard Calculation.
-
In the Calculation Configuration dialog box, choose VBScript from the Type list.
-
Choose the appropriate trigger from the Trigger list.
-
In # of inputs, type the number of inputs the calculation will have.
-
On the Script tab, type the VBScript calculation.
-
Click the Inputs tab, and click New to add the first input.
-
Select the first input with alias of "a." The attributes of this input will be displayed under Selected Input.
-
Edit the Name, Entity, and Attributes to be associated with the Input.
-
Repeat steps 7 through 9 for the remaining calculation inputs.
-
Click Save to save the calculation and close the Calculation Configuration dialog box.
See Also