Warning: partial hijack (and on my first post as well...heh)
Cyberseth,
Nice job. Since you have wrapper functions for this "bank array", you could do multidimensions by storing bank addresses in upper dimensions (the first dimension in a 1x1 points to 2nd bank(N)).
Partially implemented re-work of your code...
I worked out a similar solution, only to easily accomodate bank arrays of different data types I point the bank cells at an address of a Type (using Handle on user defined types for string, array, int, float, bank) and the "type" of the type is specified at creation by the user and used in the supporting functions.
I imagine this uses much overhead and ultimately the thing to do would be more bank manipulation (ie., convert bank cell to string).
Ken,
Not only is quick access a great use of arrays, but if you read up on Blitz arrays (not the Dim style) you will see that it is possible to have local arrays as a field type (even of another type).
Type Object
Field name
Field description
End Type
Type Thing
Field name
Field inventory.Object[100]
End Type
The obvious advantage here is that you can have many "Thing"s that have their own inventory, so even if you have to parse the entire list, it is shorter than searching across (worse case) #_of_Things * #_of_inventories.
The main disadvantage of blitz arrays is that they cannot be resized at all and cannot be returned from a function (they can however be passed into one!), therefore my post is not really on topic.
Cheers!
-Roboslug
Cyberseth,
Nice job. Since you have wrapper functions for this "bank array", you could do multidimensions by storing bank addresses in upper dimensions (the first dimension in a 1x1 points to 2nd bank(N)).
Partially implemented re-work of your code...
myarray = NewArray(100,100) For i=0 To 50 For j=0 To 50 SetArray myarray, i, j, i+j ; easier to check than Rand, result will be dim1+dim2 Next Next Print GetArray(myarray,10,11) WaitKey() End ;-------------------------------------- Function NewArray(dim1,dim2) arrbank = CreateBank(dim1*4+4) For k=0 To dim1 PokeInt arrbank, k*4,CreateBank(dim2*4+4) Next Return arrbank End Function Function GetArray(arrbank, d1cell,d2cell) d2bank = PeekInt(arrbank, d1cell*4) Return PeekInt(d2bank,d2cell*4) End Function Function SetArray(arrbank,d1cell,d2cell,val) d2bank = PeekInt(arrbank, d1cell*4) PokeInt d2bank, d2cell*4, val End Function
I worked out a similar solution, only to easily accomodate bank arrays of different data types I point the bank cells at an address of a Type (using Handle on user defined types for string, array, int, float, bank) and the "type" of the type is specified at creation by the user and used in the supporting functions.
I imagine this uses much overhead and ultimately the thing to do would be more bank manipulation (ie., convert bank cell to string).
Ken,
Not only is quick access a great use of arrays, but if you read up on Blitz arrays (not the Dim style) you will see that it is possible to have local arrays as a field type (even of another type).
Type Object
Field name
Field description
End Type
Type Thing
Field name
Field inventory.Object[100]
End Type
The obvious advantage here is that you can have many "Thing"s that have their own inventory, so even if you have to parse the entire list, it is shorter than searching across (worse case) #_of_Things * #_of_inventories.
The main disadvantage of blitz arrays is that they cannot be resized at all and cannot be returned from a function (they can however be passed into one!), therefore my post is not really on topic.
Cheers!
-Roboslug