Function Selection Dialog
Use this to browse a portion of the VTScada function library for code to use in your expressions. The Function Selection dialog is available from any VTScada Expression Editor dialog.
Options depend on where the expression is being created and therefore the value that should be returned.
This example is meant to return a numeric (analog) result.
Function Selection versus Function Editor
- Function Selection helps you create expressions. Use the this to find and choose both operators and functions. Everything that you add is always appended to what you have already written.
- Function Editor helps you edit the parameters of the functions and operators you have already added to your expression. Use this after you have an expression containing at least one function or operator, in order to change that part of the expression.
While the Function Selector is helpful, you still need to know how expressions work and have a clear idea of the expression you are attempting to build. It is also helpful to look up the description of each function and its parameters in the VTScada documentation while editing.
* Press F1 while selecting parameters, to see the description of the function you are configuring (as well as suggestions for alternatives).
* Advanced developers can create their own functions for use with the Function Selector. See Add Functions to Your Application's Library
Function Editor / Parameter Assignment
To use the Function Selector:
- Begin creating an expression by opening the expression editor.
- Place the cursor in your expression where you want to add a function or operator.
- Open the Function Selector. (Refer to the first image in this topic.)
- Choose your function or operator, then click OK.
If parameters are required (as they almost always are) the function editor dialog will open. The title of this dialog varies because it always includes the selected function followed by the word "Parameters". In the following example, the selected operator was "Divide" (/).
Plan to press F1 at this step. Doing so will open the VTScada documentation to the relevant function or operator, where you can learn more about what is needed for each parameter.
The expression editor will try to simplify your expression as much as possible before saving it. For example, if you type something like Max(1,2,3,4), the expression will be interpreted as a constant “4” and the expression editor will not allow editing.
Example:
Suppose that your intent is to create a expression that returns the integer portion of tag's floating point value. For this, you could use either the Int function, or the Cast function. For the purposes of this example, let's assume that you decide to use Cast.
For the "Value" parameter, you will select the tag. But, what should you provide for the "Type" parameter? You will need to refer to the documentation of this function to discover that the Type must be a number, and further, that number must be 1 in order to cast to an integer. Pressing "F1" will open the relevant documentation topic.
When adding text parameters, do not type quotation marks around the text. For functions with optional parameters, beware of telling the dialog that you want to include an extra parameter and then leaving it unspecified. "Invalid" is the likely result.
Function Selector Description
Search
Type a function (or part of a function) into the search field and press the Enter key on your keyboard. Wild cards are supported and are assumed if not provided.
Filter
The list is prefiltered to functions and operators that can be used in the context of where you are creating your expression. For example, if your expression will run in steady state, script-only functions such as CurrentTime are removed from the list.
You can further filter the list by setting the drop-down selection to any of:
All Keywords
All functions and operators that can be used in the current context.
Alarm
Check whether a given tag has active or unacknowledged alarms.
Counters
Only one: Trigger Counter - watch equipment starts.
Date and Time
Calculate time and date in many ways.
Logical
A large variety of functions to check the status of your application.
Math
Generic, Boolean, and Trigonometric functions.
Mouse
Two functions that return the location of the pointer within the application.
Network
Translate a TCP/IP address to text.
Text
Manipulate and examine text.
Variable
Cast one variable type to another, or specify the scope of an object.
Error: Failed to compile expression
You will see this or a similar message when there is a syntax error in your expression. Refer to the Syntax Rules for Expressions
The dialog indicates only syntax errors. Errors in logic can be saved and will run, but return the wrong result. Write your expressions with care.
Practice using the Function Selector
- Create a new I/O and Calculations tag named Level Steps.
- Ensure that the data type is Analog and select the Calculation option on the ID tab.
- Configure an expression using the Function Selector to use the Deadband function, setting the Delta value to 2. (Hint: Don't forget that you can use F1 to open the documentation.)
(You might want to disable alarm sounds before proceeding with the next part of this exercise. As a reminder, you can find a control for that in the Alarms tab of the Edit Properties dialog.)
- Edit the tag, Level, to add a low level alarm. This should have a priority of "Warning" and a setpoint of 10.
- Modify the tag, Inflow, to add a similar low level alarm with a setpoint of 25.
- Create a new I/O and Calculations tag named Station Alarms
- Set the data type to Digital and select the Calculation option.
- Use the function selector to create an expression that will be TRUE whenever there is an active alarm on either Level or Inflow. (You will need the OR operator, which is written as two vertical bars: || )
After ensuring that your expression works, feel free to disable those two alarms before proceeding.