Passing arrarys to a function
Blitz3D Forums/Blitz3D Programming/Passing arrarys to a function| 
 | ||
| Is it possible to pass arrays to a function? For example Dim a(10) function Thisfun(param()) this value = param(1) end function Thisfun(a()) Hopefully, this sloppy code will demonstrate what I mean! | 
| 
 | ||
| Arrays are global so I'm not sure there is any need to pass an array to a function? | 
| 
 | ||
| The inability to pass arrays to functions was an unfortunate "feature" of Blitz and is one of the reasons another kind of array was introduced. There is a very terse introduction buried in the documentation for Dim: http://blitzbasic.com/b3ddocs/command.php?name=dim&ref=goto These are one dimensional and may not be relevant if you are still working on the Game of Life. | 
| 
 | ||
| Depending on the type of data you're working with, Banks may be another option. You can create as many as you need (so they're basically instancable) and a Bank handle is an integer, so you can easily pass it to and from a function. Parsing and storing data in a Bank is a much more hands-on affair though, but you can store whatever data you want (you're not limited to a single data type per bank). | 
| 
 | ||
| You can use the local-fixed-size-arrays form instead (not "Dim") Local MyArray%[12] MyArray[1] = 50 Function MyFunction%(Param%[12]) value = Param[1] return value End Function Print MyFunction(MyArray) waitkey end | 
| 
 | ||
| Thanks, all! |