PML Customisation
User Guide
Arrays
: Subtotalling Arrays with the VAR Command
Subtotalling Arrays with the VAR Command
Suppose you have sorted the array
!Car
and another array
!Value
using the command:
VAR
!Index
SORT
!Car
!Value
LASTINGROUP
!Group
The arrays would look like this:
!Index
!Group
!Car
!Value
[1]
1
1
CHARIOT
50000
[2]
2
FORD
1000
[3]
4
FORD
100
[4]
5
FORD
8000
[5]
10
2
FORD
7000
[6]
3
3
VAUXHALL
2000
[7]
7
4
ford
1000
[8]
9
5
vauxhall
3000
[9]
6
(Unset)
9000
[10]
8
6
(Unset)
6000
You can then generate an array of subtotals for each type of car with the following command:
VAR
!Totals
SUBTOTAL
!Values
!Index
!Group
This would produce the result:
!Index
!Group
!Car
!Value
!Totals
[1]
1
1
CHARIOT
50000
50000
[2]
2
FORD
1000
[3]
4
FORD
100
[4]
5
FORD
8000
[5]
10
2
FORD
7000
16100
[6]
3
3
VAUXHALL
2000
2000
[7]
7
4
ford
1000
1000
[8]
9
5
vauxhall
3000
3000
[9]
6
(Unset)
9000
[10]
8
6
(Unset)
6000
15000
VAR !variable SUBTOTAL ..
This will sum value strings that contain values with or without unit qualifiers. Unit qualifiers within the strings will be ignored. This is to allow REPORTER to still operate with unit qualified value strings that may have been introduced by other VAR or $!variable commands.
VAR !variable EVALUATE …
Will return string variables and arrays of unit qualified values if the evaluation generates quantities with physical dimensions.
VAR !D EVAL (DIAM) for all CYLI
sets !D to a set of strings such as '90cm' '60cm' etc. - when cm are the current length units). The unit will be the current working unit.
VAR !variable ATTRIBUTE
This sets the variable to a string that contains the value AND the unit qualifier for attributes with of a physical quantity
VAR !X XLEN sets !X to '46cm' if current units are cm)
The unit will be the current working unit.
1974 to current year.
AVEVA Solutions Limited and its subsidiaries. All rights reserved.