Passing arrays to functions..

Blitz3D Forums/Blitz3D Beginners Area/Passing arrays to functions..

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Arrays in Blitz are global and can't be passed to functions.

One solution is just to use Walk in the Render_This function, albeit that this not very modular, but then we are dealing with a Basic language here.

There are things called "blitz arrays" that are not documented and can be passed to functions and made members of types etc.

Here is a (very silly) example. Notice that the arrays are passed by "reference" which means that the function can modify the array that is passed in and the results are seen at the top level. The same would be true for entities etc.

Global c[10]

Type T
	Field b[10]
End Type

Function fred(x[10])
	Print x[1]
	x[1] = 23
End Function

k.T = New T

k\b[1] = 1
c[1] = 2

fred(k\b)
fred(k\b)
fred(c)

WaitKey


If you'd rather stay within the documented stuff, you are probably going to have to use a bank instead.

Hope this helps,

Steve.