logical function shows incorrect Boolean value

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
pavel0529
Posts: 5
Joined: 22 Apr 2021, 04:33

logical function shows incorrect Boolean value

27 Sep 2021, 06:58

Hello, logical function shows incorrect Boolean value.
Inside of my clipboard is text "12345"
I call function countNumberOfCharecters and it returns 5.
Then I check it if(%numberOfCharactersInClipboard%=5)
I expected that it will show "MsgBox, number of character is five"
But due to some reason "MsgBox, %numberOfCharactersInClipboard%" esecuted
This meant that AHK thinks that 5 is not equal to 5.
I suppose i made a mistake somewhere in code but can not find that. Could you help me with that?

Code: Select all

numberOfCharactersInClipboard := countNumberOfCharecters(clipboard)

if(%numberOfCharactersInClipboard%=5)
{
MsgBox, number of character is five
} else
{
MsgBox, %numberOfCharactersInClipboard%
}

countNumberOfCharecters(str)
{
T=%str%
Loop, Parse, t
     a++
Return, a
}
gregster
Posts: 9056
Joined: 30 Sep 2013, 06:48

Re: logical function shows incorrect Boolean value

27 Sep 2021, 07:20

if(%numberOfCharactersInClipboard%=5) should be

Code: Select all

if (numberOfCharactersInClipboard=5)
If with parentheses means: It's expression syntax. See also If.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Sarhad, tosia and 279 guests