Jump to content
Sign in to follow this  
wraithdu

Comparisons With Ptr(x)

Recommended Posts

wraithdu

What kind of comparison is AutoIt doing here? Numeric or string? It seems like string to me, and that doesn't seem correct.

;broken
ConsoleWrite((Ptr(5) = 5) & @CRLF)
ConsoleWrite((Ptr(5) > 0) & @CRLF)
ConsoleWrite((Ptr(5) < 0) & @CRLF)

; works
ConsoleWrite((Number(Ptr(5)) = 5) & @CRLF)
ConsoleWrite((Number(Ptr(5)) > 0) & @CRLF)
ConsoleWrite((Number(Ptr(5)) < 0) & @CRLF)

Share this post


Link to post
Share on other sites
Richard Robertson

It's possible that instead of a pointer that equals 5, you got a pointer to a 5. The help file doesn't describe the result very well.

Share this post


Link to post
Share on other sites
wraithdu

The Ptr() function converts an expression into a pointer variant. A ConsoleWrite() of Ptr(5) outputs "0x00000005". For example, DllCall functions that can return INVALID_HANDLE_VALUE must be compared to Ptr(0xFFFFFFFF).

Share this post


Link to post
Share on other sites
Richard Robertson

I see. I don't really know what to tell you there. It doesn't make much sense to store it in a string.

Share this post


Link to post
Share on other sites
Valik

Uhh, somebody forgot to implement the logic for comparing pointers. There is literally no code there to do the comparison correctly.

It will be fixed in the next beta.

Share this post


Link to post
Share on other sites
Richard Robertson

Well that explains why it doesn't work. So what kind of answer was it giving? A null?

Share this post


Link to post
Share on other sites
Valik

Undefined comparisons default to False.

Share this post


Link to post
Share on other sites
wraithdu

Thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×