how to scripting goto and labels?
how to scripting goto and labels?
sample: dosen't work Code:
if (blabla)Code:
if (blabla)Code:
if (blabla) |
Re: how to scripting goto and labels?
Sample 1 works, but not as you think.
PHP Code:
- if bla is true, we goto label and execute code 2 - if bla is false, execute code1 then goto label and execute code2 Now, if we change the code to PHP Code:
- if bla is false, execute code1 then we exit "else" block and we execute code 2 Same thing, right? Check this to see how i've tried to use it, i've managed to perfect that plugin by not using goto, i just hope you'll see the use of it in that context. Basically, you can use goto to jump back or forward some code, preferably many lines. Moar stuff on goto. |
Re: how to scripting goto and labels?
Goto's should only be used if you have no other possible solution.
In this case, you can do it with only if() statements. Sample 1: PHP Code:
PHP Code:
PHP Code:
|
Re: how to scripting goto and labels?
Quote:
|
Re: how to scripting goto and labels?
Quote:
|
Re: how to scripting goto and labels?
ah ok i understand thank you both
|
Re: how to scripting goto and labels?
Quote:
|
Re: how to scripting goto and labels?
I can't think of any good reason to use goto. As mentioned, it's always possible with other methods. Also, goto makes it difficult to read program flow.
Maybe the compiler should mark goto as deprecated to force people to avoid (at least one) bad programming habit. :P |
| All times are GMT -4. The time now is 14:32. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.