Poll: What do you think about using goto in your programs?
You do not have permission to vote in this poll.
Always use GOTO
0%
0 0%
Often use GOTO
37.50%
3 37.50%
Somtimes use GOTO
12.50%
1 12.50%
Rarely use GOTO
37.50%
3 37.50%
Don\'t use GOTO
12.50%
1 12.50%
Total 8 vote(s) 100%
* You voted for this item. [Show Results]

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The forbidden GOTO
#1
Does anyone else use goto to write spaghetti programs like me?
WHILE RPG$ <> "complete" : make up silly excuses :WEND
Reply
#2
That's all hogwash really. Goto wouldn't even be there if you weren't supposed to use it!  Big Grin Of course, abuse is another story. A good rule of thumb is don't use goto to move backwards in your program, unless it's just a short hop, if you know what I mean.
Reply
#3
I was taught not to use it but I really see no problem with using it.
Reply
#4
Using or not using GOTO is an age old debate. Simply put its best to not use it if you can as using it can make your program code a little harder to read but otherwise use it in small doses. Just remember there is usually more than one way to do code something.
Reply
#5
one of my spaghetti programs can be downloaded here:
http://practicalqbprogs.googlepages.com/peanuts
WHILE RPG$ <> "complete" : make up silly excuses :WEND
Reply
#6
Jack of The Qbasic Station wrote a good article on this a while ago:

http://www.qbasicstation.com/index.php?c=t_article&a=10
-yah
Reply
#7
Good reference, Zoasterboy!  I'm in agreement with it, too. 

One instance where I use the GOTO is when I am trouble shooting.  I'll enter this at the beginning of the code:
Code:
TEST = 0
TEST = 1
INPUT1 = 124 'just use any default value for the first INPUT statement
INPUT2 = 25   'default value for second INPUT statement
'etc.
Then, whenever the code is supposed to receive an INPUT statement, I'll add, just before it:
Code:
IF TEST = 1 THEN GOTO SKIP1
and I'll conclude that part of code with:
Code:
SKIP1:
Now, I can run my code over and over, without having to stop and enter something at each INPUT statement, letting me quickly get to the problem(s) I am trying to find and debug. 

Once the program runs fine, I either remark out the line,
TEST = 1
which allows me to further trouble shoot easily in the future, or, if I'm very sure I will not have to do any more debugging,  I will delete both "TEST =" lines, and all the pertinent GOTO... and SKIP1:, SKIP2:, etc. labels.
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)