Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Engineering

Subtotaling Arrays with the VAR Command

  • Last UpdatedOct 29, 2024
  • 2 minute read

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

This sets !D to a set of strings such as '90cm', '60cm', and so on, 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.

Related Links
TitleResults for “How to create a CRG?”Also Available in