Choosing the Tag Type
- Basic tags hold a single value.
- Array tags are a set of tags that use the same name with unique indexes.
- Class tags are a set of compound tags that consist of user-defined data types (Boolean, Integer, Real or String) or data-type structures.
- Indirect tags are pointers that provide indirect access to another tag type, including class tags.
A discussion of these tag types follows.
Basic Tags
- TankID (to identify different tanks in your project)
- Temperature (to identify the current temperature of an object)
- Status (to identify whether an object is open or closed)
Array Tags
An array tag consists of a set of tags that all have the same name, but use unique array indexes (a matrix of n lines and one column) to differentiate between each tag. An array indexcan be a fixed value, another tag or an expression. Maximum array sizes are determined by product specifications.
- Simplify configurations
- Enable multiplexing in screens, recipes, and communication interfaces
- Save development time during tag declaration
- For a simple array tag, type:
ArrayTagName[ArrayIndex]
- For a complex array tag (where the array index is an expression consisting of a tag and an arithmetic operation), type:
ArrayTagName[ArrayIndex+c]
Where:- ArrayTagName is the tag name;
- [ArrayIndex] is the unique index (fixed value or another tag);
- + is an arithmetic operation; and
- c is a numerical constant.
- You must specify a maximum index for each array tag by typing a value (n) in the Array Size column of an Project Tags datasheet or in the Array Size field on a New Tag dialog. (See “Creating project database Tags“).
When you create an n-position array tag, IWS actually creates n+1 positions (from 0 to n). For example, if you specify ArrayTag[15], the array will have 16 elements, where 0 is the start position and 15 is the end position.
- You must not use spaces in an array tag.
When IWS reads a tag it begins with the first character and continues until it finds the first space or null character. Consequently, the system does not recognize any characters following the space as part of the array tag.
For example, if you type a[second + 1] IWS regards a[second as the tag and considers it invalid because IWS does not find (recognize) the closing bracket. However, if you type a[second+1], this is a valid array tag.
You can specify an array tag wherever you would use a variable name. Also, because array tags greatly simplify configuration tasks and can save development time, we suggest using them whenever possible.
- temperature1 — high temperature on tank 1
- temperature2 — high temperature on tank 2
- temperature3 — high temperature on tank 3
- temperature4 — high temperature on tank 4
- temperature[n] — high temperature on tank n
Array Tag Example | Description |
---|---|
Tank[1], Tank[2], Tank[500] | Simple arrays, where the array indexes (1, 2, and 500) are numerical constants. For example, tank numbers. |
Tank[tk] | A simple array, where the array index (tk) is a tag. For example, a tag representing the tank number. |
Tank[tk+1] | A complex array, where the array index (tk+1) is an expression. For example, the value of tk (tank number) plus 1. |
- If IndexTag is greater than the size of the array, then MyArray[IndexTag] will point to the end position of the array; and
- If IndexTag is less than 0, then MyArray[IndexTag] will point to the start position of the array (i.e., MyArray[0]).
Indirect Tags
Indirect tags “point” to other database tags (including class-type tags). Using indirect tags can save development time because they keep you from having to create duplicate tags (and the logic built into them).
- To reference a simple tag, assume the strX tag (a string tag) holds the value “Tank”, which is the name of another tag, then reading from or writing to @strX provides access to the value of the Tank tag.
- To reference a class-type tag and member, you simply create a string tag that points to the class tag and the member. For example, if a tag strX (a string tag) holds the value “Tank.Level”, which is the name of the class tag, then reading from or writing to @strX provides access to the value of the Tank.Level member.
- You can also point directly to a class-type tag member; by identifying a class-type that points to a class member. For example: to access the Tank.Level member of the class, you must store the “Tank” value within the strX tag and use the syntax, @strX.Level.