Posts: 29
Threads: 9
Joined: Oct 2004
When I put DATA operator into SUB I get this:
Illegal in sub, function or defint!
What does it mean!? Why can't I use data into SUB's? Thank you!
Posts: 979
Threads: 27
Joined: Aug 2001
Simply that. You can't use DATA outside the main routine. If you can, learn to live without DATA. If you need it, load it into a shared variable at the start of the program, and then access that.
Posts: 354
Threads: 11
Joined: May 2002
If I remember right, you can the access DATA from anywheer in your program even though it's in the main routine. I could be wrong though - it's been a while and I dont have a PC to test it on right now..
In a world without walls and doors, who needs Windows and Gates?
Posts: 1,080
Threads: 87
Joined: Feb 2002
AFAIK The
"DATA Stuffhere"
can only be put in the main routine
while "READ mystuff%" can be put
anywhere and will read from the DATA
part in the main routine.
/post]
Posts: 719
Threads: 72
Joined: Mar 2003
well, here is a solution:
[syntax="qbasic"]
DECLARE SUB Blah ()
RESTORE datablock1
CALL Blah
END
datablock1:
DATA 1,2,3
SUB Blah
FOR n% = 1 to 3
READ a%
PRINT a%
NEXT n%
END SUB
[/syntax]
Oz~