bmax equvalent of this

BlitzMax Forums/BlitzMax Beginners Area/bmax equvalent of this

a.mytype=first mytype


is there such a thing i know i can addlast and addfirst but is there anything like a getfirst or getlast.......

TList has a First and Last Method which returns an object.

Here's how I handle types, it makes things much easier to manage.

Type TMyType
	Global list:TList 'list that is global to the type and so can be accessed outside of an instance
	Field X:Float
	Field Y:Float
	
	Function Create:TMyType(X:Float , Y:Float) 
		
		If list = Null Then list = New TList
		
		Local temp:TMyType = New TMyType
			temp.x = x
			temp.y = y
			list.addLast(temp) 
			
		Return temp
		
	End Function
	
	
	Function getFirst:TMyType() 
		'since list.first() returns an generic object, we need to cast it as a TMyType to use it properly
		Return TMyType(list.first())
	End Function
	
	
	Function getLast:TMyType()
		Return TMyType(list.last())
	End Function
	
End Type

'make some types
TMyType.Create(10.25 , 10.25)
TmyType.Create(100.23 , 283.12) 
TMyType.Create(50 , 10)
TmyType.Create(1200.23 , 213.112) 
TMyType.Create(10 , 350)
TmyType.Create(1500.23 , 213.12) 
TMyType.Create(450 , 10)
TmyType.Create(9100.23 , 223.12) 

Local a:TMyType = TMyType.getFirst() 

Print a.x

For Local i:TMyType = EachIn TMyType.list
	Print i.x + " : "+i.y
Next


Each type then has it's own list that can be accessed directly or iterated through either via an instance of the type:
a.list
or through the type itself:
TMyType.list


seems so simple so i see it...thanks....