Releasing an object from its own method?

BlitzMax Forums/BlitzMax Beginners Area/Releasing an object from its own method?

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.

I usually do types something like this:

Type TMyType
	Global List:TList
	Field value:Int
	
	Function Free(t:TMyType)
		If ListContains(List, t) Then ListRemove(List, t)
		t = Null
		FlushMem
	End Function
	
	Function Create:TMyType(val:Int)
		Local tempMyType:TMyType = New TMyType
			tempMyType.value = val
			If Not List Then List = New TList
			List.AddLast(tempMyType)
		Return tempMyType
	End Function
End Type


TMyType.Create(10)
TMyType.Create(14)
TMyType.Create(17)

For Local t:TMyType = EachIn TMyType.List
	Print t.Value 'print the values
	TMyType.Free(t) 'free the type
Next