Qbasicnews.com

Full Version: Data Commands
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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!
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.
*****
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..
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
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?
Yep.
Cool, cool. That is what I'm looking for! Thanks all!

Charles A. Crane
Quick note: use RESTORE on its own to go to the top of data.