dpExists()
The function dpExists() checks the existence of a valid datapoint identifier.
Synopsis
bool dpExists(string dpname);
Parameter
| Parameter | Description |
|---|---|
| dpname | A datapoint identifier:
A sys, a DPT, a DP, a DPE, a config, a detail or an attr. |
Return Value
The function returns true if at least one part of a datapoint identifier can be resolved correctly and otherwise FALSE.
Errors
The errors can be retrieved with getLastError(). This includes missing or incorrect arguments.
Description
The function dpExists() checks the existence of a valid datapoint identifier. The function returns true if at least one part can be resolved correctly, i.e. a sys, a DPT, a DP, a DPE, a config, a detail or an attr.
The following calls return TRUE:
dpExists(":_original.._value");
dpExists("System1:");
dpExists(":");
bool e = dpExists(dpSubStr(ident2check, DPSUB_DP)); DP Identifier variable as an argument
dpExists() can also use a DP identifier variable as an argument. Note that CTRL does not have an explicit data type to store this type.
However, the type is received as part of a response to a dpQuery*() result - see example below:
main(mapping event)
{
dpCreate("b1", "ExampleDP_Bit");
dyn_dyn_anytype res;
dpQuery("SELECT '_original.._value' FROM 'b1.'", res);
DebugN(res);
DebugN(dpExists(res[2][1]));
dpDelete("b1");
DebugN(res);
string name = res[2][1];
DebugN(dpExists(res[2][1]));
}
The example checks if the datapoint ExampleDP_Arg1 exists.
main()
{
bool retVal;
retVal = dpExists("System1:ExampleDP_Arg1");
DebugN("dpExists:", retVal);
}
Assignment
Datapoint function
Availability
UI, CTRL
