Jump to content
IGNORED

Read data


Champions_2002

Recommended Posts

How do i basic to read a list of data and then print the list to the screen

 

Here is a small example of reading data in Atari BASIC using DATA statements. I chose to use a "dummy" data value to detect the end of data but there are other ways of doing this. I hope this helps.

 

10 DIM S$(20)

100 RESTORE 500:C=0

110 READ I

120 IF I=-1 THEN 200

130 READ R,S$:C=C+1

140 ? I;" ";R;" ";S$

150 GOTO 110

200 ? C;" items read"

210 END

500 DATA 1,1.1,one

510 DATA 2,2.2,two

520 DATA 3,3.3,three

530 DATA 4,4.4,four

540 DATA -1

Link to comment
Share on other sites

Atari BASIC is slightly different with strings so far as DATA goes.

 

Most BASICs actually require you to enclose them in quotes.

 

Atari BASIC just reads the quotes as if it was part of the data. Also, the DATA statement has to be the last one on a line.

 

e.g. 1000 DATA A,B,C,D:GOTO 2000

would not execute the GOTO, it would be read as a string of value D:GOTO 2000

 

The quote thing does have an up/downside. Upside is you can embed quotes in your strings easily. Downside is you can't embed commas in the string - you have to set them by other means.

Edited by Rybags
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...