Array Handles?

Blitz3D Forums/Blitz3D Beginners Area/Array Handles?

Hi,

I know that you make arrays with Dim name(number) but is it possible to give an array a handle? Like

array= Dim name(number)

oviously the above dosen't work or I wouldn't be posting but is there a way to do something like?

well, the command itself does not support it, as you mention. at least not to my knowledge

what about

dim name(number)
array = name(number)

@sinu
that would work only for a single array field thing. I am doing it with type instances so I want to do something like

For system.system=Each system
   system\par_array.particle=Dim array.particle(par_num)
Next


I definintly need the data in an array. Does any one know of any work arounds for this?

There is no "array" data type.

I would say to just use a pointer to the first element. Can't really do that in Blitz, though.

The only workaround I can think of is to have your array within a custom type "wrapper", e.g.:
Type Particles
	Field particles[100]
End Type


Then you can create one instance of that type Particles (which will create the whole array), and just store that variable within your System type object.

In fact ther is an array data type. The ones with [] can be used almost just like an object: you can have local ones, global ones, pass them to functions. The only thing you can't do with them is return them from a function.
Local array[5]
For i = 0 To 5 
	array[i] = 3 * i
Next

Function f(t[5])
	For i = 0 To 5
		Print t[i]
	Next
End Function
f(array)

The only concern is that these kind of arrays is suppsoed to be implemented in a somewhat hack-is way (dixit Mark Sibly)

@soja
Thats not a bad idea:) I think I will try it.

Thanks for all the help

Thanks Koriolis, I didn't realize it had more data-type-ish properties (like being able to pass it into a function, ala "f(array)").

Pity you can't return it from a function, though.

Bluewolf, see if something like this works for you too.
Function f(t[5])
	For i = 0 To 5
		Print t[i]
	Next
End Function

Type System
	Field x%
	Field ParticleArray[5]
End Type

s.System = New System
s\ParticleArray[0] = 0
s\ParticleArray[1] = 1
s\ParticleArray[2] = 2
s\ParticleArray[3] = 3
s\ParticleArray[4] = 4
s\ParticleArray[5] = 5
f(s\ParticleArray)