You are here: Core Reference > Coding > Scripting > State

State

The Alarm.SelectedAlarms and Alarm.Alarms properties both return an alarm collection. Each alarm in an alarm collection has a State property which is a number that represents the state of the alarm. The number that is returned by the State property varies according to the state of the alarm:

In this context, the term 'enabled' means the alarm has been raised (and so is enabled on the Alarm Banner).

Accessing an alarm’s State property in your Alarm Banner script can be useful as it allows you to code different outcomes depending on the state of the alarm.

Syntax

State

Description

Returns the number for the state of the alarm (1, 3, or 7).

Arguments

None.

Returns

State {integer}. The alarm state is returned as a number.

Example:

In this example, the State property of an alarm is used to determine whether the Source of the alarm is added to a combo box on a Form.

  • For Each objAlarm In AlarmBanner.SelectedAlarms
    • If objAlarm.Object.CheckAccess("ALM")
    • And objAlarm.State < 4 Then
    • frmDrop.Add objAlarm.Source
    • AddToArray sPointNames,
    • objAlarm.Source
  • End If

For each alarm in the alarm collection returned by the Selected Alarms property, the script:

  • Checks that the user has sufficient permissions to access the object of the alarm (the item that is associated with the raised alarm)
  • Checks if the alarm has an alarm state that is less than 4. If the alarm state is less than 4, the Source of the alarm is added to an array (the Source is a string that is usually the name of the database item associated with the alarm). If the alarm state is greater than 4, its Source is not added to the combo box.

The combo box would be created earlier in the script, prior to this extract.


ClearSCADA 2015 R2