iFIX includes several subroutines that can help simplify scripts that are intended to perform common tasks, such as acknowledging alarms or replacing pictures. Since these subroutines are stored in the FactoryGlobals project, they can be accessed directly through the Visual Basic Editor. For more information on FactoryGlobals, see the Creating Global Scripts chapter of this manual.
In addition to providing the code necessary to perform the task at hand, subroutines offer several extras that you would normally have to code yourself, including:
- Generic error handling.
- Posting of operator messages to the alarm system.
- Conformance to VBA naming conventions.
If you are using tag names that contain special characters, this is a perfect case for using the ReadValue and WriteValue global subroutines to access your tags in VBA.
For example, suppose you have the following tag:
Fix32.SCADA.SORTER|SIZER|BLOCK10|PT.F_CV
In VBA, you can read this tag with the following syntax:
Private Sub Text1_Click()
Dim x As Variant
x = ReadValue("Fix32.SCADA.SORTER|SIZER|BLOCK10|PT.F_CV")
Text1.Caption = x
End Sub
Once the value is stored as a variant (x), you can use it in expressions.