Posts: 5
Threads: 1
Joined: Jun 2003
Ok i've checked the tutorials, and searched for "sub sprites" and I can't find anything to help.
My problem is this, I'm making a crappy animation, and I have a sub for each scene.
So when i was making the scenes I would make them their own file, then copy and paste into the subs. Now the problem seems to be that you cant have the DATA in the sub, it says:
"Illegal in procedure or DEF FN" I looked up the DEF with the QB help file, doesn't make any sense to me.
So I placed just the DATA into the main program. It works for scene1, which has only one sprite, but once it calls scene2(which uses the sprite from scene1, and a new sprite), it says out of data, and stops at the READ command for the second sprite.
Then I tried putting the entire array into the main program, and only left GET in the subs, so then it says "array not defined", of course.
So anyone have any ideas? And also if you need any of the code to help, just say so.
Thanks
Posts: 594
Threads: 11
Joined: Oct 2002
Post the whole code so that we can help you...
B 4 EVER
Posts: 5
Threads: 1
Joined: Jun 2003
lol....how do you copy and paste from inside qbasic...do you have to open it with notepad or something?[/code]
Posts: 354
Threads: 11
Joined: May 2002
DATA can only be read once. To quote myself from another thread:
Quote:Think on DATA as a line of lemmings, each time you read an item of data, the next lemming jumps off the cliff and dies. So you can't READ that lemming(data) again... unless you RESTORE that lemming to life... with RESTORE.
RESTORE brings all the lemmings back to life and lines them up at the top off the cliff. Also, you can put the DATA statements at the end of the code, they don't have to be in the flow control loops at all.
So with that in mind, the best thing to do is group your data under different labels, and use RESTORE on each when needed.
The moral of the story: you can't read dead lemmings.
In a world without walls and doors, who needs Windows and Gates?
Posts: 5
Threads: 1
Joined: Jun 2003
What post was that? I dont really know anything about data labels or anything.
I tried putting RESTORE before the READ statements, but I was just getting black sprites like there was no READ.
Posts: 729
Threads: 105
Joined: Feb 2003
Quote:lol....how do you copy and paste from inside qbasic...do you have to open it with notepad or something?[/code]
Yep, open it with Notepad, and copy the code here.
size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]
Posts: 1,813
Threads: 284
Joined: Mar 2003
Not only that, but when you get Out of Data errors, you should also check your code to see if you read too much data by accident. I sometimes do that when I use FOR ... NEXT loops to read my data...
earn.
Posts: 5
Threads: 1
Joined: Jun 2003
hmm I have WinXP with QBasic v 4.5 I think, its encrypted or something when I open with notepad:
Code:
ü Ââ Qÿÿ$ ´ Â¾Ã Æ >¿ ® ⡠¦ñ s V ÷ â º à Oà _ à  t { h ¬ »R H rightà @delayÅ¡ Victoria Day¤ left²@scene1 z WHEN color2 color1à @firework S C T xY yä COL) Wë d3 joec BF y2| delay1
heh that's just part of it
Posts: 704
Threads: 0
Joined: Dec 2002
.
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Posts: 6,419
Threads: 74
Joined: Mar 2002
You can't put DATAs inside a SUB. All DATA statements have to be in the main section (outside all subs). What you can do, is use a label for each section's data:
Code:
DataForSub1:
DATA ...
DataForSub2:
DATA...
...
And then, inside your SUBs, just do a RESTORE <label> where <label> is the correct label that precedes the DATA you need (DataForSub1 for SUB 1, and such).
About posting code: When you're gonna save the code, be sure to check "Save as Text", then hit Save. That way, QB will get rid of its crappy bytecode format and will save your code as a normal, plain text file that you'll be able to open with notepad.