Page 1 of 1

(SOLVED) Comparing Pointers

Posted: Mon Mar 08, 2021 4:55 pm
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.

Re: (SOLVED) Comparing Pointers

Posted: Mon Mar 08, 2021 7:48 pm
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>"

Re: (SOLVED) Comparing Pointers

Posted: Wed Mar 10, 2021 1:02 pm
by sphere
Thank you.
When I ever get the courage to dive into LCB again, then i will plow thru all these threads.