dhysk
March 22nd, 2009, 10:36 PM
as lame as it sounds I thought this would be simple and strait forward however no luck searching the help or google.
This is my first program ever other than the lame "hello world" that is everyone's 'first' program. Anyway, i can't find how to reverse my array order for instance.
change MyArray(-2,-1,0,1,) into MyArray(2,1,0,-1,)
the array size isn't known and although always in either ascending or descending order it isn't known which one.
I found in visual basic all you have to do is
Array.reverse(MyArray)
no luck in OOo basic though ;(. So I tried to do this
tmp = MyArray
for x = LBound(MyArray) to UBound(MyArray)
MyArray(x) = tmp(UBound(MyArray) - x)
next x
I only go threw it one time however what i get for an output is MyArray(1,0,0,1) and here is the odd part I also get tmp(1,0,0,1)
again originally MyArray(-2,-1,0,1) and without the for loop I verified both arrays are (-2,-1,0,1). however no matter what the array is it always repeats the 0,0 in the middle and then mirrors the other side. for example (-30,-29,....0,...,29,30) ill get (29,28,....0,0,....28,29)
This is my first program ever other than the lame "hello world" that is everyone's 'first' program. Anyway, i can't find how to reverse my array order for instance.
change MyArray(-2,-1,0,1,) into MyArray(2,1,0,-1,)
the array size isn't known and although always in either ascending or descending order it isn't known which one.
I found in visual basic all you have to do is
Array.reverse(MyArray)
no luck in OOo basic though ;(. So I tried to do this
tmp = MyArray
for x = LBound(MyArray) to UBound(MyArray)
MyArray(x) = tmp(UBound(MyArray) - x)
next x
I only go threw it one time however what i get for an output is MyArray(1,0,0,1) and here is the odd part I also get tmp(1,0,0,1)
again originally MyArray(-2,-1,0,1) and without the for loop I verified both arrays are (-2,-1,0,1). however no matter what the array is it always repeats the 0,0 in the middle and then mirrors the other side. for example (-30,-29,....0,...,29,30) ill get (29,28,....0,0,....28,29)