Qbasicnews.com

Full Version: About using GOTO . . .
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9
Goto: use it but don't abuse it ;-)

Glenn: I've started to think about giving Blitz a custom rank, kinda like personal trainer but actual name of personal aggrevator.

Blitz: Is your posting style self taught or did you have to learn how to be so combatant? :rotfl: Could I interest you in a custom rank of "n00bie"? :bounce:
D00d, are you calling me a n00b? omg! Smile
Nah, it took years of training. I had to go up in the mountain in tibet and live with the munks for years.
:rotfl:
How many people think that people who show pictures of food in their "avatar" should have to throw a party and feed all the people they've made hungry?
Now this is fun!!!!

:rotfl:
That is the bad side of QBasic being a recursive lingo... Sad Why are you even in 27 nested loops anyways? Don't forget that using GOTO in this situation leaves the 27 loops on the stack clogging up your precious stack space.

Edit: This was designed as a reply to nathan (see p1)
of nested IF THEN/ELSE constructs. (I don't see why the stack would be involved at all. Such constructs usually get translated to jump instructions.) The reason such large nested structures are used is likely because people are trying to avoid GOTO. There aren't any rules regarding how deep of a nesting level might be required by any given application. The application determines that, not bureaucrats. (And nested IF THEN/ELSE constructs isn't recursion.)
*hands Glenn an apple*

A gosub/return SHOULD be translated as 2 GOTOs.
Quote:That is the bad side of QBasic being a recursive lingo... Sad Why are you even in 27 nested loops anyways? Don't forget that using GOTO in this situation leaves the 27 loops on the stack clogging up your precious stack space.

Edit: This was designed as a reply to nathan (see p1)

I have never seen loops which use the stack for any purposes. Stacks are used in PROC calls (assembly), which are more or less functions and subroutines.

You can test it by yourself. Write something like:

Code:
WHILE i%>0
FOR j%=0 TO 7
  FOR k%=7 TO -100 STEP -3
   DO
    FOR h%=1 TO 1000
     WHILE amber%>100
      amber%=amber%+1
      IF j%+amber%>=h% THEN GOTO ending
      k$=INKEY$
     WEND
    NEXT h%
   LOOP WHILE INKEY$=""
  NEXT k%
NEXT j%
i%=i%+1
WEND
ending:
PRINT "Exit"

And generate the assembly listing. You'll notice no PROC calls, so no stack involved.
(I appreciate the trouble you went to to find one without the worm. Smile )

Well, yes, a GOSUB/RETURN would involve two jumps, but that *would* use the STACK.
Pages: 1 2 3 4 5 6 7 8 9