Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reverse a string in XI 1

Status
Not open for further replies.

BlurredVision

Technical User
Joined
Aug 6, 2001
Messages
326
Location
GB
I need to reorder/reverse

Example = 123456 needs to be displayed as 563412

So, StrReverse wont' work.. Any ideas?

Thank you.
 
So are you trying to reverse it in chunks of 2? Will you always have an even number of chars?

~Brian
 
This logic will work if the length is always divisible by 2:
Code:
local stringvar input := "123456";
local stringvar output;
local numbervar x;

for x := length(input) to 1 step -2
do
(
    output := output & right(input,2);
    input := left(input,length(input)-2)
);
output

~Brian
 
Perfect.. Star for you..

Thanks for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top