Page 1 of 1
Posted: Sat Sep 01, 2007 10:42 am
Now, I've used data and read statements for quite some time. Now I'm getting a syntax error for my Read statement
Here's my code:
FOR Y% = 1 TO NUMBER% 'number is the number of cubes
FOR X% = 1 TO 6 '6 sides of a cube
READ C% 'read some data
LET CUBES(Y, X) = C% 'store it to an array
DATA 000, 000, 000, 000, 000, 000 'INTRO CUBE
DATA 000, 000, 000, 000, 000, 000
... more data
Have I forgotten something?
Posted: Sat Sep 01, 2007 2:14 pm
Ohh... the compiler was looking at the remarks after Data. That would explain a lot.
Is there a way around this? I want to title my data.
Posted: Sat Sep 01, 2007 3:01 pm
Mentat wrote:Is there a way around this?
No. Anything after DATA is counted as data. There is no way to put a remark on a DATA line.
Of course, you can always do this
' Here is some data
' And here is some other data
Posted: Mon Sep 03, 2007 5:53 pm
The only way I know of adding remarks to the end of a DATA line is by putting a colon at the end of them, like this:
DATA 000, 000, 000, 000, 000, 000: 'INTRO CUBE
DATA 000, 000, 000, 000, 000, 000: 'ICE CUBE?
I didn't know about that trick until last year, and I don't think the QB manual even mentions it. It's in the QBKB here: http://kb.qbasicnews.com/Q36395.TXT
Posted: Mon Sep 03, 2007 6:07 pm
Thanks a lot
. But I might switch over to .DAT instead. See the Loading post.
Posted: Mon Sep 03, 2007 8:13 pm
Dav wrote:The only way I know of adding remarks to the end of a DATA line is by putting a colon at the end of them
Good point, Dav! I forgot about that.
And I usually always use colon before remarks to keep the spacing. I hate it when
x = 1 'First guy
x = 1'First guy
so I do
x = 1: ' First guy
I should have noted that this would apply to DATA also
Posted: Wed Sep 05, 2007 3:33 pm
People, please use code tags. It makes your post a lot easier to read, as some of you just randomly put code anywhere in your post, and sometimes it's hard to differentiate between the code and your post.
Posted: Thu Sep 06, 2007 6:21 am
People, please use code tags
So that's what those buttons are for
I didn't post there just for fun. I KNOW somebody has the answer.