If statement that brings back the wrong results Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
BScripting

If statement that brings back the wrong results

23 Oct 2017, 06:50

I am trying to figure out why this does not recognize "fork" ? I run it and it tells me hello or train :crazy:


Datak = "fork"
{
If (Datak="hello" or "train")
{
MsgBox You wrote hello or train
}
else
If (Datak="fork")
{
MsgBox You wrote fork

}
}
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: If statement that brings back the wrong results

23 Oct 2017, 07:16

Code: Select all

Datak := "fork"

if (Datak = "hello") or (Datak = "train")
{
    MsgBox % "You wrote hello or train"
}
else if (Datak = "fork")
{
    MsgBox % "You wrote fork"
}
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: If statement that brings back the wrong results  Topic is solved

23 Oct 2017, 07:46

The reason your If statements didn't work is because you tried to use statement mode vs. expression mode for setting variables.

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat

BScripting

Re: If statement that brings back the wrong results

23 Oct 2017, 08:35

Thank you jNizM for that it makes sense now and works

Delta, ill read up on that so I can understand better

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, jollyjoe and 146 guests