Another 'Type' problem

Blitz3D Forums/Blitz3D Beginners Area/Another 'Type' problem

[quote]Am I missing something or should I create them as global at the beginning of my program[quote]

Yes, you are misunderstanding types. Types are always global, so your functions can always access each type.

type myType
  field field1
  field field2
end type

for n = 1 to 10
  ;m is local here

  m.myType = new myType
  m\field1 = n
  m\field2 = n * 2
next

PrintMyTypes

waitkey

function PrintMyTypes()
  ;t is local and goes through each myField type

  for t.myType = each myType
    print t\field1 + " " + t\field2
  next
end function


As you can see I have no global variables and can still access the types. Also I don't need to create a new variable for each type I create, I can reuse variables because of the way types work.

I can use the following:

t = first myType ;t points to the first type
t = last myType ;t points to the last type
t = after t ;t now points to the next type
t = before t ;t now points to the previous type