Hello Sir,
I am new in as400 programming area, In an interview I was asked How to reverse a String in rpg.
I wrote the fixed lenght string program but don't know how to write it for Variable length string.
I an declaring an array in RPG as:
DStringR s 15A DIM(%len(%trim(String)) )
I am not getting any compile time error , but my program is not running.
PLease guide!
Software/Hardware used:
V5R3 Mochasoft,
ASKED:
October 20, 2011 6:39 PM
UPDATED:
March 17, 2012 7:21 AM
What is the rest of the code?
And when you say “no running”, is it creashing or just not doing anything?
I an declaring an array in RPG as:
DStringR s 15A DIM(%len(%trim(String)) )
I am not getting any compile time error…
Since %TRIM() isn’t valid in that location, it’s not clear why you wouldn’t get a compile error. Are you absolutely certain?
Tom
I assume the interview is over, but here is one possiblity:
H debug D string s 15a varying inz( 'abcdef' ) D rev s like( string ) D pos s 10i 0 /free %len( rev ) = 0; for pos = %len( string ) downto 1 ; rev = rev + %subst( string : pos : 1 ) ; endfor; string = rev ; *inLR = *on ; dump ; return ; /end-freeOther possibilities exist.
Tom