Post by hap2u on Apr 10, 2020 9:29:07 GMT -5
I did a search of the board for this an received no results so perhaps my solution may be of some use.
Both solutions are a pain! Creating a separate function to go along with each multi dimension variable is the larger headache especially when a REDIM is needed. So creating a DIM of the sub dimensions is probably the best way to do this. To REDIM a multi array one can create a Function which would handle multiple Re-dimensions. Say [ Redim.MyArray(D1,D2,D3) ]
My formula is different from the one in the help manual; [ (Max*D2)+D3+1 ] as this creates a value in order from 1 to Max it should work better with routines such as a bubble sort.
Trd() holds third dimension variables
MyArray() is any Array of three dimensions
Max1, Max2, Max3 are the limits of the three dimensions
Max is the Largest of the Trd() dimensions
Note: You will need a REDIM function for every 'three dimensional array' you create with different DIM parameters. Third.Size is a two dimensional check on the size of your third dimension. A Bubble Sort Subroutine should work as the Trd() value is ordered by number.
Liberty Basic Code:
Global Trd, MyArray
Max1=3: Max2=1: Max3=0: if Max2>Max3 then Max=Max2 else Max=Max3
dim Trd(Max2,Max3)
dim MyArray(Max1,Max*Max1+Max2+1)'by formula
Third.Size=Redim.MyArray(Max1,Max2,Max3)
Print Third.Size
print Trd(Max2,Max3)
MyArray(Max1,Trd(Max2,Max3))=1000
print MyArray(Max1,Trd(Max2,Max3))
end
'_________________________________________
Function Redim.MyArray(Max1,Max2,Max3)
if Max2>Max3 then Max=Max2 else Max=Max3
redim Trd(Max2,Max3)
redim MyArray(Max1,Max*Max1+Max2+1)
print Max*Max1+Max2+1
print "--------------------"
'load Third Array with in series number
For D2=0 to Max2
for D3=0 to Max3
Trd(D2,D3)=(Max*D2)+D3+1 'serial number formula
print D2;",";D3, Trd(D2,D3)
next D3
next D2
Redim.MyArray=Trd(Max2,Max3)
end function
Both solutions are a pain! Creating a separate function to go along with each multi dimension variable is the larger headache especially when a REDIM is needed. So creating a DIM of the sub dimensions is probably the best way to do this. To REDIM a multi array one can create a Function which would handle multiple Re-dimensions. Say [ Redim.MyArray(D1,D2,D3) ]
My formula is different from the one in the help manual; [ (Max*D2)+D3+1 ] as this creates a value in order from 1 to Max it should work better with routines such as a bubble sort.
Trd() holds third dimension variables
MyArray() is any Array of three dimensions
Max1, Max2, Max3 are the limits of the three dimensions
Max is the Largest of the Trd() dimensions
Note: You will need a REDIM function for every 'three dimensional array' you create with different DIM parameters. Third.Size is a two dimensional check on the size of your third dimension. A Bubble Sort Subroutine should work as the Trd() value is ordered by number.
Liberty Basic Code:
Global Trd, MyArray
Max1=3: Max2=1: Max3=0: if Max2>Max3 then Max=Max2 else Max=Max3
dim Trd(Max2,Max3)
dim MyArray(Max1,Max*Max1+Max2+1)'by formula
Third.Size=Redim.MyArray(Max1,Max2,Max3)
Print Third.Size
print Trd(Max2,Max3)
MyArray(Max1,Trd(Max2,Max3))=1000
print MyArray(Max1,Trd(Max2,Max3))
end
'_________________________________________
Function Redim.MyArray(Max1,Max2,Max3)
if Max2>Max3 then Max=Max2 else Max=Max3
redim Trd(Max2,Max3)
redim MyArray(Max1,Max*Max1+Max2+1)
print Max*Max1+Max2+1
print "--------------------"
'load Third Array with in series number
For D2=0 to Max2
for D3=0 to Max3
Trd(D2,D3)=(Max*D2)+D3+1 'serial number formula
print D2;",";D3, Trd(D2,D3)
next D3
next D2
Redim.MyArray=Trd(Max2,Max3)
end function