Posts: 13
Threads: 5
Joined: Jun 2003
Hello,
I am wondering about the DATA command.
Lets say I have this data here.
Code: DATA 0,0,0,1,0 'Group 1
DATA 0,0,1,0,1
DATA 0,1,0,0,0
DATA 0,0,1,0,0 'Group 2
DATA 0,1,0,1,0
DATA 0,1,1,1,1
DATA 0,0,1,1,1 'Group 3
DATA 1,0,0,1,1
DATA 0,0,0,0,0
What is there is one group I want before the other? What if I access one and want it again? What if I want 3, then 1 then 2 then 3 again? Is this possible? Thanks!
Posts: 1,956
Threads: 65
Joined: Jun 2003
First of all, you can't put comments on a DATA statement. The comments will be treated as additional data.
There is a command, I can't remember the name, which ,after you have the DATA statements into your program's memory, allows you to reset and be able to read them again.
If you want to get them in a different order, read them the first time into different arrays corresponding to your "group" numbers. Then you can process them how you please.
*****
Posts: 3,368
Threads: 195
Joined: Jan 2003
what if you just forget about data commands, you silly gopher, and use files and OPEN? Just make a search for it on this site..
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 1,752
Threads: 21
Joined: Jun 2002
Code: Group1:
DATA 0,0,0,1,0
DATA 0,0,1,0,1
DATA 0,1,0,0,0
Group2:
DATA 0,0,1,0,0
DATA 0,1,0,1,0
DATA 0,1,1,1,1
Group3:
DATA 0,0,1,1,1
DATA 1,0,0,1,1
DATA 0,0,0,0,0
RESTORE Group3
FOR i = 1 TO 3
FOR j = 1 TO 5
READ k
PRINT k;
NEXT
PRINT
NEXT
PRINT
RESTORE Group1
FOR i = 1 TO 3
FOR j = 1 TO 5
READ k
PRINT k;
NEXT
PRINT
NEXT
PRINT
RESTORE Group2
FOR i = 1 TO 3
FOR j = 1 TO 5
READ k
PRINT k;
NEXT
PRINT
NEXT
PRINT
Posts: 13
Threads: 5
Joined: Jun 2003
Plasma,
I think I see what you mean. So you use RESTORE GROUP to go to GROUP:. Correct? Then it sets it to where you want to go, ready to read?
Posts: 1,752
Threads: 21
Joined: Jun 2002
Posts: 13
Threads: 5
Joined: Jun 2003
Cool, cool. That is what I'm looking for! Thanks all!
Charles A. Crane
Posts: 3,343
Threads: 83
Joined: Mar 2003
Quick note: use RESTORE on its own to go to the top of data.
|