When to use Goto and not Do While/Until

120ThingsIn20Years

Senior Member
@120, if you were to place your DO . . . LOOP within a DO . . . LOOP block, then your two goto statements could be replaced in toto with EXIT instructions and the code would/should work exactly as you have written it.

The EXIT instruction causing you to exit at the end of the current DO loop, which in your case would put you immediately back into an iteration of the new DO . . . Loop structure.
Ok that works.

Thanks.

My code no longer works but I can now see that it should :)
 

hippy

Ex-Staff (retired)
I find this so difficult to understand, that I cant even tell if that does what I need it to do :)

I wish I'd learnt it correctly from the start.
One thing to remember is that there is no definitive "correct way" of doing anything in programming; there are always numerous ways to achieve the same thing.

People will have their preferences for the way they like best, there will be debate and disagreements as to which are the better and worse ways of doing things but the primary goal is to produce a program which works.

If you find you are struggling with something someone suggests then there is no reason you shouldn't discard that suggestion, do it the way you want to or how you best understand things. As you gain experience you will come to understand better the other ideas and suggestions and may choose to use them but it's not a requirement to do so, and certainly not when starting out.
 

inglewoodpete

Senior Member
I'll second what hippy says there.

People will have their preferences for the way they like best, there will be debate and disagreements as to which are the better and worse ways of doing things but the primary goal is to produce a program which works.
But I'll enhance that one a bit. I would say there are two primary goals:
1. Produce a program that works.
2. Produce it in such a way that you can revisit the code a year later and understand what it does without having to completely re-read every line. Particularly important if the revisitor is not the original programmer!
 

120ThingsIn20Years

Senior Member
IF nothing ELSE, GOTOs are great for some simulator fun: http://www.youtube.com/watch?v=TftZYLkJcyU
The programming equivalent of a "Useless Machine" : http://www.youtube.com/watch?v=Y2Sfjt4nmF8
I had someone from Adelaide University drop in to have a look at my aquaponics system a few weeks ago. In talking about keeping things simple, he told me about people who make "hello world" programs that are hundreds of lines long and insanely complex. Apparently it's something of a competition. That sounds like the kind of thing I'd be naturally good at :)

It seems such things are called (amongst other names) Rube Goldberg machines.
 

hippy

Ex-Staff (retired)
There are significant differences between Robinson and Goldberg; contraption versus contrivance, jerry-rigged but practical and purposeful versus the impractical and pointless.

It's notable that Robinson usually creates machinery or mechanisms which would work continuously while Goldberg often employs use-once components. While Robinson revels in the bizarre but workable, Goldberg seems to go more for the ridiculous and slapstick.

There is some cross-over and both did a lot more art beyond the mechanics they are mostly famous for but I've always felt Robinson was on the inside celebrating engineering solutions and 'make do' attitudes while Goldberg was more on the outside looking in and perhaps employing derision along the way. In my opinion, Robinson creates things to take delight in while Goldberg creates things to laugh at.
 
Top