(602) 326-3502

BASIC TAKES / by Richard Ramella

The Ins and Outs Of Computer I/O

Computer input/output, or I/O, is any activity that moves information into or out of a computer. In the mid-1960s the words input and output became part of our vernacular and soon became cliches meaning to give and get information.

In computer jargon, input means putting information into a device and output means taking it out. You enter information into and get information from computers. This month I'll look at some common I/O statements.

I/O Statements Defined

Reference books vary' in what they define as I/O statements for the TRS-80. To avoid confusion, I take this radical stance: Information that's moving comes from somewhere and goes somewhere. Where it happens to be represents only a waystation. Don't be greatly concerned by defining these concepts. You need only understand how these statements work to use them.

Basic I/O statements put information in memory through the keyboard, send information from memory to screen display or another device (printer or modem), and exchange information between memory and a storage device (cassette or disk). In Basic, I/O is as simple as pressing a keyboard character or typing in PRINT.

Examples in Print

The Print statement and variations of Print that create screen displays (Print Print Tab, Print Using) are I/O statements.

The Print statement displays one or several items. It displays literals (1, 40), variables (A, Bl), characters ("This is fun") and string variables (B$, MY$).

The statement Print 23 includes a line feed so that the next Print statement goes on the following line. However, if you put a semicolon after Print 23, the next Print statement appears

Program Listing 1. Acreage Yield program to demonstrate Print Tab.

on the same line, one space after the first one.

Separating a series of values by commas prints them within predefined zones on one or more lines. For example, type in PRINT 1,2,3,4 and press the enter key. Then type in PRINT 1;2;3;4 and press the enter key. See the difference?

The Print @ statement puts information at a specific screen position (0-1023 on Models I, III, and 4). For example, PRINT @ 50, "pickle" prints the word pickle at position 50. The same rules apply when using commas or semicolons.

Print Tab is a formatter. It starts to print material a specified number of spaces from the left-most screen position (0-255). Type PRINT TAB(12), "I start at the 12th position" and press the enter key. Try Acreage Yield in Program Listing 1 to see how this works in a program.

Print Using is a modification of the Print statement. One way to use it is with dollars-and-cents amounts you want printed in flush-right format.

Try running Program Listing 2. Enter amounts ranging from a few cents

Program Listing 1. Acreage Yield program to demonstrate Print Tab.


Was this article helpful?

0 0

Post a comment