HandleFromObject - HandleToObject ?

BlitzMax Forums/BlitzMax Programming/HandleFromObject - HandleToObject ?

You only need to call Release once you remove the integer handle (generated by HandleFromObject) from the array.

HandleFromObject stores the object along with an integer handle in a map, and when you use HandleToObject it looks up the handle in the map and returns the object if it is present. Calling Release will remove the object + handle from the map.

Check the source code for blitz.mod/blitz_handle.c if you still don't understand how it works.

This is how HandleFrom/ToObject works:
Type MyType
	Method say()
		Print "*burp*"
	EndMethod
EndType
Local a:mytype = New mytype

'
' Convert object to integer handle
Local b:Int = HandleFromObject(a)

'
' Convert integer handle to object
Local obj:mytype = mytype(HandleToObject(b))
obj.Say()

'
' Remove from handle/object map
Release b