123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|612|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz Max -> Making an array of arrays in blitzmax?

Sat, 24 Sep 2011, 23:55
Mog
Hey guys,

Been a while - have been doing other projects lately but started up programming again, and like usual, blitzmax and its arrays are making me rage.

Im trying to convert some C# code from someones perlin noise example, and i came across this little line:



Basically they're trying to make an array of 2 dimensional arrays indexed by octaveCount, problem is- blitzmax doesn't like doing this it seems. Anyone have any idea how this could be done- essentially making an Array of Arrays?

-=-=-
I am Busy Mongoose - My Website

Dev PC: AMD 8150-FX, 16gb Ram, GeForce GTX 680 2gb

Current Project: Pyroxene
Sun, 25 Sep 2011, 01:08
shroom_monk
(I wouldn't know, since I don't use BM), but surely doesn't BlitzMax support three-dimensional arrays? A quick search of the internet suggested it did. I'm sure that's what this is rather than an 'array of arrays'.

-=-=-
A mushroom a day keeps the doctor away...

Keep It Simple, Shroom!
Sun, 25 Sep 2011, 01:10
Jayenkai
I haven't trusted Multi-Dim arrays for a long long time.
I can't remember exactly what language it was that put me off them, but it messed my multi-dims up, caused a lot of "Why is THAT happening?!" bugs, I realised what it was, got all peed off (like I do!), and pretty much stopped using them for good.
Grr..
Evil!!!


Jay-style Multidims just need a good multiplier, but also require you to specify your sizes beforehand. If you're one of those coders who inexplicably find a need to keep ReDimming things, you're going to hate this!





You'll probably want to make a function for the inny bit!

but... You'll also want to watch out for too-many function jumpy things.
Also best to save the array's position into a variable where you're reusing it over and over again.

-=-=-
''Load, Next List!''
Sun, 25 Sep 2011, 13:01
Evil Roy Ferguso
BlitzMax supports two different kinds of multidimensional arrays out of the box:

"Rectangular" arrays:

or, if the size of each dimension isn't known until later:


The kind of array you were trying to do also exists, but "jagged" arrays are a bit more awkward in BlitzMax. As far as I am aware you have to manually new up the arrays inside each level of the array.



I'm not sure what the original code is doing, but it'd be nice if you could use the "rectangular" arrays instead.

Jay, Blitz3D had issues with 'real' multidimensional arrays in types, IIRC, but it was also crazy enough to have multiple types of array to begin with. You don't have to live like this anymore.
Sun, 25 Sep 2011, 13:22
Mog
Roy - What jay does with 'Blitzarrays' could be used in types - kind of a bastard hack way of multidims within a type.

Now on to blitzmax, i kind of figured out what was needed, although it's a little kludgy in my opinion - it's done with slicing.



note the [,][] - making an array of 2-dims, now..



-=-=-
I am Busy Mongoose - My Website

Dev PC: AMD 8150-FX, 16gb Ram, GeForce GTX 680 2gb

Current Project: Pyroxene
Sun, 25 Sep 2011, 14:17
dna
I wish you had posted you technique for dimensional arrays before Jay.
Your method makes more sense for the Blitz series compilers.

The old NewDos and NewDos80 type of compilers made up for this need by using some initial assigning before hand.

Good Job.

-=-=-
DNA