Page 1 of 1

if(...).... in ohne line

Posted: 16 Jul 2017, 10:43
by SL5
I was surprised when I accidentally discovered this very strange behavior. On an unware statement nevertheless commandos. Later I realized that it was probably because it was all in one line. Other programming languages are no problem. An error message has it also nciht. I will now have to examine my other scripts.

the following lines works like a true condition:

if(false)lll...
if(0)lll...

follwong works like false (like expected):

if(false)
lll...
if(0)
lll...

with regex you could find it with:
^[ ]*if[ ]*\([^()]+\)[^{\s]+

used
AutoHotkey_1.1.26.01_setup.exe

Re: if(...).... in ohne line

Posted: 17 Jul 2017, 00:57
by TAC109
The IfEqual, IfNotEqual, etc commands can have another command on the same line - see the help documentation for details.

Re: if(...).... in ohne line

Posted: 17 Jul 2017, 02:34
by lexikos
(false) lll is a legitimate expression which concatenates the variables false (containing 0) and lll.

The condition of an IF statement is not required to be enclosed in parentheses. It is just a convenient way of disambiguating between IF-expression and the other types of IF statement, since expressions always allow parentheses and the other types of IF do not.
On an unware statement nevertheless commandos.
...

What? I'm guessing that was mistranslated.