Quoting through arrays of different sizes
Hi i can imagine 3 arrays
ArrayA = {1,2,3}
ArrayB = {4,5,6,7}
ArrayC = {8,9,10,11,12}
I want to loop, but in a sequence like below
print ArrayA, B, C first value
print ArrayA, b, C second value
print ArrayA, B, C third value
print ArrayA, b, C fourth value
... ... ...
so that it outputs
1,4,8
2,5,9
3,6,10
at this point Array A needs to be wrapped so that the next result is
1,7,11
2,4,12
... ...
if the arrays where I could make the same size 10 elements,
x = 0 to 9
print ArrayA {x}
print ArrayB (x)
print ArrayC (x)
next x
but with arrays of different lengths I can put them in the same loop. Suppose I could put the count into an array that increments each time the loop runs, like
x = x + 1 if x> array max value then x = 0
but can this be done in a more efficient way?
I am looking at this in perl and I know the above code is not like perl, so the actual code is below, but I am currently playing in VBA.
stars is a singular array of size 199, and each element in that array is a dimensional array of 720 size and 3 widths. SO stars (single star) (point in orbit, x coordinate, y coordinate)
so star (1) contains an array that has roots x, y orbits of the star with a resolution of 0.5 degrees. but some of them must have different resolutions, so they will vary in size. but I still want them to be able to loop through them continuously and wrap each array as needed.
For h = 0 To 720
'Application.ScreenUpdating = False
For st = 0 To 199
Cells(st + 10, 2).Value = stars(st)(h, 1)
Cells(st + 10, 3).Value = stars(st)(h, 2)
Next
'calls chart to update
'Application.ScreenUpdating = True
DoEvents
Next
Greetings
source to share
If you want to wrap, you can just use 'mod' as in 'mod mod size'
[ADDENDUM - FreeBasic example]
const aSize=5
const bSize=3
dim a(0 to aSize-1) as integer
dim b(0 to bSize-1) as integer
a(0)=0
a(1)=1
a(2)=2
a(3)=3
a(4)=4
b(0)=0
b(1)=10
b(2)=20
for i=0 to 20
print "[";a(i mod aSize);" ";b(i mod bSize);"]"
next
sleep
source to share