Use macros, Use macros to assign values to tags, Use macros to assign values to tags -1 – Rockwell Automation FactoryTalk View Machine Edition Users Guide User Manual

Page 565

Advertising
background image

30-1

30

Use macros

This chapter describes:

Use macros to assign values to tags.

Use the Macros editor.

When to use macros.

Running macros when tags or expressions change value.

Where to assign macros.

Use macros to assign values to tags

A macro is a list of tag assignments stored in a text file, in the format <tag>=<value>.
Each assignment assigns a value to a tag. The value can be in the form of another tag, an
expression, a numeric constant, or a string.

Examples: Use macros to set tag values

Tag1 = 8
Sets the value of Tag1 to 8.

Tank1\Message = “Tank1 overflow”
Sets the string tag Tank1\Message to Tank1 overflow.

Tag1 = Tag2
Sets the value of Tag1 to be the same as Tag2.

Tag1 = Tag1 + 1
Increases the value of Tag1 by 1.

Tag1 = if (Tag2 < Tag1) then 4 else 3
Performs the if-then-else calculation and stores the result in Tag1.

1Pump = {Industry-2} + {2Pump}
Adds the values of Industry-2 and 2Pump and stores the result in 1Pump.

Brackets surround Industry-2 because of the dash in the name. Brackets surround 2Pump
because the name starts with a number. No brackets are used for 1Pump because this name
is on the left side of the equal sign.

For more information about expression syntax, see Chapter 23.

Advertising