[v2.0-rc.3] `#HotIf [string]` is always false Topic is solved

Report problems with documented functionality
User avatar
NovaChromatic
Posts: 22
Joined: 21 Dec 2021, 09:28
Contact:

[v2.0-rc.3] `#HotIf [string]` is always false

10 Dec 2022, 11:34

In v2, pressing a does nothing.

Code: Select all

#HotIf 'some string'
a:: MsgBox()
In v1, pressing a creates a MsgBox.

Code: Select all

#If "some string"
a:: MsgBox
This is not how the normal if statement works.

Here, a creates a MsgBox.

Code: Select all

a:: {
    if 'some string' {
        MsgBox()
    }
}
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: [v2.0-rc.3] `#HotIf [string]` is always false

10 Dec 2022, 13:43

I don't think this is a bug, the expression probably needs to evaluate to a non-zero number to be true, like hotif(). In any case, #Hotif 'quoted string' is pretty silly. Edit, it might be an oversight in the documentation on #hotif though

Cheers.
User avatar
NovaChromatic
Posts: 22
Joined: 21 Dec 2021, 09:28
Contact:

Re: [v2.0-rc.3] `#HotIf [string]` is always false

11 Dec 2022, 12:56

@Helgef I wrote #HotIf 'some string' for simplicity. #HotIf fn() is also always false if fn returns a string.

However, you are probably right that #HotIf needing a non-zero number to evaluate to true is the intended functionality because that is what is stated in the HotIf documentation.
User avatar
NovaChromatic
Posts: 22
Joined: 21 Dec 2021, 09:28
Contact:

Re: [v2.0-rc.3] `#HotIf [string]` is always false

11 Dec 2022, 13:05

But it's still weird because in the v1 documentation, Hotkey, If, % FunctionObject also says it needs a non-zero number, but #If "some string" works fine.
Tensai
Posts: 29
Joined: 12 Dec 2019, 14:15

Re: [v2.0-rc.3] `#HotIf [string]` is always false

11 Dec 2022, 15:41

Simply use a ternary ;)

Code: Select all

abc() => "Triggered"

#HotIf abc()
a::MsgBox(abc())

#HotIf abc()?true:false
b::MsgBox(abc())	; Triggered
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: [v2.0-rc.3] `#HotIf [string]` is always false

12 Dec 2022, 04:08

KingQuarter wrote:
11 Dec 2022, 13:05
But it's still weird because in the v1 documentation, Hotkey, If, % FunctionObject also says it needs a non-zero number, but #If "some string" works fine.
Well, v1 is filled with weirdness, so nothing weird with v2 being less weird, i.e., #hotif and hotif being consistent. Though, non-numbers being being false might be considered an inconsistency ;).
Simply use a ternary
!!abc()

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 23 guests