Q(uick)BASIC Routine: SetFormatCC
Quick View
SetFormatCC
This routine sets the country code used by the FormatX$ functions
Worth knowing
Useful and cross-version information about the programming environments of QBasic and QuickBasic.
Syntax
- SetFormatCC (countrycode%)
Description/Parameter(s)
countrycode% | Any international telephone dialing prefix; determines the display format of numeric strings formatted by one of the FormatX$ functions. The default is 1, the United States countrycode. |
- The argument countrycode% is the international telephone dialing prefix for the country chosen as the target audience when using the FormatX$ functions.
- The only reason to use SetFormatCC is to change what the FormatX$ functions expect as thousands-separator and decimal-point formatting characters.
- The default setting for the country code is the United States (1). If you set the country code to France (33), the following statement would display the number 1,000 (U.S.) as 1.000,00:
- PRINT FormatD$(1#, "#.##0,00")
- The format you use with the FormatX$ functions must be compatible with the current country code in order for formatted numbers to display properly.
- If you set the country code to one of the following countries, the FormatX$ functions expect alternative formatting characters: Austria, Belgium, Brazil, Canada (French), Denmark, France, Germany, Italy, Netherlands, Norway, Spain, Sweden, or Switzerland.
- To use SetFormatCC in the QBX environment, use the DTFMTER.QLB Quick library. To use SetFormatCC outside the QBX environment, link your program with the appropriate DTFMTxx.LIB file. Depending on the compiler options you chose when you installed BASIC, one or more of the following files will be available:
Filename | Compiler options |
DTFMTER.LIB | 80x87 or emulator math; DOS or OS/2 real mode |
DTFMTAR.LIB | Alternate math; DOS or OS/2 real mode |
DTFMTEP.LIB | 80x87 or emulator math, OS/2 protected mode |
DTFMTAP.LIB | Alternate math; OS/2 protected mode |
- The FORMAT.BI header file contains the necessary function declarations for SetFormatCC.
- For more information on using libraries, see "Creating and Using Quick Libraries" and "Using LINK and LIB" in the Programmers Guide.
Example
This example uses the CCUR function to convert a double-precision, floating-point value to currency data type. The program performs an interest calculation in double precision, but displays the result as a currency value. The SetFormatCC routine is used with the FormatC$ function to display the currency amount in the formats of the United States and West Germany.
Note: To run this example you must use a Quick library that includes the procedures contained in the date/time/format library files. The following include file must also be present.
'$INCLUDE: FORMAT.BI
DECLARE FUNCTION GetSalesTax@ (Amount#, percent!)
CONST percent! = 8.1
CLS
INPUT "What is the taxable currency amount "; Amount#
PRINT
USCurFmt$ = FormatC$(GetSalesTax@(Amount#, percent!), "$#,###,###,##0.00")
SetFormatCC (49) West Germany.
WGCurFmt$ = FormatC$(GetSalesTax@(Amount#, percent!), "#.###.###.##0,00")
WGCurFmt$ = WGCurFmt$ + " DM"
PRINT "In the United States, currency is displayed with commas as"
PRINT "numerical separators and a period serves to separate whole from"
PRINT "fractional currency amounts. In some European countries, the "
PRINT "numerical separator is a period, and the comma serves to"
PRINT "separate whole from fractional currency amounts."
PRINT
PRINT "In the US, the tax on $"; Amount#; "at"; percent!; "percent is "
PRINT "displayed as "; USCurFmt$
PRINT
PRINT "In West Germany, the tax on"; Amount#; "DM at"; percent!; "percent is"
PRINT "displayed as "; WGCurFmt$
END
FUNCTION GetSalesTax@ (Amount#, percent!)
GetSalesTax@ = CCUR(Amount# * (percent! * .01))
END FUNCTION
See also: