GetTagHandle

The GetTagHandle method retrieves a handle for a specified tag in a taglist.  This method will not descend into the sections of a taglist.  To access a tag in a section, you must call OpenSection and pass the section taglist to GetTagHandle.

Tag handles provide a more advanced means of working with tags and taglists, but many applications can be written entirely without using tag handles.  The handle returned from GetTagHandle can be used to access all aspects of the tag by subsequently calling GetTagData, GetTagDataLength, GetTagDataType, GetIdFromHandle.

LONG GetTagHandle(
  LONG TagList, // Taglist to be queried for desired tag
  BSTR TagName, // Name of tag to retrieve
  LONG TagIndex // Index of tag to retrieve
)

Parameters:
TagList TagList to be queried for the desired tag.

TagName
Value Meaning
"" Retrieve any CAS tag
"<tag name>" Specific tag name to retrieve

TagIndex When multiple tags matching the specified TagName exist, the TagIndex is used to specify which occurrence of the tag should be retrieved.

Return Values:
Handle to specified tag, or null if unable to retrieve the handle.  You must pass this handle to RetTagHandle when you are done using it.

Example:
var Tl, Th, TagInfo;

Tl = CAS.New();
CAS.AddTag(Tl,"SUBJECT","This is a test.");

if ((Th = CAS.GetTagHandle(Tl,"SUBJECT",0)) != null)
  {
  TagInfo  = "Tag ID is "+ CAS.GetIdFromHandle(Th) +"\r\n";
  TagInfo += "Tag data is "+ CAS.GetTagData(Th) +"\r\n";
  TagInfo += "Tag data length is "+ CAS.GetTagDataLength(Th) +"\r\n";
  TagInfo += "Tag data type is "+ CAS.GetTagDataType(Th) +"\r\n";

  CAS.RetTagHandle(Th);
  }
else
  {
  TagInfo = "Tag not found";
  }

CAS.Delete(Tl);

The contents of TagInfo will be:

Tag ID is 832
Tag data is This is a test.
Tag data length is 16
Tag data type is 1


See Also:
CAS GetTag, CAS RetTagHandle