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

  1. Create a new variable or select an existing variable.

  2. Right-click on the variable and select Create Standard Calculation.

  3. In the Calculation Configuration dialog box, choose VBScript from the Type list.

  4. Choose the appropriate trigger from the Trigger list.

  5. In # of inputs, type the number of inputs the calculation will have.

  6. On the Script tab, type the VBScript calculation.

  7. Click the Inputs tab, and click New to add the first input.

  8. Select the first input with alias of "a." The attributes of this input will be displayed under Selected Input.

  9. Edit the Name, Entity, and Attributes to be associated with the Input.

  10. Repeat steps 7 through 9 for the remaining calculation inputs.

  11. Click Save to save the calculation and close the Calculation Configuration dialog box.

See Also