Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

reverse of string using string function only

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
cynderilla

New User


Joined: 07 Dec 2006
Posts: 5
Location: chennai

PostPosted: Mon Dec 11, 2006 12:36 pm    Post subject: reverse of string using string function only
Reply with quote

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
View user's profile Send private message

neelesht

New User


Joined: 24 Jul 2006
Posts: 99
Location: Los Angeles

PostPosted: Mon Dec 11, 2006 12:41 pm    Post subject:
Reply with quote

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
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Mon Dec 11, 2006 1:26 pm    Post subject:
Reply with quote

Hi Cynderilla,
topic is discussed, u can get more information from below link

http://www.ibmmainframes.com/viewtopic.php?t=15857&highlight=reverse
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2238
Location: @my desk

PostPosted: Mon Dec 11, 2006 1:38 pm    Post subject:
Reply with quote

Hi

Code:
MOVE FUNCTION REVERSE('your string') TO RES.


The variable RES will have your reversed string.

Thanks
Arun

[/code]
Back to top
View user's profile Send private message
cynderilla

New User


Joined: 07 Dec 2006
Posts: 5
Location: chennai

PostPosted: Mon Dec 11, 2006 5:22 pm    Post subject: Re: reverse of string using string function only
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Mon Dec 11, 2006 6:00 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Dec 11, 2006 9:14 pm    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us