Creating a Global Variable

To work with the script in this section, you must first create a global variable object to hold the string that represents the current active picture.

To create a global variable object to hold the string for the current active picture:

  1. In the iFIX WorkSpace system tree's Globals folder, right-click the User icon, and select Create Variable from the pop-up menu.
  2. Set the Name property to CurrentPicture and the VariableType property to 8 - vtString. The system tree should look like the following:

System Tree Example

Once you have created the variable, add the following code to the Activate method of the main picture to set a Global variable:

Private Sub CFixPicture_Activated()

 

'Set the user global variable when you activate to find

'out the name of current active picture.

user.CurrentPicture.CurrentValue = Me.FullyQualifiedName

 

'Me is a VB intrinsic variable that tells you the name

'of the current project (picture object).

End Sub

The Global variable lets you know which main picture has focus so the toolbar can act on it. Now you can add the following script to the bitmap object by right-clicking it and selecting the Edit Script command from the pop-up menu:

Dim PicObj As Object

 

'Loop through the documents that are open.

For Each PicObj In Application.Documents

'If the document that is open has the same name as the

'current active main picture, set the active property,

'which will in turn set the active document.

If PicObj.Name = user.CurrentPicture.CurrentValue Then

     PicObj.active = True

     'Acknowledge alarms of the selected items in the

     'active picture.

     AcknowledgeAnAlarm

     Exit Sub

End If

Next PicObj

How Do I...