stringAsDecimal()

The system function mathLib.stringAsDecimal accepts a character value (like "98.6") and returns the equivalent value as a DECIMAL type. If the input is non-numeric, the function returns a null value.

If the character value to be converted is null or blank, the return value depends on the value of the I4GLItemsNullable property (see i4glItemsNullable). If I4GLItemsNullable is set to YES, the function returns a null value; otherwise the function returns 0. This behavior is the reason to use mathLib.stringAsDecimal rather than making a simple assignment (see Assignments). If you assign a blank value to a DECIMAL variable, EGL will throw an exception.

mathLib.stringAsDecimal(numberAsText STRING in)
  returns (result DECIMAL nullable)
numberAsText
A character field or literal string, which can include an initial sign character.
result
A field that can accept a DECIMAL value. The receiving field must be nullable and can have any decimal position and any length. EGL allows as many as 32 digits on either side of the decimal point. If you are generating Java™ code, the decimal point (if any) is specific to the locale.

Example

  myField = "-5.243";

  // result = -5.243
  result = mathLib.stringAsDecimal(myField);  

Feedback