On May 16, 2006, at 2:45 PM, Dan Stenning wrote:

Now that ive tried and used ptr, a few questions:

1) when using Addressof to point to an RB function, does the ptr work fine
with C++  ( I presume so since its intended as a callback )


Yes.


2) can I point to class instance methods or am I limited to global functions
in modules?


Yes, but you need to pass "self" in, like you would if you were writing a plugin.


3) am I free to copy the pointer to an int , using casting etc ?


Yes, you can cast Ptr to Integer, and Integer to Ptr.


4) can I do integer calculations etc? Ie can I add an index to the pointer?


Not quite -- you can add two pointers, but you can't add an integer to a pointer. So, you can say myPtr + Ptr(1) to increment it, if you'd like.


5) saw this in your release notes: the ability to dereference it (ptr) with
any structure-safe type : how does this work ?


Just use the dot notation. Ie:

dim p as Ptr = someMemoryBlock

while p.UInt8 <> 0
 p = p + Ptr(1)
wend

That'll loop until it finds a byte with a value of "0". Note that autocomplete doesn't work in r2.


6) also : "There is an optional byte offset parameter" could you explain
this ?


You can also write the above loop such as:

dim p as Ptr = someMemoryBlock
dim i as Integer

while p.UInt8(i) <> 0
  i = i + 1
wend

If the offset isn't specified, it's assumed to be 0.


7)  is it ok, allowable to pass/use Ptr as an argument datatype in RB
methods and functions ?


Yes... as long as those functions take that as a type :)

HTH,
Jon


--
Jonathan Johnson
[EMAIL PROTECTED]
REAL Software, Inc.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to