Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sub help ... they want me to clear what?
#1
ok i am makeing a game for school the catch is there cannot be any goto statements and its a text based game (as long as you use texted based comands) ok heres my problem because its texted based im useing subs alot and when i run the game and go in and out of about 20 rooms the game chrashes and it says "out of stack space" and it says i need to use clear ... how do i do this and what dose it do? (it crashes on the a line going into a sub used alot in the game)
ever wish for anything because if you have a wish in one hand and shit in the other what do you have?
Reply
#2
Each time you enter a sub, the adress in the program where execution was before you entered the sub is pushed onto the stack.
So the program knows where to continue execution when it exits the sub.

Code:
clear , , X
Where X is a number, look it up in the QB helpfile.


Do note that:
GOTO/GOSUB is considered bad coding until you know what you're doing. And should be avoided.

Using SUBs the way you apparently is doing it, is equally as bad, as you never know how large the free stack space is on any given computer.
Reply
#3
ok i see what i did i went from sub to sub instead of leting the subs end ok thanks for the help
ever wish for anything because if you have a wish in one hand and shit in the other what do you have?
Reply
#4
EVERY GOSUB must be exited in a RETURN. You can call GOSUBS from other GOSUBS, but at last every one must RETURN to the caller, and the first one must RETURN to the main program.

If you don't do it like this, ther return adresses are not removed from the stack, until it fills up and the program crashes.

You could crash too by going too deep in calling gosubs from other gosubs, but the first problem is more common.
Antoni
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)