I have a little problem with SUBs. I'm not sure if anyone can help me with this without looking at the code, but here I go.
In my program I have more than 10 SUBs (that changes nothing) and I call one from another. And here goes the problem: very often after a few secondes previous SUB loads without me doing anything.
Has anyone had a problem like this? If yes, PLEASE HELP ME
SUBs
When you run a sub from the main code it will go through and run the subs code and return to where it was. The same is true when you run a sub from a sub, the sub that you called from the sub will run then return to the original sub. The example demonstrates this best.
Output will be
1
2
3
Code: Select all
DECLARE SUB Test1 ()
DECLARE SUB Test2 ()
CALL Test1
SUB Test1
PRINT "1"
CALL Test2
PRINT "3"
END SUB
SUB Test2
PRINT "2"
END SUB
1
2
3
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
Beware of recursive calls! IE calls that go back and forth between two SUBs. Error will be "Out of Stack Space".
You should have some kind of condition for calling a SUB or it will run every loop until you leave the loop.
Same with FUNCTIONs.
Ted
You should have some kind of condition for calling a SUB or it will run every loop until you leave the loop.
Same with FUNCTIONs.
Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0