dpDisconnectUserData()

Unregisters a callback function which was called using dpConnectUserData().

Synopsis

int dpDisconnectUserData([class object,] string|function_ptr work,anytype userData[, string dp1[, string dpe2 ...] | dyn_string dp_list);

Parameters

Parameter Meaning
object An object of a Control++ class.
work

Name of the callback function ("work function") that is called when data point values change.

Or

The name of a function pointer to the work function (callback function).

userData User-defined data which is passed as parameter to the callback function.

dp1, dp2, ...

|

dp_list

Data point attributes (for example, "A.:_original.._value", "B.:_original.._value") or a data point list to be unregistered. If you pass a data point list, the DPEs and values in the work function are passed as a dyn_string dp-list and dyn_<type> Values. See example using dpConnect().

Return Value

dpDisconnectUserData() returns 0, in the event of a failure returns -1.

Errors

Errors can be retrieved with getLastError() . This includes missing arguments or if the data point or work function does not exist. The usage of not initialized variables for the parameter userData will raise an error.

Description

The function dpDisconnectUserData() unregisters the function work() for call if values of the data point attributes dp1, dp2 ... are changed. The work function is no longer executed spontaneously.

A dpDisconnectUserData() can only be made in the same script like the dpConnectUserData()!

If there exists no definition for a config or attribute, the following defaults are used and added internal:

Function Default
dpSet*() _original.._value
dpGet() _online.._value
dpGetAsynch() _offline.._value
dpGetPeriod() _offline.._value
dpConnect() _online.._value
dpDisconnect() _online.._value
dpConnectUserData() _online.._value
dpDisconnectUserData() _online.._value

Example

main()
{
  anytype userData = getUserName();
  dpConnectUserData("startCalc", userData,
  "D.:_original.._value");
}
startCalc(anytype userData, string dp1, int d)
{
  if(d == 1)
  dpConnectUserData("add", userData, "A.:_original.._value",
  "B.:_original.._value");
  else
  dpDisconnectUserData("add", userData "A.:_original.._value",
  "B.:_original.._value");
}
add(anytype userData, string dp1, int a, string dp2, int b)
{
  dpSet("C.:_original.._value", a + b);
  DebugN(a + b, userData);
}

You can find an example of how to use a Control++ class instance in a connect function in the chapter dpConnect().

Assignment

Data point function, waiting Control function

Availability

CTRL