Opens a dialog with a title, a value field and, OK and Cancel buttons.
Informal Syntax:
ValueDialog( Title, Prompt, Var )
Formal Syntax:
ValueDialog( Title:=Expression, Prompt:=Expression, Var:=Variable Reference )
Parameter | Type | Description |
---|---|---|
Title | ANY_STRING | The title that appears at the top of the dialog. |
Prompt | ANY_STRING | The prompt string associated with the text entry field. |
Target | REF_TO ANY_ELEMENTARY |
A reference to a program variable.
|
An INT value indicating which button was pressed:
Value | Button |
---|---|
0 | Cancel |
1 | OK |
When the Target field is a BOOL value, the dialog creates a check box to represent the field value. For all other types of field, the dialog creates a text entry field to represent the field value.
The ValueDialog() function is logically equivalent to:
FUNCTION ValueDialog VAR_INPUT Title : WSTRING; Prompt : WSTRING; END_VAR VAR_IN_OUT Value : ANY_ELEMENTARY; END_VAR DialogNew(); DialogAddValue( Prompt, Value ); ValueDialog := DialogOpen( Title, 1 ); END_FUNCTION
VAR V : BOOL; Result : INT; END_VAR (* Read the value of the tag *) V:=%"Digital Tag"; (* Open the value dialog to prompt for a new value *) Result := ValueDialog( "Pump Control", "Start pump 1", V ); IF Result THEN (* The user pressed OK, write the new value to the tag *) TagWriteValue("Digital Tag", V ); END_IF;
In the above example, the operator action reads the value of the digital tag "Digital Tag" into variable V. The code then displays the Value Dialog. If the user presses the Cancel button, the Result value will be 0 and the code skips the remaining statements. If the user presses the OK button, the Result value will be 1. The code goes on to write a new value to the digital tag:
The following image shows the dialog displayed by the preceding code example:
VAR V : LREAL; Result : INT; END_VAR (* Read the value of the tag *) V:=%"Analog Data Point Tag"; (* Open the value dialog to prompt for a new value *) Result := ValueDialog( "Change set point", "Enter new set point:", V ); IF Result THEN (* The user pressed OK, write the new value to the tag *) TagWriteValue("Analog Data Point Tag", V ); END_IF;
In the above example, the operator action reads the value of the analog tag "Analog Data Point Tag" into variable V. The code then displays the Value Dialog. If the user presses the Cancel button, the Result value will be 0 and the code skips the remaining statements. If the user presses the OK button, the Result value will be 1. The code goes on to write a new value to the analog tag:
The following image shows the dialog displayed by the preceding code example:
To learn about the DialogNew() function.
To learn about the DialogAddTextEditor() function.
To learn about the DialogOpen() function.
To learn about the TagWriteValue() function.
To learn where you can use this function.
For the meaning of terms used in Fernhill SCADA.