Overcoming the DATA statement in BASIC

2 posts / 0 new
Last post
Offline
Last seen: 5 years 2 months ago
Joined: Dec 20 2003 - 10:38
Overcoming the DATA statement in BASIC

Ok, here's an old question that was asked years ago to the Apple 1 owners club members. I thought I'd answer this question.

How do you rewrite the BASIC program when you are using the DATA and READ command.

Answer: Easy, PEEK & POKE

Example
10 DATA 1,2,3,4,5,6,7,8,9
20 FOR I=1 TO 9
30 READ A(I):NEXT I

The fix:

In the monitor:

300:01 02 03 04 05 06 07 08 09

From BASIC:

10 Z=0:FOR I=1 TO 9
20 A(I)=PEEK(768+Z):Z=Z+1:NEXT I

You could even eliminate the Z and use I but I wanted to point out the easier way to show.

Hope this helps people converting BASIC programs.

Vince

iceandfire's picture
Offline
Last seen: 2 years 4 days ago
Joined: Dec 20 2003 - 10:38
Data Statement

Boy that answer took a long time getting to me. About 28 years! I wrote that question for the Apple I Owners Club newsletter back in 1978, and this is the first time I've seen the correct response to it. Vince is the winner. The only prize, though is a harty handshake and an attaboy!:-)

Larry

Log in or register to post comments