Two dimensional array?
I would like to display on my monitor 5 rows of 7 numbers each.
Please see my desired example, but cannot load the 2-D array.
EdKirk·· edk@wi.rr.com
Please see my desired example, but cannot load the 2-D array.
EdKirk·· edk@wi.rr.com
Comments
long Number[noparse][[/noparse]5*7] 'create a single dimesional array that stores the equivalent of a two-dimensional array
Repeat Rows From 1 to 5
__Repeat Cols From 1 to 7 'I noticed in your code sample that you have 'Rows' in this line, not 'Cols'
____VideoDisplay.dec(Number[noparse][[/noparse](Rows*5)+Cols]) 'here is where we mimic the 2 dimensional array, basically doing what a compiler does in languages that support multidemsional arrays
____VideoDisplay.out(32)
.....
Hope this helps.
Kerry
Post Edited (kerryw) : 6/5/2006 4:01:48 AM GMT
Very clever! I will do a 'long' to store two 16-bit numbers.
Why not four 8-bit numbers? How do it know? Things usually fall down; how do it know? I will never understand gravity.
Ed Kirkham
edkirk edk@wi.rr.com
Kerry,
Never mind my stupid question.· I thot at first that you were splitting the 32-bit numbers in half; but no you just made the list longer instead.·
Since I do not need 32-bit resolution for my numbers I guess I could have used 'word' instead of 'long'.
Ed
Post Edited (EdKirk) : 6/5/2006 12:32:52 PM GMT
Not a stupid question, you could actually split the 32-bit numbers in half to store your numbers.... likewise for splitting it in 4ths. Sort of like BCD format.
Long NumberArray[noparse][[/noparse]10]
...could represent 20 16-bit numbers or 40 8-bit numbers, but since you can specify a descriptor of long, word, or byte, the conversion
is partially done for you.
In terms of occupying memory...
long NumberArray[noparse][[/noparse]10] = word NumberArray[noparse][[/noparse]20] = byte NumberArray[noparse][[/noparse]40]
The remainder of the conversion is to do what kerryw suggests. You could expand this further to a 3-dimentional array or whatever met your needs...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 6/5/2006 3:07:30 PM GMT