PropBasic - Arrays
camelot2
Posts: 54
hi, I have 2 HUB arrays (HUB1 and HUB2) each with 100 values.
What I want to do is take the first value from HUB1 array and
store it in HUB3 array at address 1 then take the first value
from HUB2 array and store it in HUB3 array at address 2. Then
take the second value from HUB1 array and store it in HUB3 array
at address 3, then take the second value from HUB2 array and
store it in HUB3 array at address 4 and so on.
So the values in HUB1 go into the odd addresses of HUB3 array and
the values in HUB2 go into the even addresses of HUB3 array. I am
lost as to how to do this in PropBasic. Can someone help me, thanks
What I want to do is take the first value from HUB1 array and
store it in HUB3 array at address 1 then take the first value
from HUB2 array and store it in HUB3 array at address 2. Then
take the second value from HUB1 array and store it in HUB3 array
at address 3, then take the second value from HUB2 array and
store it in HUB3 array at address 4 and so on.
So the values in HUB1 go into the odd addresses of HUB3 array and
the values in HUB2 go into the even addresses of HUB3 array. I am
lost as to how to do this in PropBasic. Can someone help me, thanks
Comments
Simply have 2 index variables, one for HUB1 and HUB2 and one for HUB3.
HUB3[ idx2 ] := HUB1[ idx1 ]
idx2 := idx2 + 1
HUB3[ idx2 ] := HUB2[ idx1 ]
idx2 := idx2 + 1
idx1 := idx1 + 1
Put this piece of code inside of a loop and don't forget to initialize the idx-variables - then you're done.
Of course you can optimize this a bit by only using idx1. But I'll leave it as a challenge first ;o)
Could someone please put this in PropBasic code?? - thanks again for any help
Bean
thanks very much. Also thanks for PropBasic its great.
Happy Holidays - Dave