View previous topic :: View next topic
|
Author |
Message |
sahaanup
New User
Joined: 16 Feb 2006 Posts: 9
|
|
|
|
Hi,
Can we reverse the string in cobol ? See the following problem :
77 NAME PIC X(10) VALUE 'MANOJ'.
77 SRNAME PIC X(10).
I want JONAM in SRNAME.
Regards, |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
There's a link at the top of the page to the manuals. Click on it, find the COBOL Language Reference manual, and look up the REVERSE function. This has also been the topic of a thread or two which you could find by using the SEARCH function. |
|
Back to top |
|
|
leo_sangha
New User
Joined: 11 Aug 2005 Posts: 85 Location: England
|
|
|
|
Is there any specific reason to use 77 Levels ?
i think you can do that by using below logic
start from the last byte ...
SET WS-SUB to 10.
Perform below logic until WS-SUB = 1
IF WS-SUB =spaces
Subtract 1 from WS-SUB giving WS-SUB
ELSE
MOVE Name(WS-SUB:1) TO SRNAME
Subtract 1 from WS-SUB giving WS-SUB
END-IF |
|
Back to top |
|
|
sahaanup
New User
Joined: 16 Feb 2006 Posts: 9
|
|
|
|
[quote="leo_sangha"]Is there any specific reason to use 77 Levels ?
No, there is no specific reason for using 77 level.
Thru coding we can reverse the string .. but i was actually looking for some COBOL verv that will do the same without putting any logic.
Thanks,
Anup |
|
Back to top |
|
|
leo_sangha
New User
Joined: 11 Aug 2005 Posts: 85 Location: England
|
|
|
|
You should have mentioned you are looking for a COBOL VERB.
did you try REVERSE as Robert advised.
I'm not sure but may INSPECT clause might help as well. Look for the syntax and usage. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
but i was actually looking for some COBOL verv that will do the same without putting any logic. |
Anup,
have you bothered to look up the REVERSE function that Robert Sample suggested? |
|
Back to top |
|
|
|