Explain me in simple terms, what are the difference between these?
Never used Gosub, always only Goto. Maybe I lose some abilities not using Gosub?
Goto vs Gosub
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Goto vs Gosub
Goto branches to a label, changing the execution of the script to that line.
Gosub runs a subroutine, returning to the same point when the subroutine has finished.
Gosub runs a subroutine, returning to the same point when the subroutine has finished.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: Goto vs Gosub
It looks I can do all with Goto>Label without Gosub. When Gosub is preferred to Goto?
Just never even tried to use Gosub, always used Goto>Label, and it always worked. Maybe with Gosub I can make my program shorter or easier to remember if I am back at its code after a year or so?
Can something be done with Gosub, what cant be done with Goto?
Just never even tried to use Gosub, always used Goto>Label, and it always worked. Maybe with Gosub I can make my program shorter or easier to remember if I am back at its code after a year or so?
Can something be done with Gosub, what cant be done with Goto?
Re: Goto vs Gosub
Gosub should be prefered, there is a reason for most programming languages to have ditched goto statements. That reason has to be the fragility, your code after using goto statements is more prone to error than it is after using gosub.
There are different posts around... here is a more detailed explanation.
https://www.quora.com/Why-are-goto-brea ... er-science
There are different posts around... here is a more detailed explanation.
https://www.quora.com/Why-are-goto-brea ... er-science