nameCheck()

Checks if the name of a datapoint or name of a project only contains the permitted characters.

Replaces the dpNameCheck() and dpIsLegalName() functions which remain for compatibility reasons!

Synopsis

int nameCheck( string &dpName [, int nameType]);

Parameters

Parameter Description
dpName DP or project name.
nameType

Constants that specify the check type:

  • NAMETYPE_DP (==1): Checks whether the specified data point name only contains the allowed characters.

    Forbidden characters for datapoint names are: . : , ; * ? [ ] { } $ @ as well as unprintable ASCII characters:
    \x01 \x02 \x03 \x04 \x05 \x06
                                                \x07 \x08 \x09 \x0A \x0B \x0C \x0D \x0E \x0F \x10 \x11
                                                \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C
                                                \x1D \x1E \x1F \x20 \x7F
    . See here for more information on these unprintable characters.
  • NAMETYPE_PROJ (==2): Checks whether the specified project name contains the following forbidden characters: \ / " ? < > * | : ; '

  • NAMETYPE_PATH (==3): No check at the moment.

    If you do not specify the nameType, the NAMETYPE_DP is used by default.

Return value

The function returns 0 if the name only contains permitted characters and otherwise -1. When the function returns -1, it also returns the corrected name (therefore, the syntax contains the "&" character).

Error

Description

Checks if the name of a datapoint or project name only contains the permitted characters. The function also checks multibyte characters. The returned result is 0 (only permitted characters) or -1 (illegal characters). The corrected name is returned in the dpName parameter.

Example

The example checks if the name of the datapoint in the text field is correct. It also writes the corrected datapoint name into the text field after a delay.

main()
{
  string dpName1 ="/Datapoint1%";
  DebugN("Datapoint name:", dpName1);
  TEXT_FIELD1.text = dpName1;
  int i = nameCheck(dpName1, 1);

  if(i == 0)
    DebugN("The datapoint name does not contain any illegal characters:", dpName1);
  else
  {
    DebugN("Datapoint name contains illegal characters");
    DebugN("Corrected name: ", dpName1);
    delay(3,30);
    TEXT_FIELD1.text = dpName1;
  }
}

Assignment

Datapoint function

Availability

CTRL