Cicode Programming Reference > Cicode Function Categories > Tag Functions Introduction > SubscriptionAddCallback

SubscriptionAddCallback

Adds a function callback to a tag subscription. When the value change for a subscribed tag is detected, a callback function can be called. This implements change based Cicode and avoids continuously polling a tag value to monitor changes.

Multiple callbacks are possible to the same subscription.

To remove a callback from a subscription use the SubscriptionRemoveCallback function.

Syntax

SubscriptionAddCallback(iHandle, sCallback)

iHandle

Integer handle of the subscription to add a callback to.

sCallback

String stating the name of a function to call when the value is updated. The function should have the structure:

FUNCTION evtHandler(INT subsHandle)
..
End

Where subsHandle is the subscription that raised the event.

Return Value

0 (zero) if successful, otherwise an error is returned.

Related Functions

TagSubscribe, TagUnsubscribe, SubscriptionGetAttribute, SubscriptionRemoveCallback

See Also

Tag Functions