HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

*faking* double subscripted arrays

01-23-2003, 06:42 AM#1
MicrosoftXP
as long as your array does not need to be dynamic (ie. expand in size on the fly) you can fake a double subscripted array.

heres the method:
index one ranges from 1 to A
index two ranges from 1 to B

here is the formula you use the index your array:

array_variable[((Index One - 1) x B) + (Index Two)]

this will set up your array as follows: (assume A = 4, B = 6)
actual index: [1]    [2]   [3]    [4]   [5]   [6]    [7]    [8]    [9]  [10]  [11]  [12] ... [24]
fake index: [1,1] [1,2] [1,3] [1,4] [1,5] [1,6] [2,1] [2,2] [2,3] [2,4] [2,5] [2,6] ... [4,6]
01-23-2003, 10:10 AM#2
SuperIKI
*yawn*:ohh:
That's really old stuff.