STR

Synopsis

HELP:   String representation of an floating point number
TYPE:   OBJECT
SYNTAX: STR(CHRSET=NONE/SYSTEM/ASCII/UCS1/UTF8/EBCDIC/UCS2BE/UTF16BE/UCS2LE/UTF16LE/UCS4BE/UTF32BE/UCS4LE/UTF32LE/LOCAL,SEPARATOR=SYSTEM/PERIOD/COMMA/APOSTROPHE,GROUPSEPARATOR/MARKER=num/NON/OFF/SYSTEM/PERIOD/COMMA/SPACE/APOSTROPHE,VALUE='str',ALLOWTRUNC)

Description

Reads a string representation of an real number. The result is an FL5-internal neutral real number representation which can be converted to any of the supported target real number representations by a corresponding write converter.

The string must be in decimal (base 10) format.

The CHRSET parameter must match the character set of the string. If no character set is specified, the system's default character set is assumed. All character sets supported by the character conversion module can be used, including multi-byte charsets.

If the string has some leading or trailing whitespace characters, they are ignored.

The SEPARATOR parameter specifies the character that separates integral and fractional portions of the number (i.e. period or comma). If not specified an auto detection is done. The automatic determination is not 100% clear. If it is not possible to clearly identify which character serves as the separator, the previous setting is used; if nothing has been recognized to date, the system defaults are used. We therefore recommend setting one of the separators to the correct value. This saves the expensive auto-recognition and misinterpretation of the numbers, which results in the following examples.


 123          - don't need correct separators
 1.234        - this is not unique it could be 1234 oder 1.234
 1.23         - this is unique for fractional separator '.'
 1,2          - this is unique for fractional separator ','
 1.2345       - this is unique for fractional separator '.'
 12.234       - this is not unique
 123.456      - this is also not unique
 1.234,456    - this is unique for fractional separator ','
 1.234.456    - this is unique for group separator '.'

With the system defaults the read numbers are expected to be in the locale-dependent default number format (e.g. environment variable LC_NUMERIC on Linux). The auto detection is only supported for single byte ASCII, EBDIC oder UTF-8 character strings.

The VALUE parameter, defines a default float in local char set and decimal base and period as floating point separator. An empty string will be replaced by default value and don't result in an error anymore.

Arguments