passing a type to a function

Blitz3D Forums/Blitz3D Beginners Area/passing a type to a function

cermit(Posted 2005) [#1]
I want to do this:

Function Update()
   for t.thing = Each thing
      If t\thing_type$ = "window" Then UpdateWindow()
   Next
End Function

Function UpdateWindow()
   Rect w\window_x, w\window_y, 32, 32, 0
End Function
I could do this:
Function Update()
   for t.thing = Each thing
      If t\thing_type$ = "window" Then UpdateWindow(w\window_x, w\window_y)
   Next
End Function

Function UpdateWindow(wnd_x, wnd_y)
   Rect wnd_x, wnd_y, 32, 32, 0
End Function
But i don't want to use locals (wnd_x, wnd_y) if i can do it without them.


Rob Farley(Posted 2005) [#2]
You could do

for t.thing = each thing
updatewindow(t)
next

function Updatewindow(t.thing)
rect t\windowx,t\windowy,32,32,0
end function



cermit(Posted 2005) [#3]
Works perfect :D thanks