Getting Started
Introduction
Sample Programs
QBasic IDEs
History
Advice
Tools
Mini-Tutorial
Tutorial
Code Snippets

Resources
Web Sites
More Tutorials
Vendors
Books
Magazines
NewsLetters
NewsGroups
Forums
User Groups
Talk Shows
Blogs

GBIC >> QBasic >> Tutorial >> Printing

QBasic Information Center Tutorials - Printing
These tutorials were written to help you get a quick, but thorough, understanding of QBasic - the scope of the language as well as it's specific capabilities.

Printing
QBasic's support for printing is limited to text output to a printer device (known as a line printer in prior years).

    • Print Commands    
     lprint, lprint using 
    • Print Command Modifiers    
     lpos, spc, tab, width 

Printer Functions Reference
Here's a quick reference of the available printing functions, in alphabetical order.

  • lpos - returns last printed position on the current line
        result% = lpos(n%)   # n% values:  0=LPT1 1=LPT1 2=LPT2 3=LPT3
        

  • lprint - prints to LPT1
        lprint a$, b%, c%      # prints 3 variables, cursor moves to next line
        lprint a$, b%, c%;     # prints 3 variables, keep cursor on same line
        lprint a$, b%, c%,     # prints 3 variables, move to next print zone
        

    If statement ends with semicolon to keep cursor on same line, or with comma to move cursor to the next print zone.

  • lprint using - prints to LPT1 using custom format
        lptrint using format$, a$, b%, c%    # custom format
        

    If statement ends with semicolon to keep cursor on same line, or with comma to move cursor to the next print zone.

  • spc - moves cursor a specified number of columns
        lprint a$; spc(20); b$  # b$ prints 20 spaces after a$
        

  • tab - moves cursor to specified column
        lprint tab(column%), a$       # starts printing a$ in column 40
        

  • width - sets width of printed lines
        width lprint column%     # syntax
        width "LPT1", column%    # alternate syntax
        width lprint 40          # sets line width to 40 columns
        width "LPT1", 30         # sets line width to 30 columns
        

If you have any suggestions or corrections, please let me know.