View previous topic :: View next topic
|
Author |
Message |
cynderilla
New User
Joined: 07 Dec 2006 Posts: 5 Location: chennai
|
|
|
|
Hi all,
Can anybody plz tell me how to reverse a string using string function in cobol
if u explain me with code it will be better.
thanx in advance, |
|
Back to top |
|
|
neelesht
New User
Joined: 24 Jul 2006 Posts: 99 Location: Los Angeles
|
|
|
|
Hi Cynderilla,
there is a reverse function in COBOL to reverse a string
FUNCTION REVERSE(STRING)
Please correct me if I am wrong.
Neelesh |
|
Back to top |
|
|
krisprems
Active Member
Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Hi
Code: |
MOVE FUNCTION REVERSE('your string') TO RES. |
The variable RES will have your reversed string.
Thanks
Arun
[/code] |
|
Back to top |
|
|
cynderilla
New User
Joined: 07 Dec 2006 Posts: 5 Location: chennai
|
|
|
|
Hi All,
thank's for u r responses
but wat i really need is reverse of a string for example
"abcdef" to "fedcba".
using String Verb in cobol i want to reverse it ,only STRING verb
n nothing other than that.
if it is possible plzz help me. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Going a byte at a time and starting from the tail end using reference modification.
If its length is known and small, hardcode a single string statement with all of the one byte string elements.
If its length is unknown or long, use a perform loop with a single string statement and a single string element and keep track with the string pointer. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
To do what i believe you want, please try the following:
01 REVERSE-WORK.
05 RW-IN PIC XXXX.
05 RW-OUT PIC XXXX.
MOVE 'QWER' TO RW-IN.
DISPLAY RW-IN.
STRING RW-IN(4:1),
RW-IN(3:1),
RW-IN(2:1),
RW-IN(1:1) DELIMITED BY '\'
INTO RW-OUT.
DISPLAY RW-OUT.
The "input" and "output" displays.
QWER
REWQ
If your field(s) are very long or variable in length. . . . .
Is there some business reason to NOT use the reverse function? |
|
Back to top |
|
|
|