Applies To:
  • CitectSCADA 7.0

Use the TagSubscribe() function to subscribe to the Array itself and not an individual element in the array, which is different from the TagInfo() function where this function supports array syntax as seen in the help as TagInfo("PLC_Array[9],nType) 

The TagSubscribe() function would then have the [, sCallback] argument declared to make reference to the SubscriptionGetAttribute() function which will be called everytime the value of the individual element of the array is changed.  The SubscribtionGetAttribute() function has an [, iOffset] argument which is the zero based index of the subscribed array. 



FUNCTION TagSubArray()

INT iTagSub;

iTagSub = TagSubscribe("Array_Tagname",250,"Eng", -1, "ArrTagSubChanged");   // where "Array_Tagname" is defined as a tag in your Variable Tag Database and the address would be the array syntax defined



FUNCTION ArrTagSubChanged( INT iSubscription )

STRING sTagName;

STRING sValue[3];

sTagName = SubscriptionGetAttribute ( iSubscription, "TagName" ); // Get the new values

sValue[0] = SubscriptionGetAttribute( iSubscription, "Value", 0);   // 1st Element in the Array

sValue[1] = SubscriptionGetAttribute( iSubscription, "Value", 1);  // 2nd Element in the Array

sValue[2] = SubscriptionGetAttribute( iSubscription, "Value", 2);  // 3rd Element in the Array

TraceMsg("Update Array TagName = " + sTagName + " ArrayTagValue = " + sValue[0] + ", " + sValue[1] + ", " + sValue[2] + ", " + sValue[3])// Displays a message in the Kernel




The current functionality is by design, as it is actually more efficient to treat arrays in this manner, as instead of having 10 different subscriptions, Citect will only have one to the core tag. This is different behaviour to TagInfo, but this is by design.  Also, V7.0 Service Pack-A (SPK-A) should be running as the TagSubscribe() functionality has been corrected and will allow this function to work properly in some situations.