Liberty BASIC Help Online

USING( )
 
USING(templateString, numericExpression)
 
Description:
This function formats numericExpression as a string using templateString.  The rules for the format are similar to those in Microsoft BASIC's PRINT USING statement,  but since using( ) is a function, it can be used as part of a larger BASIC expression instead of being useful only for display output directly.  The template string consists of the character "#" to indicate placement for numerals, and a single dot "." to indicate placement for the decimal point.  The template string must be contained within double quotation marks.  If there are more digits contained in a number than allowed for by the template string, the digits will be truncated to match the template.
 
A template string looks like this:
 
amount$ = using("######.##", 1234.56)
 
As part of a larger expression:
 
notice "Your total is $" + using("####.##", 1234.5)
 
 
A template string can be expressed as a string variable:
 
template$ = "######.##"
amount$ = using(template$, 1234.56)
 
 
Using() may be used in conjunction with 'print'.  The following two examples produce the same result:
 
amount$ = using("######.##", 123456.78)
print amount$
 
print using("######.##", 123456.78)
 
The using() function for Liberty BASIC 3 has been modified so that it rounds its output like PRINT USING does in other BASICs.
 
Usage:
 
' print a column of ten justified numbers
for a = 1 to 10
    print using("####.##",  rnd(1)*1000)
next a
 
'sample output from the routine above:
  72.06
244.28
133.74
  99.64
813.50
529.65
601.19
697.91
   5.82
619.22


Copyright (C) 2003 Shoptalk Systems
Liberty BASIC - http://www.libertybasic.com/