QBasic Chapter4 by iQckp8W1

VIEWS: 10 PAGES: 13

									QBasic



  Chapter 4 - Input &
  Output
Input & Output

   Methods of inputting data
   Methods of output and formatting
Input

   Storing Data in Variables
    – INPUT statement
    INPUT “Please enter your age”; Age
    INPUT Name$, Address$, Phone$
    Separate variables by commas
    – INPUT must come first
    – Program stops to wait for input
    – No quote needed for character strings
    – Separate multiple input by commas
    – Must enter all necessary values or error will occur
    – Must enter data in correct format or error will occur
Input

   Displaying Prompts for the User
    – If no text is entered, only a ? will appear
    – Can use a PRINT keyword or not
    PRINT “Enter your birthdate:” results in: Enter your birthdate?
    INPUT BDate

    INPUT “Enter your birthdate: ”; BDate
    – Inquiry-and-Response or Conversational Mode
    – Use a comma instead of semicolon to remove the question
      mark
    – Use space w/in the quotes when needed
Output

   Formatting Results
    – Semicolon – separates two or more variables in a single
      PRINT statement
    PRINT “Tarleton”; “State”            will print:
    TarletonState
    PRINT “Tarleton”; “ State”           will print:
    Tarleton State
    – Numeric digits are not adjacent like character strings
    PRINT 100; -200; 300                 will print:
    100 -200 300
Output

   Print Zones – 14 characters wide, five zones per line
    Zone 1 Zone 2 Zone 3 Zone 4 Zone 5

     Col 1   Col 15   Col 29   Col 43   Col 57


  Use commas to move output to next zone
PRINT “Have”, “A”, “Good”, “Day”   will print:
Have          A     Good         Day
(in zones 1-4)
Output

   Print Zones
    –   Additional data will go to Zone 1, Line 2
    –   If data is wider than 14 characters, it will go into
        next zone
    –   A zone can be skipped by using more than 1
        comma
Output

   TAB Function
    – Allows more flexibility in output
    PRINT TAB(10); “Juniors Register”; TAB(25);
      “Today”
    – No backspacing allowed
Output

   SPC Function
    – Similar to TAB
    – Used for spacing between output
    PRINT “CIS”; SPC(10); “110”       will print:
    CIS        110
Output

   LOCATE Statement
    – Used to position cursor at a specified column &
      row
    LOCATE 10, 15
    PRINT “Computer”
    – Rows –> 1 to 25
    – Columns –> 1 to 80
Output

   Sending Output to the Printer
    – LPRINT – sends to paper
    – PRINT USING – use for formatting
    – X = 23.456
    PRINT USING “###.##”; X            will print:
    _23.46
    – PRINT USING with $
    – $ - leaves spaces for blanks
    – $$ - moves $ next to value
Output

   PRINT USING Format$
    Format$ = “####.##”
    V1 = 4.562
    PRINT USING Format $; V1   will print:
    4.56
Edit Menu

   Alt-E or use mouse to click
    –   Cut
    –   Copy
    –   Paste
    –   Clear

								
To top