Object and Handle

Blitz3D Forums/Blitz3D Programming/Object and Handle

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Basicly handle creates a unique integer reference to a type instance and object recovers the type instance for a given handle. The integer reference is incremented sequentially for each new handle obtained, so this will eventually overflow if you create a lot of instances and get handles for them.

You get a handle simply by doing
num=handle(q.qaz)

You test for a valid handle for a type instance by doing

q.qaz=object.qaz(num)
if q<>null then ...

This will fail if the type instance referenced by a given handle belongs to another type or has been deleted.

Now this does have its uses but they are few and far between . The favorite use is fast entity lookup into a type list by storing the handle to the type in the entity name. There is an example on the archives. http://www.blitzbasic.com/codearcs/codearcs.php?code=216