ComboBox.Selection

The ComboBox Control Object that is returned by the AddComboBox function has a Selection property. The Selection property allows you to determine which Combo Box option is selected when the Form is closed. This information can then be used to determine the next course of action. For example, if the Combo Box options correspond to controls, the Selection property could be used in the script to determine which Control Object was selected, and therefore which Control Object needs to be executed.

Syntax

ControlObject.Selection

Where ControlObject. is the name of the variable (declared in your script) that is used to store the Combo Box Control Object that is returned by the AddComboBox function.

Description

References the Index Number of the Combo Box option that is currently selected at the time the Form is closed.

Arguments

None.

Returns

Integer (the Index Number of the option that is selected when the Form is closed).

Example:

The following script is used to provide the functionality for an Override feature on a Mimic. When a Mimic object is selected, a Form is displayed that has an Override Combo Box. The Combo Box has 2 options—one overrides a point's value to 50, the other overrides the point's value to 80.

Public Function ComboBoxForm

Dim ObjAlarmValue

Dim frmComboBox

Dim pstrings (1)

Dim frmOKButton

Dim frmCancelButton

Dim frmStaticText

pstrings(0) = "Override to Normal"

pstrings(1) = "Override to High High"

Form.Init "Override AI1 Point"

Set frmStaticText = Form.AddStaticText (1,2,"Override AI1 Point")

Set frmComboBox = Form.AddComboBox (20,2, pstrings)

Set frmOKButton = Form.AddPushButton(60,5,"OK")

frmOKButton.Default = True

Set frmCancelButton = Form.AddPushButton(75,5,"Cancel")

Form.Show

If Form.Selection = "OK" Then

Select Case frmComboBox.Selection

Case 0

Set ObjAlarmValue = Server.FindObject(Server.GetOPCValue(".AI1.Fullname"))

ObjAlarmValue.Interface.Override 50

Case 1

Set ObjAlarmValue = Server.FindObject(Server.GetOPCValue(".AI1.Fullname"))

ObjAlarmValue.Interface.Override 80

End Select

End If

End Function

The Form is set to have a Combo Box, an OK button and a Cancel button. The Combo Box has 2 options, named "Override to Normal" and "Override to High High".

If the user selects the OK button, the script performs one of 2 actions, depending on which option is selected in the Combo Box.

If "Override to Normal" is selected (this is Case 0 as it has an Index Number of 0), the script performs an Override of 50 on the point named AI1. The Server.GetOPCValue function is used in conjunction with the Server.FindObject function—this is because the Server.FindObject function does not support relative references, but by using the Server.GetOPCValue function as well, you can use a relative reference (although this involves extra requests).

If "Override to High High" is selected (this is Case 1 as it has an Index Number of 1), the script performs an Override of 80 on the point named AI1.

If the user does not select the OK button, and closes the Form by selecting the Cancel button or the Close window icon, the script does not execute.


Disclaimer

ClearSCADA 2017 R3