Rockwell Automation 9307 FactoryTalk EnergyMetrix User Manual
Page 216
FactoryTalk EnergyMetrix Software
216
All other MPR objects must be declared as the applicable Object type. Variables and
constants should be declared as the appropriate data type. The first character of any script
element name must be an alphabetic character, a digit, or an underscore.
The following are examples of declarations:
Dim totalConsumption As Double 'declares a variable named
totalConsumption as a Double data type
Dim group As Group 'declares the object named group as a Group
object type
Const weeksInYear as Integer = 52 'declares an integer constant
named weeksInYear and assigns 52 as its value
Dim richText as New RichTextBox() 'declares a RichTextBox object
named richText and creates an instance of the object
Declarations placed at the beginning of the MPR script (prior to the
Sub Main()
statement) are global to the entire script. Declarations placed within a routine or function are
local to that routine or function.
Main Routine
The MPR script must contain at least a Main routine, as shown below:
Sub Main()
[declarations]
[main routine script]
End Sub
Optional Elements
The script can also have subroutines and functions.
Subroutines
The MPR script can also contain subroutines called from the main routine:
Sub Main()
[declarations]
[main routine script]
For Each item In collection
Routine2(arg1, arg2, ...)
Next item
End Sub
Sub Routine2(arg1 As Type, arg2 As Type, ...)
[declarations]
[subroutine script]
End Sub