dpExists()

The function dpExists() checks the existence of a valid data point identifier.

Synopsis

bool dpExists(string dpname);

Parameter

Parameter Description
dpname A data point 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 data point 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 data point 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(":");            
Note: If you want to check for a dedicated part of the data point identifier such as DP name or DP+DPE, you must additionally call the function dpSubStr() with the appropriate enum parameter: 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 data point ExampleDP_Arg1. exists.

main()
{
 bool retVal;
 retVal = dpExists("System1:ExampleDP_Arg1");
 DebugN("dpExists:", retVal);
}                            

Assignment

Data point function

Availability

UI, CTRL