Problems with Accessing Types

Blitz3D Forums/Blitz3D Beginners Area/Problems with Accessing Types

Do a search for 'Handle' and 'Object'.

These are two undocumented functions that have been OK'd for use (I thought I read somewhere that they HAD been officially documented ...)

'Handle' allows you to get a handle to an already created object. This object-handle can be stored in an array, passed around to functions, etc.. It's just a simple integer.

'Object' allows you to get a 'pointer' back to the original object. The same type of pointer 'new', 'first', 'next' or 'last' would return.

Example 1:
Type MyType_t
 Field Foo%
End Type

local ptr0.MyType_t = new MyType_t
ptr0\Foo = 99
'ptr0' can be used to access the types fields, but 'ptr0' cannot be stored in an array or passed to other functions.


Example 2:
Type MyType_t
 Field Foo%
End Type

local ptr0.MyType_t = new MyType_t
ptr0\Foo = 99
local hobj% = <b>Handle</b>(ptr0) ;; 'hobj' would equal '0' were 'ptr0' not a valid pointer
'hobj' cannot be used to access the types fields, but 'hobj' can be stored in an array and passed to other functions.


Example 3:
Type MyType_t
 Field Foo%
End Type

local ptr0.MyType_t = new MyType_t
ptr0\Foo = 99
local hobj% = <b>Handle</b>(ptr0)
local ptr1.MyType_t = <b>Object</b>(hobj)<b>.</b>MyType_t ;; 'ptr1' would equal NULL were 'hobj' not a handle to an object of type 'MyType_t'
ptr1\Foo = 111
'ptr0' and 'ptr1' now refer to the same object. I.E. 'ptr0\Foo' and 'ptr1\Foo' both equal '111'

HTH