|
|
Goto command something went wrong! -A7.05
#148567
08/16/07 20:58
08/16/07 20:58
|
Joined: Jan 2007
Posts: 651 Germany
RedPhoenix
OP
User
|
OP
User
Joined: Jan 2007
Posts: 651
Germany
|
I just tried to use Goto command, but it seems that it doesn't work right anymore. Here is a simple code: Code:
function cha_tex_zahl() { if (tex_zahl < 16) { tex_zahl += 1; goto (down); } tex_zahl = 1; down : aktualize_tex(max_tex_size*integer(sqrt(tex_zahl)+1),tex_zahl); } This is how it should work right. At least I can't see anything wrong here (the aktualize_tex function works right, I previously had a return instead of the goto command in the code, but I wanted the function to be executed everytime). What happens is the engine gives a syntax_error message while starting. I played around with it and finally found out that leaving the brackets in the command goto down; solves that problem. But then the command only accepts labels that stand in the function above the goto, what definitely can't be right. EDIT: I don't know whether this problem already existed before A7.05 because I didn't use this command since A6.5 
Last edited by RedPhoenix; 08/16/07 21:01.
|
|
|
Re: Goto command something went wrong! -A7.05
[Re: RedPhoenix]
#148568
08/17/07 06:59
08/17/07 06:59
|
Joined: Aug 2006
Posts: 652 Netherlands
bstudio
User
|
User
Joined: Aug 2006
Posts: 652
Netherlands
|
the Goto command is evil! Better not use it. And yes it was removed in A7.
BASIC programmers never die, they GOSUB and don't RETURN.
|
|
|
Re: Goto command something went wrong! -A7.05
[Re: bstudio]
#148569
08/17/07 09:36
08/17/07 09:36
|
Joined: Oct 2004
Posts: 1,655
testDummy
Serious User
|
Serious User
Joined: Oct 2004
Posts: 1,655
|
I have heard or seen this 'goto is evil' mantra often enough, and I believe I know why it is considered 'evil'. I accept the advice about good practices, but I disagree with the generalizations, or the manner in which the advice is packaged and delivered. Typically, I tend to consider it bad form to assign an instruction a moral alignment. A certain usage or arrangement of instructions, can be considered less than optimal, and some elements might be misused more than others, but I wouldn't put horns on such elements, and state that they 'demonic' or 'controlled by the devil'. I think, to be consistent, if the instruction is available in C, it should be available in Lite-C. If the instruction is available in A6, it should be available in A7. For the most part, I believe, advice can be given, and suggestions can be offered, but the responsibility to use certain elements wisely, should be left up to the programmer. I argue that, in a few cases, the goto instruction was particularly useful in C-Script. If you are correct, and the 'goto' instruction was removed from A7 (particularly C-Script), then I now claim that it seems a hand of madness now often holds the reigns.
|
|
|
Re: Goto command something went wrong! -A7.05
[Re: RedPhoenix]
#148573
08/17/07 16:37
08/17/07 16:37
|
Joined: Oct 2003
Posts: 827 22�21'24"N 114�07'30"E
Frederick_Lim
User
|
User
Joined: Oct 2003
Posts: 827
22�21'24"N 114�07'30"E
|
hmm..no problem to me. I add this to my main and no problem Code:
start: goto quit; .. .. goto start; quit: sys_exit(NULL);
The level will quit. If I remark the "goto quit;", the engine will dead loop and prompt not enough entity reserve error.
|
|
|
|