Re: your personal AutoHotkey style guide
Posted: 22 Jul 2019, 10:30
From my PM conversation with Flipeador:
Me:
Me:
Flipeador:In your Ahk2Exe on GitHub you sometimes use something like
but sometimesCode: Select all
; https://github.com/flipeador/Ahk2Exe/blob/master/Ahk2Exe.ahk#L457 if (Var != "")
Could you explain, is there any difference between them? And why you use slightly unusual if (Var != "") instead of if (Var)?Code: Select all
---- ; https://github.com/flipeador/Ahk2Exe/blob/master/Ahk2Exe.ahk#L546 if (Var)
In AutoHotkey it is true that an empty string is interpreted as FALSE, but for me this is not appropriate. So, if a function returns an empty string to indicate error, I prefer to use if (var == ""), it's more explicit and clear. On the other hand, if the function returns zero in case of error, I use if (var == 0) or if (!var). Also AHK interprets a number in a string just like a pure number, which I disagree with as well (when used with if strnum == num). I never handle an empty string as FALSE.
This is true on v2.0-a103-56441b52:
Code: Select all
MsgBox "0x00009" == 9