Jump to content











Photo

If command


  • Please log in to reply
1 reply to this topic

#1 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 29 December 2008 - 04:27 PM

Since a long time it is a well used practice to use 'nested' if commands:

If,<condition1>,If,<condition2>,If,<condition3>,command

In former times this worked well, but now we have an 'else' command

If,<condition1>,If,<condition2>,If,<condition3>,command
Else,command

Which 'False If Condition' causes the Else command beeing executed?
#1, #2, #3 ???

I have no logical idea.

JonF PMed me a bug.

Simplified:

if,Not,a,equal,a,if,b,equal,b,begin
echo,x
end

Here the Echo command is executed and the End command raises a 'stack Error', inspite both commands should be skipped.

I fixed that (075 beta 5 K). But if there are three If in a line, this cannot be fixed. Similar question as above.

Therefore:
@ .script developers:

Try to use begin .. end more frequently!
e.g.

If,<condition1>,Begin
If,<condition2>,Begin
If,<condition3>,Begin
...
End
End
End

Here it is also rather easy to place the Else correctly, maybe also with Begin ... End.

And the above sample should be:

if,Not,a,equal,a,begin
if,b,equal,b,begin
echo,x
end
end



Peter

BTW: I'll have a look whether the Begin ... End blocks can be permanently indented in the script.

#2 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 29 December 2008 - 06:13 PM

BTW: I'll have a look whether the Begin ... End blocks can be permanently indented in the script.

I implemented this.

Have a look here

Peter




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users