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
Aug 6, 2001
326
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top