Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
USING Keyword 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.
' To try this example:
' 1. Choose New Project from the File menu
' 2. Copy the code example below to the code window
' 3. Press F5 to run the example
CLS ' Clear the 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
Amount = Amount * Quantity ' Calculate subtotal
Total = Total + Amount
LPRINT USING "### "; Quantity; ' Print line of receipt
LPRINT USING "\ \"; Item$;
LPRINT USING "$$######,.##"; Amount
LOOP
LPRINT ' Finish receipt
LPRINT TAB(12); "Total amount paid: ";
LPRINT USING "$$#######,.##"; Total