Using Logical Operators and Functions

Contents
A function is a series of VB.NET or C# statements that return a value. You can use functions to create a calculation for a calculated indicator or asset health calculation that includes logical operators such as IF, AND, OR, and so on. For example, you could do this if you want a calculation that includes an IF THEN statement.
Note: To create a calculation using a function, you should be familiar with VB.NET or C# scripting.
For example:

VB.NET

If A > B Then
return A
Else
return B
End if

C#

if (A > B)
{
return A;
]
else
[
return B;
}
Where A and B are the argument names.
A function returns a value by assigning a value to the function’s name in one or more statements of the procedure. The return data type of a function is always a Variant.

Calculation Inputs and Argument Names

In order for a function to work, the calculation input names defined for the indicator must match the arguments named in the function. Therefore, in this example you must also define calculation inputs named “A” and “B”. This is similar to entering a regular calculation expression.
When you define a calculation for an indicator without functions, the system processes the calculation by wrapping your expression in a function statement. For example, if your calculation is A / B, the system processes it as:
A / B
When you create a calculation by defining your own function, the system behaves similarly: in the first line of the statement the system inserts your calculation input names as arguments for the function. This means that you can leave the arguments for the function blank. However, for your own record-keeping, you will probably want to enter the argument names anyway.
Note: Your calculation input names must match the names of the arguments used in the function.
This topic explains in general terms how to add a function to your calculated indicator. For examples of how you can use functions, see the following topics:
For a list of logical operators and statements, see Functions and Logical Operators.

To Add a Function to a Calculated Indicator

1.
2.
Select the Calculation tab.
3.
4.
From the New list select either Indicator Input or Filter Input. The Calculation Input dialog appears. For detailed instructions, see the following topics:
5.
You can check the syntax (the order of the elements) of your calculation by clicking Check (Test). When you click this button, the system looks for errors in how you have typed the calculation.
6.
To use the test values on the inputs to complete a test calculation, click Calculate. You can use the result of this calculation to check that the function is giving the desired results.
7.
If necessary, you can change the Required Proximity of the calculation inputs.
8.
Select the Frequency tab.
9.
In the Triggering mechanism section, select when and how the system triggers the calculation. If the calculation is to be triggered at a regular interval, define the scheduled interval for the indicator.
For detailed instructions, see Defining an Indicator’s Calculation Frequency.
10.