GetTagValue
- Last UpdatedOct 29, 2026
- 3 minute read
Returns the current value of a tag (project tag or system tag).
|
Function |
Group |
Execution |
String Exp. |
Windows |
Windows Embedded |
IoT View |
Thin Clients |
Mobile Access |
|---|---|---|---|---|---|---|---|---|
|
GetTagValue |
Tags Database |
Synchronous |
Yes |
Supported |
Supported |
Supported |
Supported |
Supported |
Syntax
GetTagValue("strTagName", optNumRefresh)
strTagName
The name of the tag. Specify a string enclosed in quotes (double quotes or single quotes).
Note: If this parameter is enclosed in quotes, the string literal will be used. Otherwise, the value of the tag/expression will be used.
optNumRefresh
Enter the name of a project tag. A change to this tag's value will trigger a new execution of this function to refresh the displayed value on a screen or screen object, after the initial execution of the function. (Normally, a function is executed only when it is called, such as when it is configured on a Button object event, and the event executes the function during run time.) To execute this function at regular intervals, specify a system tag such as Second, Minute, or Hour.
This parameter is intended for use only with the Viewer or Secure Viewer on Windows; not for other viewers (such as Mobile Access), on other runtimes (such as Linux), or in other modules (such as Background Tasks).
Return value
This function returns the current value of the project tag specified by strTagName. If the specified tag does not exist, this function returns -1 with BAD quality. The value of the project tag specified by optNumRefresh does not affect the return value in any way.
If this function returns -1, this value may indicate either that the tag does not exist or that the current value of the specified tag actually is -1. You will need to take extra steps to determine which it is. and you can do so using one of the following methods.
First, you can check if the quality of the tag that receives the return value to see if it is BAD (myReturnValue->Quality). For more information, see Reference a tag property instead of a project tag. However, when this function is called in VBScript, the return value does not include quality, so this method will not work if you use VBScript to access this function.
Second, you can call the function TagsDBGetTagProperty to check if the project tag specified by strTagName exists. It does not matter which property you try to get — if that function returns -4, it confirms the specified tag does not exist. However, TagsDB functions can be executed only in the full AVEVA Edge software, so this method will not work if you try it on other platforms.
Third, as an alternative to the first and second methods above, you can create a VBScript procedure (in the VBScript Global Procedures interface, for example) that checks if a specified tag exists:
Function IsTagAvailable(tagName)
$LocalPointer = tagName
If $@LocalPointer->Name <> "" Then
IsTagAvailable = 1
Else
IsTagAvailable = 0
End If
End Function
The procedure above uses a tag pointer (@) to check the Name property of the specified tag. (Without the tag pointer, the procedure would check the Name property of LocalPointer itself.) If the property is not empty, the tag has a name and therefore exists.
Examples
Get the current value of myTag:
GetTagValue("myTag")
Get the value of myTag and refresh it every second:
GetTagValue("myTag", Second)
Get the value of the tag specified by myPointer and refresh it whenever the value of myTrigger changes:
GetTagValue(myPointer, myTrigger)