Classic Computer Magazine Archive COMPUTE! ISSUE 49 / JUNE 1984 / PAGE 129

Atari TAB

Stephen Levy, Editor, COMPUTE! Books

Atari BASIC has no built-in TAB or SPC functions. Here are four ways you can set up TABs.

Although there are no TAB or SPC functions built into Atari BASIC, the functions do exist. It is true that these functions are somewhat less convenient than those found in other BASICs, but they are no less powerful.

Most Atari users overcome the need for a TAB by using the POSITION statement. The POSITION statement is similar to the TRS-80 command PRINT AT. The short program below will illustrate how the POSITION statement works.

10 PRINT CHR*(125)
20 FOR X=0 TO 20
30 POSITION X, X: PRINT X
40 NEXT X

Two zero page locations are useful when the TAB function is needed. The following program accomplishes the same task as the previous program, but uses a POKE to location 85.

10 PRINT CHR$(125)
20 FOR X=0 TO 20
30 POKE 85, X: PRINT X
40 NEXT X

The number POKEd into 85 is the actual column to which the cursor is moved. If the cursor is at column 30 and the computer encounters a POKE to 85 less than 30, the cursor will move to the next line. The cursor will not move to the specified location until something is actually printed on the screen.

The second useful page zero location is 201. Location 201 contains a 10 when the Atari is turned on, which means that the tabs have been set to 10. By POKEing another number into this location, we can change the tab settings. Placing a comma after a PRINT statement will cause the next PRINT statement to print at the next available tab stop.

Try this:

POKE 201,15:PRINT "COMPUTE!","Magazine"

Notice how the words have been separated. The next example will help you understand how different numbers POKEd into 201 will affect the tab stops. The program will accept only numbers from 4 to 29.

10 PRINT CHR$(125)
20 TRAP 20: PRINT "HOW MANY SPACES BE
   TWEEN TAB STOPS";:INPUT TAB
30 IF TAB<4 OR TAB>30 THEN 20
40 POKE 201, TAB
50 PRINT :PRINT "POKE 201,"; TAB
60 COL=PEEK(85): PRINT COL, 
70 IF C0L+ TAB>38 THEN 90
80 GOTO 60
90 PRINT :G0T0 20

If you POKE 201,1 the computer will leave three spaces. Likewise, POKE 201,2 will leave four spaces. POKE 201,0 will cause problems when the next PRINT statement with a comma is encountered.

Spaces

Perhaps the simplest method of leaving spaces between prints is to put spaces within quotes. This may be the preferred method when spacing is used just a few times within a program. However, when this method is needed often within a program and the number of spaces will vary, it may be convenient to create a string of 38 spaces. Once the string is created, you need to call only the number of spaces required.

10 DIM    SPC$(380): SPC$="  " : SPC$(38)=SP C$:SPC$ (2) =SPC$
20 PRINT "15": SPC$(1, 15): "spaces"

Nicely Formatted Names

Let's assume you wish to create a listing of names, nicely formatted on the screen. You can use any one of the methods discussed here. Each program below uses one of these methods, but all create the same screen display.

Program 1: TAB Using POKE 201

10 PRINT CHR$ (125): POKE 201, 13
20 DIM NAME$ (10), ADDRESS$ (25)
30 PRINT "NAME", "{3 SPACES} ADDRESS"
50 PRINT
60 FOR A = 1 TO 4
70 READ NAME$, ADDRESS$
80 PRINT NAME$, ADDRESS$
90 NEXT A
100 END
110 DATA ADAMS, 12 MAIN STREET
120 DATA ARTHUR, 1515 SUNNY STREET
130 DATA SMITHSON, 100 CIRCLE DRIVE
140 DATA WEEKS, 2 DONNA LANE

Program 2: TAB Using A String Of Spaces

10 PRINT CHR$ (125)
20 DIM SPC$ (38), NAME$ (10), ADDRESS$ (2
   5)
30 SPC$ = " ":SPC$ (38) = " " : SPC$ (2) = SPC
   $
40 PRINT "NAME" ; SPC$ (1, 12) ; "ADDRESS"
50 PRINT
60 FOR A = 1 TO 4
70 READ NAME$ ; SPC$ (LEN(NAME$), 12) ; ADDRESS$
80 PRINT NAME$ ; SPC$ (LEN (NAME$), 12) ; A
DDRESS$
90 NEXT A
100 END
110 DATA ADAMS, 12 MAIN STREET
120 DATA ARTHUR, 1515 SUNNY STREET
130 DATA SMITHSON, 100 CIRCLE DRIVE
140 DATA WEEKS, 2 DONNA LANE

Program 3: POSITION Example

10 PRINT CHR$ (125)
20 DIM NAME$ (10), ADDRESS$ (25)
40 PRINT "NAME" : POSITION 18, 1 : PRINT
"ADDRESS"
50 PRINT
60 FOR A = 1 TO 4
70 READ NAME$, ADDRESS$
80 PRINT NAME$ : POSITION 14, A + 2 : PRINT
    ADDRESS$
90 NEXT A
100 END
110 DATA ADAMS, 12 MAIN STREET
120 DATA ARTHUR, 1515 SUNNY STREET
130 DATA SMITHSON, 100 CIRCLE DRIVE
140 DATA WEEKS, 2 DONNA LANE

Program 4: POKE 85 Example

10 PRINT CHR$ (125)
20 DIM NAME$ (10), ADDRESS$ (25)
40 PRINT "NAME" ; : POKE 85, 18 : PRINT "A
   DDRESS"
50 PRINT
60 FOR A = 1 TO 4
70 READ NAME$, ADDRESS$
80 PRINT NAME$ ; : POKE 85, 15 : PRINT ADD
   RESS$
90 NEXT A
100 END
110 DATA ADAMS, 12 MAIN STREET
120 DATA ARTHUR, 1515 SUNNY STREET
130 DATA SMITHSON, 100 CIRCLE DRIVE
140 DATA WEEKS, 2 DONNA LANE