bas7ex.hlp (Topic list)
LPRINT USING Statement Programming Example
                       Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
'This example uses the LPRINT USING statement to print a receipt
'on the printer.
 
'Note: To run this program, you must have a printer connected to LPT1.
 
CLS             'Clear screen.
Total = 0
LPRINT "Your receipt:"
LPRINT
DO
    INPUT "Enter quantity (0 to end): ", Quantity
    IF Quantity = 0 THEN EXIT DO
    INPUT "Item name: ", Item$
    INPUT "Amount: ", Amount
    PRINT
 
    'Calculate subtotal.
    Amount = Amount * Quantity
    Total = Total + Amount
 
    'Print line of receipt.
    LPRINT USING "###  "; Quantity;
    LPRINT USING "\                        \"; Item$;
    LPRINT USING "$$######,.##"; Amount
LOOP
 
'Finish receipt.
LPRINT
LPRINT TAB(12); "Total amount paid: ";
LPRINT USING "$$#######,.##"; Total
 
 
'Sample Output
'
'Enter quantity (0 to end): 1
'Item name: Used car
'Amount: 3999
'
'Enter quantity (0 to end): 10
'Item name: Gallons gas
'Amount: .98
'
'Enter quantity (0 to end): 0
 
 
'Output on line printer
'
'Your receipt:
'
'  1  Used car                     $3,999.00
' 10  Gallons gas                      $9.80
'
'            Total amount paid:    $4,008.80