I can't reccomened octothorpes container classes enough!
Alternatively you could use a array in bank system like mine below, which Octothorpe also helped me with (you're the man!).
;Multi-dimensional array object using banks.
Type array
Field BankHND% ;Memory bank handle.
Field Dim1% ;Size of first array element.
Field Dim2% ;Size of second array element.
Field Dim3% ;Size of third array element.
Field Dim4% ;Size of fourth array element.
Field Dim5% ;Size of fifth array element.
End Type
Function array_Create.array( nDim1%, nDim2%=1, nDim3%=1, nDim4%=1, nDim5%=1 )
Local Err$ = "Invalid dimension size specified in array_Create()"
Assert( nDim1%>0, Err$ ):Assert( nDim2%>0, Err$ ):Assert( nDim3%>0, Err$ )
Assert( nDim4%>0, Err$ ):Assert( nDim5%>0, Err$ )
Local nArray.array = New array
nArray\Dim1% = nDim1
nArray\Dim2% = nDim2
nArray\Dim3% = nDim3
nArray\Dim4% = nDim4
nArray\Dim5% = nDim5
nArray\BankHND% = CreateBank( ( nDim1 *nDim2 *nDim3 *nDim4 *nDim5 ) *4 )
Return nArray
End Function
Function array_Destroy%( this.array )
Assert( Not this=Null, "Null 'array' object in array_Destroy()" )
FreeBank( this\BankHND% )
Delete this
End Function
Function array_Copy.array( this.array )
Assert( Not this=Null, "Null 'array' object in array_Copy()" )
Local nArray.array = New array
Local Size% = BankSize( this\BankHND% )
nArray\Dim1% = this\Dim1%
nArray\Dim2% = this\Dim2%
nArray\Dim3% = this\Dim3%
nArray\Dim4% = this\Dim4%
nArray\Dim5% = this\Dim5%
nArray\BankHND% = CreateBank( Size% )
CopyBank( this\BankHND%, 0, nArray\BankHND%, 0, Size% )
Return nArray
End Function
Function array_WriteVal%( this.array, nValue%, nDim1%, nDim2%=0, nDim3%=0, nDim4%=0, nDim5%=0 )
Assert( Not this=Null, "Null 'array' object in array_WriteVal()" )
Local nOffset% = array_GetOffset( this, nDim1%, nDim2%, nDim3%, nDim4%, nDim5% )
PokeInt( this\BankHND%, nOffset% *4, nValue% )
End Function
Function array_ReadVal%( this.array, nDim1%, nDim2%=0, nDim3%=0, nDim4%=0, nDim5%=0 )
Assert( Not this=Null, "Null 'array' object in array_ReadVal()" )
Local nOffset% = array_GetOffset( this, nDim1%, nDim2%, nDim3%, nDim4%, nDim5% )
Return PeekInt( this\BankHND%, nOffset% *4 )
End Function
;Implementation function only.
Function array_GetOffset%( this.array, nDim1%, nDim2%, nDim3%, nDim4%, nDim5% )
Assert( Not this=Null, "Null 'array' object in array_GetOffset()" )
Local Error = False
If nDim1% >= this\Dim1% Then Error = True
If nDim2% >= this\Dim2% Then Error = True
If nDim3% >= this\Dim3% Then Error = True
If nDim4% >= this\Dim4% Then Error = True
If nDim5% >= this\Dim5% Then Error = True
Assert( Error=False, "Array index out of bounds!" )
Local nOffset% = nDim1%
nOffset% = nOffset% +nDim2% *this\Dim1%
nOffset% = nOffset% +nDim3% *this\Dim2%
nOffset% = nOffset% +nDim4% *this\Dim3%
nOffset% = nOffset% +nDim5% *this\Dim4%
Return nOffset%
End Function
You'll also need this:
Function Assert( Condition%, Message$ )
If not Condition% then RunTimeError( Message$ )
End Function