Page 1 of 1

"if..is type" not working with a property of an object

Posted: 09 Aug 2020, 08:18
by rhaos
i have an object and a string as its property
when i check its property is really a string, its not working..
a code i tried is below

Code: Select all

o:={},o.var:="str"
if o.var is number
    OutputDebug, true ; debug console output: true
if o.var is space
    OutputDebug, true ; debug console output: true
please let me know proper way
Thank you for help!

Re: "if..is type" not working with a property of an object  Topic is solved

Posted: 09 Aug 2020, 08:48
by swagfag
it doesnt work due to the documented limitation of If Var Is Type that it only accepts plain variables and doesnt work with expressions.
write urself a type function wrapping If Var Is Type or use one of the numerous ones other people have already posted on the forums or other places on the internet. dig around

this also applies to ur other thread(where the issue is that if var is type cant be used in expressions)

Re: "if..is type" not working with a property of an object

Posted: 09 Aug 2020, 09:32
by rhaos
Thank you swagfag!
it was my lackness..
now i found it you mentioned in ahk help doc
Note: The operators "between", "is", "in", and "contains" are not supported in expressions.
sorry for my stupid question

Re: "if..is type" not working with a property of an object

Posted: 09 Aug 2020, 10:08
by swagfag
not a stupid question, ahk limitation