Question about Type and Each command

Blitz3D Forums/Blitz3D Beginners Area/Question about Type and Each command

Yes it is normal, they are indeed two different pointers, but both point to the same structure; that means that they go through the same list, thus the same element collection.

If you want two different lists, you can choose between:

1) make two different type structure and pointers (type chair_1 and chair_2, pointer mychar_1 and mychar_2)
OR
2) use only one type structure and one pointer, and add an additional field - ex. ID - which can be set each time you create a new element. Example (one structure and one pointer):

Type chair
 Field ID ;--------> New Field added !
 Field colour$
 Field Height%
End Type

mychair.chair = New chair
mychair.ID = 1 ;here we set the new ID field
mychair\colour$="Blue"

mychair.chair = New chair
mychair.ID = 2 ;here we set the new ID field
mychair\colour$="brown"

cont=1

;Display only the chair with ID = 1
For mychair.chair= Each chair
 If mychair\ID = 1 then
   Print "ELEMENT: " + cont + " - "+mychair\colour$
   e$=Input()
   cont=cont+1
 EndIf
Next

End


Personally, I would use the 2nd choice.

Sergio.