'
' program name: Print_Using.bas
'
' This small program formats a float with two separate blocks.
' The first block is the interger part of the float separated
' in groups of three didits by a comma, the second group is
' the decimal part of the float rounded to 2 digits after the
' decimal point.
' The main purpose of this program is to format a float without
' using the PRINT USING command with a mask that places spaces
' in front of the number when the float is smaller than the mask
' and that puts the % character in front of the number when the float
' is larger than the mask.
'
'
' title of the windows when used in a console
'
'
' variable initialisation
'
Number# = 1.00
'
' main program
'
PRINT "Please enter a float: ";
PRINT "Using this function will print:" + Print_Using$
(Number#
) PRINT "PRINT USING command will print:";
'
' function to format the integer part of a float and round its decimal part at 2 digits.
'
Print_Using$ = intPart(nb#) + decPart(nb#)
'
' function to format and round the decimal part of a float at 2 digits.
'
dot$ = "."
partdec$ = ".00"
partdec$ = ".00"
partdec$ = partdec$ + "0"
partdec$
= LEFT$(partdec$
, 3) decPart$ = partdec$
'
' function to format the integer part of a float with groups of 3 digits.
'
idx = m3 + 4 + (m3 = 0)
i$
= LEFT$(i$
, idx
) + "," + MID$(i$
, idx
+ 1) idx = idx + 4
i$ = "0"
i$ = "-" + i$
intPart$ = i$