USING formats

Discussions related to the extensions to the language available in LBB
guest
Site Admin
Posts: 197
Joined: Tue Apr 03, 2018 1:34 pm

USING formats

Post by guest »

(copied from the old forum)

LB4's USING() function doesn't support the full range of formatting options usually available from PRINT USING in other dialects of BASIC. LBB provides a much more complete set, as follows:

#    The hash character is used to represent a digit position.
+    A plus sign at the beginning or end of the template string causes the sign (+ or -)
     to be printed before or after the number.
–    A minus sign at the end of the template string causes negative numbers to be printed
     with a trailing minus sign.
**   A double asterisk at the beginning of the template string causes leading spaces to be
     filled with asterisks. The ** represents two digit positions.
$$   A double dollar (or £) sign at the beginning of the template string causes a dollar
     (or £) sign to be printed to the immediate left of the number.
**$  A **$ (or **£) at the beginning of the template string combines the effects of the
     previous two formats.
,    A comma to the left of the decimal point in the template string causes a comma to be
     printed between every third digit before the decimal point.
^^^^ Four carets may be placed after the digit characters to specify exponential format.

For example:

Code: Select all

    print using("**$#,###.##-", -1234.567) ' **$1,234.57-
Richard.