Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 7/13/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

NLSFormatCurrency

NLS Function: Returns a correctly formatted currency string for the current locale. This routine is only available for Windows.

Module

USE IFNLS

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

outstr

(Output) Character*(*). Is a string containing the correctly formatted currency for the current locale. If outstr is longer than the formatted currency, it is blank-padded.

intstr

(Input) Character*(*). Is the number string to be formatted. It can contain only 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

(Input; optional) INTEGER(4). If specified, modifies the currency conversion. If you omit flags, the flag NLS$Normal is used. Available values (defined in IFNLS.F90) are:

  • NLS$Normal - No special formatting

  • NLS$NoUserOverride - Do not use user overrides

Results

The result type is 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:

  • NLS$ErrorInsufficentBuffer - outstr buffer is too small

  • NLS$ErrorInvalidFlags - flags has an illegal value

  • NLS$ErrorInvalidInput - instr has an illegal value

Example

 USE IFNLS
 CHARACTER(40) str
 INTEGER(4) i
 i = NLSFormatCurrency(str, "1.23")
 print *, str                              ! prints $1.23
 i = NLSFormatCurrency(str, "1000000.99")
 print *, str                              ! prints $1,000,000.99
 i = NLSSetLocale("Spanish", "Spain")
 i = NLSFormatCurrency(str, "1.23")
 print *, str                              ! prints 1 Pts
 i = NLSFormatCurrency(str, "1000000.99")
 print *, str                              ! prints 1.000.001 Pts