cnsAddObserver
Registers the given function as CNS observer.
Synopsis
bool cnsAddObserver(string callbackFunction);
Parameters
Parameter | Description |
---|---|
callbackFunction | Name of the CTRL function which shall be registered. The function can be defined in a CTRL library, scope library or in a local script. |
Return value
Returns TRUE if successful or FALSE in case of an error.
Errors
Possible errors:
- Function does not exist
Description
Registers the given function as CNS observer. The function is called every time a CNS element is changed and receives the following parameters:
- string where - contains the CNS path of the changed element. For created/deleted elements it is the path of the element before the change. For created elements it is the path of the new element. If the display name of the system is changed it will be the name of the system.
-
int what - contains the type of change. The following CTRL constants can
be used for comparison:
- 0 CNS_CHANGE_SYSTEM_NAMES
- 1 CNS_CHANGE_VIEW_SEPARATORS
- 2 CNS_CHANGE_NAMES
- 3 CNS_CHANGE_DATA
- 4 CNS_CHANGE_STRUCTURE
- int action (optional) - contains the detailed action of the type change
(especially for CNS_CHANGE_STRUCTURE). The following CTRL constants can be used
for comparison:
- CNS_ACTION_SYSTEM_NAMES
- CNS_ACTION_CREATE_VIEW
- CNS_ACTION_DELETE_VIEW
- CNS_ACTION_CHANGE_VIEW_NAMES
- CNS_ACTION_CHANGE_VIEW_SEPARATORS
- CNS_ACTION_CREATE_TREE
- CNS_ACTION_DELETE_TREE
- CNS_ACTION_CHANGE_TREE
- CNS_ACTION_ADD_TREE
- CNS_ACTION_CHANGE_NODE_NAMES
- CNS_ACTION_CHANGE_NODE_DATA
Note: Note that you can only define one observer per a callback
function since the same callback function would be used by all observers.
Note: It is not necessary to pass these parameters, therefore the function can also be
defined as observerCB().
main()
{
bool success = cnsAddObserver("observerCB");
if (! success)
{
DebugN("Function does not exist");
}
}
observerCB(string where, int what, int action)
{
DebugN(where, what, action);
}
Availability
UI, CTRL