(SOLVED) Comparing Pointers

LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.

Moderators: LCMark, LCfraser

Post Reply
PaulDaMacMan
Posts: 683
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

(SOLVED) Comparing Pointers

Post by PaulDaMacMan »

This doesn't seem to work for me:

Code: Select all

if tPointerA is tPointerB then
...
When I log the contents of the two variables of type Pointer they are identical:

Code: Select all

["Next Pointer=", <foreign pointer 0x7fac7c796260>, "Current Pointer =", <foreign pointer 0x7fac7c796260>]
Is there a way in LCB to compare two pointers to determine if they point to the same block of memory?
I looked at foundation.h header file but didn't notice anything like "MCPointerIsPointer()" that could be applicable.

Or maybe there's a way to dereference or coerce Pointers into another type that I can compare?
I think a way to convert Pointers to / from a String or a Number would be very useful in a few situations.
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList
PaulDaMacMan
Posts: 683
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: (SOLVED) Comparing Pointers

Post by PaulDaMacMan »

Answering my own question...

binding to

Code: Select all

bool MCValueIsEqualTo(MCValueRef value, MCValueRef other_value);
found in livecode's foundation.h header did the trick,
here is the binding code:

Code: Select all

__safe foreign handler MCValueIsEqualTo(in rPtrA as Pointer, in pPtrB as Pointer) returns CBool binds to "<builtin>"
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList
sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: (SOLVED) Comparing Pointers

Post by sphere »

Thank you.
When I ever get the courage to dive into LCB again, then i will plow thru all these threads.
Post Reply