Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why DATA doesn't work in SUB'S?
#1
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!
Reply
#2
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.
Reply
#3
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?
Reply
#4
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]
Reply
#5
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~
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)