You are here: Core Reference > Coding > Scripting > Form.Remove

Form.Remove

The Remove function removes a specific control (field, button, combo box, and so on) from the Form.

Syntax

Form.Remove(Control Object)

Description

Removes a specific field, combo box, check box, button etc. from the Form.

Arguments

Control Object

The Control Object has to match the name of a variable that is used in the script to store the control object. The variable should be the variable that stores the control object that is returned by the Add function that was used to create the control that you want to remove. Control objects are returned by the Add functions for Forms such as AddComboBox etc.

Returns

None.

Example:

The following script adds 2 combo boxes to a Form. The combo boxes provide the same functionality and so the Form.Remove function is used to remove one of the combo boxes.

  • Form.Init "Verify Control Action"
  • Form.AddGroupBox 0,0,100,8,""
  • Form.AddStaticText 2,1, "Are you sure you wish to execute this control?"
  •  
  • Set frmExecuteNow = Form.AddComboBox(60,1)
  • frmExecuteNow.Add("Yes")
  • frmExecuteNow.Add("No")
  • frmExecuteNow.Add("Wait")
  • frmExecuteNow.Selection = 1
  •  
  • Set frmExecuteControl = Form.AddComboBox(80,1)
  • frmExecuteControl.Add("Yes")
  • frmExecuteControl.Add("No")
  • frmExecuteControl.Add("Wait")
  • frmExecuteControl.Selection = 1
  •  
  • Form.Show

Where:

  • frmExecuteNow is the name of the variable used to store the FieldObject that is returned by the AddComboBox function.
  • The Add functions are used to add values to the FieldObject, that is, add options to the combo box.
  • Selection is used to indicate the option that is selected by default (0 is the first option, 1 the second option, 2 the third option and so on).

The script creates the following Form:

The second combo box (referenced in the script by the frmExecuteControl variable) is no longer required, and so the following script is added to the script:

Form.Remove(frmExecuteControl)


This is added one line above the Form.Show function. It removes the control that is referenced by the frmExecuteControl variable (it removes the second combo box).

When the script is executed, the Form is shown as:


ClearSCADA 2015 R2