NLSFormatNumber

NLS Function: Returns a correctly formatted number string for the current locale.

Module: USE DFNLS

Syntax

result = NLSFormatNumber (outstr, instr [, flags ])

outstr
(Output) Character*(*). String containing the correctly formatted number for the current locale. If outstr is longer than the formatted number, it is blank-padded.


instr
(Input) Character*(*). Number string to be formatted. Can only contain the characters '0' through '9', one decimal point (a period) if a floating-point value, and a minus sign in the first position if negative. All other characters are invalid and cause the function to return an error.


flags
(Optional; input) INTEGER(4). If specified, modifies the number conversion. If you omit flags, the flag NLS$Normal is used. Available values (defined in DFNLS.F90 in /DF/INCLUDE) are:


Results:

The result is of type INTEGER(4). The result is the number of characters written to outstr (bytes are counted, not multibyte characters). If an error occurs, the result is one of the following negative values:

Compatibility

CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB

See Also: NLSFormatTime, NLSFormatCurrency, NLSFormatDate

Example

 USE DFNLS
 CHARACTER(40) str
 INTEGER(4) i
 i = NLSFormatNumber(str, "1.23")
 print *, str                            ! prints 1.23
 i = NLSFormatNumber(str, "1000000.99")
 print *, str                            ! prints 1,000,000.99
 i = NLSSetLocale("Spanish", "Spain")
 i = NLSFormatNumber(str, "1.23")
 print *, str                            ! prints 1,23
 i = NLSFormatNumber(str, "1000000.99")
 print *, str                            ! prints 1.000.000,99