Page 1 of 1
Read/Data error!
Posted: Sat Sep 01, 2007 10:42 am
by Mentat
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
NEXT X%
NEXT Y%
... blah
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
by Mentat
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
by Mac
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
DATA Blah
DATA Blah
' And here is some other data
DATA Blah
Mac
Posted: Mon Sep 03, 2007 5:53 pm
by Dav
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
- Dav
Posted: Mon Sep 03, 2007 6:07 pm
by Mentat
Thanks a lot
. But I might switch over to .DAT instead. See the Loading post.
Posted: Mon Sep 03, 2007 8:13 pm
by Mac
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
becomes
x = 1'First guy
so I do
x = 1: ' First guy
I should have noted that this would apply to DATA also
Mac
Posted: Wed Sep 05, 2007 3:33 pm
by Patz QuickBASIC Creations
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.
[/code]
Posted: Thu Sep 06, 2007 6:21 am
by Mentat
People, please use code tags
So that's what those buttons are for
.
please goto:
http://www.petesqbsite.com/forum/viewtopic.php?t=2428
I didn't post there just for fun. I KNOW somebody has the answer.