beautypg.com

Create an mpr object – Rockwell Automation 9307 FactoryTalk EnergyMetrix User Manual

Page 217

background image

9

ReportsPlus

217

Functions

The MPR script can also contain user-defined functions:

Sub Main()

[declarations]

[main routine script]

For Each item In collection

variable = Function1(arg1, arg2, ...)

Next item

End Sub

Function Function1(arg1 As Type, arg2 As Type, ...)

[declarations]

[function script]

End Function

Create an MPR Object

The MPR lets you select from a number of report elements including a Grid, a Trend
Chart, a Pie Chart, and a Rich Text Box. Each report object may differ in some details.
Refer to the MPR Object Model for detailed object specifications.

Declaring an MPR object

Declare an object by using a Dim statement in the Main routine or Subroutine where the
object will be accessed in the script:

Dim pieChart As PieChart 'declares a PieChart object with the
name of pieChart

The object can be created at the same time as it is declared by using the New method:

Dim objRichTextBox1 As New RichTextBox() 'declares a RichTextBox
object named objRichTextBox1 and creates an instance of the
object. The paired parentheses after the object type are optional
in this usage

The script must also declare variables that reference the properties of the object so they
can be accessed in the script:

Dim objGrid1 As Grid 'declares a Grid object named objGrid1

Dim objRow As Row 'declares a Row object named objRow

Dim objCol As Col 'declares a Col object named objCol

Creating a MPR object

Create an object in the MPR script as shown in the examples below.

objPieChart = New PieChart()

objGrid1 = New Grid()

Do not create an object in this manner if it has already been
created when it was declared or a run-time error will result.