If var is [not] type, didnt work in obj array

Report problems with documented functionality
rodemp9090

If var is [not] type, didnt work in obj array

28 Dec 2016, 02:05

Code: Select all

ABC:=Object()
ABC[1]:="abcde"

if ABC[1] is digit					;-not work
	MsgBox, ABC[1] is digit

tmp:=ABC[1]

if tmp is digit					;-its work
	MsgBox, tmp is digit
just me
Posts: 9478
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: If var is [not] type, didnt work in obj array

28 Dec 2016, 05:00

The docs wrote:var

[indent=1]The variable name.[/indent]
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: If var is [not] type, didnt work in obj array

28 Dec 2016, 08:30

yep read the docs:
https://autohotkey.com/docs/commands/IfIs.htm

otherwise use AHK v2 and it works like this:
https://lexikos.github.io/v2/docs/commands/is.htm

Code: Select all

;requires AHK v2

ABC:=Object()
ABC[1]:="abcde"

if ABC[1] is "digit"					; works
	MsgBox, ABC[1] is digit

tmp:=ABC[1]

if tmp is "digit"					; works
	MsgBox, tmp is digit

User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: If var is [not] type, didnt work in obj array

29 Dec 2016, 12:44

Already getting into adding the first quirks aren't we?
Recommends AHK Studio
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: If var is [not] type, didnt work in obj array

29 Dec 2016, 12:45

nnnik wrote:Already getting into adding the first quirks aren't we?
what does that mean

User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: If var is [not] type, didnt work in obj array

29 Dec 2016, 13:03

AutoHotkey 1.1 is often described as quirky due to a lot of exceptions in it's syntax. (Mainly the confusion between having to use Variable Names/Expressions/Strings)
Until now operators always accepted expressions. This one is an exception essentially making it a quirk ( and by doing so defying the reason v2 even came into creation )
Recommends AHK Studio
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: If var is [not] type, didnt work in obj array

29 Dec 2016, 13:55

nnnik wrote: Until now operators always accepted expressions. This one is an exception essentially making it a quirk ( and by doing so defying the reason v2 even came into creation )
this still doesn't make any sense

do you mean "expressions accept operators"? because if so, its not "until now", its "still true". nothing has changed

what "one exception" are you talking about?

User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: If var is [not] type, didnt work in obj array

29 Dec 2016, 15:52

No I mean what I said.
is is an operator.
It takes a Variable name instead of an expression.
Recommends AHK Studio
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: If var is [not] type, didnt work in obj array

29 Dec 2016, 16:00

nnnik wrote:No I mean what I said.
is is an operator.
It takes a Variable name instead of an expression.
wrong.

is is NOT an expression operator in AHK v1. all operators are listed on this help page:
https://autohotkey.com/docs/Variables.htm#Operators

in AHK v1, if var is type is a COMMAND, and this command takes a variable, not an expression:
https://autohotkey.com/docs/commands/IfIs.htm

in AHK v2, is IS an operator, and works in all expressions (not just if statements), and is listed as such in the AHK v2 help page:
https://lexikos.github.io/v2/docs/Varia ... #Operators

User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: If var is [not] type, didnt work in obj array

30 Dec 2016, 05:28

Well something made me think this was v2 related.
Recommends AHK Studio

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 35 guests