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
Anmerkung: Note that you can only define one observer per a callback function since the same callback function would be used by all observers.
Anmerkung: 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)
{
  DebugN(where, what);
}

Availability

UI, CTRL