Use Tag Values in Expressions

This information applies to expressions created within the expression editor.
It does not apply to VTScada script code created in modules such as custom-coded reports.

In expressions, tag names are enclosed in square brackets: [Level]. If you want to see a property of that tag, you must say which one. For example, [Level]\Value, [Level]\ShortName, [Level]\Area. Because (usually) you want the tag's value, VTScada offers a shortcut. If no property is specified, VTScada assumes that you want the tag's current value. ([Level] == [Level]\Value. Note the location of the backslash relative to the bracket. Switching the order is a common mistake.)

Only the expression editor that opens from object properties within the Idea Studio will provide a Tag Browser button to help you locate and select a tag. In all other cases, you must type in the name of the tag that you want to use.

You can copy the hierarchy of a tag's name from its properties dialog. Highlight the hierarchy and press Ctrl-C. (Right-clicking to open a dialog for copy/paste won't work.)

Copying the hierarchy of a tag name

You can also use an expression in the Help ID field to obtain the full name:

Copying the full tag name, from the expression, NAME

If the tag isn't nearby in the hierarchy, you will need to tell VTScada where to find it.

For example, given the following tag structure:

Expression to be created in \Station 1\PLC1 using Level

If you are creating an expression in a tag that's a child of PLC1 and that uses the value of Level, you would write it as [Level], as shown:

[Level] * 2 / 3 ; two thirds of the  value

If you want to refer to a tag that is not an immediate sibling in the tag hierarchy, you will need to provide the address for where to find it.

Let's say that there is also a Station 2 with a level, and you want SiteCalc to show the average of the two:

([Level] + [Station 2\PLC1\Level]) / 2 ; the average of two tank values.

Level within Station 1 can be found just by its name, but you must provide a path to the tag named Level in Station 2.


The following tools are available to help you specify tags in the hierarchy. All of these are used inside the square brackets that denote a tag name.

\ Divider between parent and child tag names.
..\ Forces VTScada to start searching one level up the hierarchy tree. Always use this when the property you want to refer to in a parent might also exist in the current tag.
Child\GrandChild To reference a value (or other property) from a child of the current tag, start with the name of the child tag, then a backslash between each subsequent child name.
Ancestor Relative Path, used when selecting a parent tag of a given type.
For example, if you want a calculation tag to refer to the first parent that is a driver, use [*Driver]. (*)
If you want it to refer to the first parent that has a numeric value, you can use [..\*Numeric]. The ..\ portion is necessary to prevent the calculation tag from finding itself.
<> Absolute path. The tag name must start immediately below the root level of the tag hierarchy.

(*) Types you are likely to use most often include: *Port, *Driver, and *Numeric.

There are advantages and disadvantages to each method. For each situation, VTScada uses what is most likely to be useful in that situation. "Likely" doesn't mean "always".

The Scope Function

VTScada handles tag addresses differently in different situations. In a tag's configuration, other tags are usually identified using relative addresses, [Tag Name]. In the Idea Studio, widgets link to tags using absolute addresses [<Full Tag Name>].

If you are writing a VTScada script code module, you can't use the square bracket shortcut. Instead, you must use the scope function:

Scope(VTSDB, "Full Tag Name or GUID", TRUE)\Attribute

If providing a full tag name, do not include the brackets. Providing the tag's GUID is equivalent to the short form, [< >]. And "Attribute" is not a keyword here; use \Value or \Description, etc. If you don't provide an attribute, then the Scope function returns a link to the tag object itself, not the value.

If adding expressions to tags in an exported Excel file, you cannot use relative references such as [TagName]. All existing expressions are exported using the full syntax and with certain characters doubled: "Scope(Self, "TagName")\\Value". You must do the same.