|
Register tags.
syntax
AddTag(
tagName
[,active = TRUE]
)
Parameters
tagName
|
|
Type:
|
character
|
|
The tag name. Multiple tag names can be specified as an array.
|
active
|
|
Type:
|
Boolean
|
|
If you want to get the value from the tag, specify TRUE. If you do not want to get the value, specify FALSE. For example, if you set FALSE when only writing with WriteVal, the load will be reduced because the value will not be retrieved. Also, when FALSE, the OnTagValueChanged event will not occur.
|
Return Value
|
|
Type:
|
Boolean
|
|
FALSE - Failure. TRUE - Success.
|
Explanation
Declare (register) the tag you want to access from scripts in the object. Typically, you register a tag in the OnInitialize event. After calling AddTag, the following methods become available for that tag.
GetVal/ ReadVal/ WriteVal/ ReadRefresh/ WriteRefresh/ ReadRequestRefresh/ WriteRequestRefresh Also, when the value of a registered tag changes, the OnTagValueChanged event will be called.
Each method is valid within the object registered with AddTag. For example, if you want to call GetVal from the script of the object that registered the tag, simply use this.GetVal. Or, if you register the tag on a form and want to call the method from each control object, you can call it as parent.GetVal.
|
Example
When calling GetVal in the script of the object that registered the tag
|
event OnInitialize()
{
this.AddTag("$D0");
}
event OnMouseUp(button)
{
this.Text = this.GetVal("$D0");
}
|
If you want to handle multiple tags at once, you can specify multiple tag names as a string array.
If any one of the AddTag fails, the return value will be FALSE. Even if AddTag fails for some tag in between, AddTag will be performed up to the last tag.
When handling multiple tags together
|
var vTags = c("$D0","$D1","$D2","$D3","$D4");
event OnInitialize()
{
this.AddTag(vTags);
}
event OnMouseUp(button)
{
var a = this.GetVal(vTags);
this.Text = ::Math.Ave(a);
}
|
|
Supported
reference
AddTag
DelTag
ClearAllTag
GetVal
ReadVal
WriteVal
ReadRefresh
WriteRefresh
ReadRequest
ReadRequestRefresh
WriteRequest
WriteRequestRefresh
|