Reversing data arrays

LiquidPenguin
09-05-2003, 10:29 PM
To boil it all down. Let's say I have an array that is filled with data. Let's just say for simplicity sake it's a byte array filled with an incrementing number.

A(0) = 0
A(1) = 1
A(2) = 2
.
.
.

Now let's say I want to reverse the data in this array and place it into a new array.

B(0) = 2
B(1) = 1
B(2) = 0
.
.
.

So other than doing this:


for i = lbound(a) to ubound(a) step 1
b(ubound(b) - i) = a(i)
next i


Is there a nice fast, one shot way... say an API call, that I can use to speed up this process?

Thinker
09-05-2003, 11:08 PM
Nope. If you were going in the same direction you could.

passel
09-05-2003, 11:10 PM
I don't believe there any intrinsic function that will reverse a byte array
for you, but assuming the arrays are the same size, or that array b is
larger than a, I would code it like this.

dim i as long, p as long
p = lbound(b)
for i = ubound(a) to lbound(a) step - 1
b(p) = a(i)
p = p+1
next

LiquidPenguin
09-06-2003, 12:24 AM
:(

That's what I figured. I guess I'll build a small sub routine to simplify the call a bit.

It's just a stop gap solution anyways until I can rewrite the rest of the code to better accomodate the inverse arrays.

LiquidPenguin
09-06-2003, 12:27 AM
Oh... Should I have mentioned that I'm not actually treating this as an array? eerr... whatever....

To be precise, the array holds the image block to what amounts to a bitmap. Should I have mentioned that?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum