On May 16, 2006, at 12:20 PM, Dan Stenning wrote:

DO you mean I can use Ptr as a datatype in Structs?

Certainly; you can use it anywhere you like. The idea of a declare- only type went away in RB 5.5.

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, that's exactly what it's for.

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

You can use shared methods or module methods as callbacks, but not, generally speaking, instance methods.

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

Yes, you can cast a ptr to an integer, and vice versa.

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

You can add an offset to the pointer, yes, but that's the only arithmetic operator allowed.

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

Dim foo As Ptr
Dim bar As Integer
foo.Integer = 42
bar = foo.Integer

You can use the name of any structure-safe type in place of "Integer" to peek or poke a value of the appropriate type from the ptr's target.

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

Dim foo As Ptr
Dim bar As Boolean
foo.Boolean( 6 ) = True
bar = foo.Boolean( 6 )

You can pass an optional integer parameter to the "method call", which is a byte offset from the pointer itself.

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

Sure.

Mars Saxman
REAL Software


_______________________________________________
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