Manipulating Types

Blitz3D Forums/Blitz3D Beginners Area/Manipulating Types

wmaass(Posted 2008) [#1]
Using the example in the manual for Types, how I delete 5 of the chairs from the list?


Stevie G(Posted 2008) [#2]
You can do it like this if you only want to delete the first 5.

; Define the CHAIR Type

Type Chair
Field x#
Field y#
Field height#
End Type

; Create 100 new chairs using FOR ... NEXT 
For tempx = 1 To 10
	For tempy = 1 To 10
		c.chair = New Chair
		c\x = tempx
		c\y = tempy
		c\height = Rnd(0,10) ; set a random height 0 to 10
	Next
Next 

; Move them all over 1 (like the description example) 
For c.chair = Each chair
	c\x = c\x + 1
Next 


Print "CHAIRS: "+CHAIRcount()

;delete the first 5 chairs
For chairs = 1 To 5
	c.chair = First chair
	Delete c
Next

Print "CHAIRS: "+CHAIRcount()

MouseWait


Function CHAIRcount()

	Count = 0
	For c.chair = Each chair
		Count = Count + 1
	Next
	
	Return Count	

End Function



wmaass(Posted 2008) [#3]
Yes, any 5 would do for my purposes so this would work great, thanks!