dpSetUnit()

Sets the unit of a DP element.

Synopsis

int dpSetUnit(string dp, langString dpUnit);

Parameters

Parameter Meaning
dp Data point
dpUnit Unit (for example, kg) in one or several languages.

Return Value

If OK the value is 0, in the event of an error -1.

Errors

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

Description

The unit can be modified using the CTRL function dpSetUnit().

The use of "@" or another character used as DPCommentSeparator, will result in the data point comment being separated at the character. The characters after the first "@" character will be saved as data point format, the characters after the second "@" as the data point unit. Should the "@"character be needed, the separator character can be changed with the config entry [general] DPCommentSeperator.

Example

Sets the unit m².

main()
{
  dpSetUnit("mld_float.", "m²");
}

Example

Sets two different units EUR and USD for two different languages German and English.

main()
{
  langString c;

  setLangString(c,0,"EUR");
  setLangString(c,1,"USD");

  dpSetUnit("integer_1.",c);
}

Assignment

Data point function

Availability

CTRL