dpSubStr()

The function dpSubStr() returns the part (sub string) of a data point name given by pattern. The function returns the neutral form of configs and attributes.

Synopsis

string dpSubStr(string dp, int pattern);

Parameters

Parameter Meaning
dp Data point element
pattern see below

Return Value

In the event of an error an empty string, otherwise the required result.

Errors

Errors can be retrieved with getLastError(). An error message is issued in the event of missing arguments or incorrect DPs.

Description

The variable dp can contain a data point name, a data point name with the (first) element, with the first and second element, with the element and the config etc. The required part of the name is specified in pattern by one of the following constants. The function verifies if the data point does exist. in case of a non existing data point an error will be returned-

Integer constant Comment
DPSUB_ALL returns the whole name string
DPSUB_SYS_DP_EL_CONF_DET_ATT returns the name path with attribute
DPSUB_SYS_DP_EL_CONF_DET returns the name path except for the attribute
DPSUB_SYS_DP_EL_CONF returns the name path except for the attribute and the detail
DPSUB_SYS_DP_EL returns the name path except for the attribute and the config
DPSUB_SYS_DP only returns the system details and the data point name
DPSUB_SYS only returns the system details of a name string
DPSUB_DP_EL_CONF_DET_ATT returns the name string without the system details
DPSUB_DP_EL_CONF_DET returns the name string without the system details and attribute
DPSUB_DP_EL_CONF returns the name string without the system details, attribute and detail
DPSUB_DP_EL

returns the name string without the system details, attribute, detail and config

Note

When querying struct data point elements only the index is returned instead of the name, e.g. dpSubStr("myDp.intStruct.node2",DPSUB_DP_EL); will return "myDp.intStruct[2]" instead of "myDp.intStruct.node2".

DPSUB_DP only returns the data point name
DPSUB_CONF_DET_ATT only returns the config, detail and attribute
DPSUB_CONF_DET only returns the config and detail
DPSUB_CONF only returns the config

Example

main()
{
  string newstring;
  newstring =
  dpSubStr("Valve17.opening:_default.._type",DPSUB_DP);
  DebugN(newstring); // Returns Valve17
}
                            

Assignment

Data point function

Availability

CTRL