Hi,
Another question which I face goes like this:
I have a string of size 26. Basically it's the letters from alphabet. With value like "ABCDE....WXYZ". Now I want to display this variable in reverse direction like "ZYXW....EDCBA".
I replied that we can do it using OOCURS. In which I can start from 26 and subtract 1 until the counter reach to 1. But question became complex when he said what if you don't know the PIC clause value of the variable?
Another question with which I need he is, he told that there can be other ways to do it but I could not answer. What are the other ways?
Reverse the value in COBOL.
- Robert Sample
- Global Moderator
- Posts: 1895
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Reverse the value in COBOL.
There is the LENGTH function if you don't know the PIC clause value of the variable.
There is an intrinsic function REVERSE which could be used.
You could use reference modification instead of OCCURS to address the individual bytes.
There is an intrinsic function REVERSE which could be used.
You could use reference modification instead of OCCURS to address the individual bytes.
-
- New Member
- Posts: 5
- Joined: Tue Jul 29, 2014 12:29 pm
Re: Reverse the value in COBOL.
Thanks Robert.Robert Sample wrote:There is the LENGTH function if you don't know the PIC clause value of the variable.
There is an intrinsic function REVERSE which could be used.
You could use reference modification instead of OCCURS to address the individual bytes.
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute