Quote: "Again...... GoTo's were never great!"
I guess that depends on when you started coding.
In my college course in BASIC (I was already self taught in BASIC for many years prior to going to the university), the instructors examples used GOTOs.
GOTO was commonly used and not thought of as a bad thing, because it was used properly. (my instructor used it incorrectly in one example, but I caught it)
Just like OOP was around in the 1970's, but wasn't commonly used until the 1990's because in the 70's it was considered too complex.
Of course, the hardware was much different then, and as it advanced the thoughts about good and bad programming techniques changed over time.
It is only a matter of personal opinion as to whether GOTO is good or bad, just like anything else.
I never had a problem using GOTO, so I failed to see why so many people are against it.
There are many ways to create endless loops without using GOTO, so that argument is weak, even though it seems to be about the only reason GOTO gets negative feedback.
Jumping to one spot of a program using GOTO can be just as effective as a Function call or using GOSUB, as long as you GOTO another spot when you need too.
Back then your BASIC programs had line numbers that were mandatory when writing the code, so that helped GOTO have its place because jumping to a line number using GOTO made a lot of sense.
We used to write our code in increments of 10 with our line numbers (10,20,30,etc) that way we could add lines in between later without having to renumber the entire program.
It was a different world back then, in the programming world too, so at one time GOTO was useful, but as far as being great, that goes back to personal opinion so there is no right or wrong to it.
Quote: "#BanSpaghettiCode "
Spaghetti code has its place too.
Some programmers used to intentionally write their code in ways that made it difficult for others to understand.
It was all about job security, if you wanted to be the one hired to modify your own code rather than have someone else cut your throat (under price you) and do it instead.
Many times is was cheaper for them to have the original programmer untangle their mess when it needed to be modified, rather than have that cheaper guy spend 3 times as long trying to figure it out or rewrite it from scratch.
For business owners, yes ban it, but for programmers it can prevent others from modifying your stuff with ease. (we didn't use comments either)
The only problem is that even the original programmer can get confused if they have been away from the code for too long, so you have to have a method to your madness!
BASIC gives you the freedom to write your code almost any way you want to, that is why we see so many different examples on how to code the same objective.
If desire$ ="structured programming" then use$= "COBOL"
I think a lot of people get misled about this topic from the "non-believers" too.
For instance, IF you GOTO (lol) the article on Spaghetti Code at Wikipedia
, THEN you will find the example pieces of BASIC code...
3 PRINT i; "squared=";i*i
4 IF i>100 THEN GOTO 6
5 GOTO 2
6 PRINT "Program Completed."
1 FOR i=1 TO 100
2 PRINT i;"squared=";i*i
3 NEXT i
4 PRINT "Program Completed."
However, the first bit of GOTO code could have been done differently, which would have resulted in the same number of lines as the so called correct way...
1 i = i + 1
2 PRINT i; "squared=";i*i
3 IF i<100 THEN GOTO 1
4 PRINT "Program Completed."
In my opinion, it all comes down to results, and if the code does what it is supposed to do, then it doesn't really matter which way you chose to do it.
After all, it is your code, so doing it your way is okay.
Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1