Page 1 of 1

strings in cobol

PostPosted: Wed Oct 20, 2010 11:37 am
by gangareddy
could u plz anyone tell how can we display a string in reverse order?

Re: strings in cobol

PostPosted: Wed Oct 20, 2010 12:36 pm
by GuyC
FUNCTION REVERSE ()

Re: strings in cobol

PostPosted: Wed Oct 20, 2010 2:48 pm
by Robert Sample
First, terminology is critical in IT, where similar terms may mean very different things. COBOL does not have "strings" -- COBOL has variables. These variables can be alphabetic, alphanumeric, numeric, packed decimal, floating point, binary, pointers, and grouped -- but they are not strings as most languages define strings.

Second, you can use FUNCTION REVERSE as mentioned already, or you can use reference modification, or you can redefine the variable as an array of one-byte alphanumeric variables -- in the latter two cases, iterate from the end of the variable to the beginning.

Re: strings in cobol

PostPosted: Fri Oct 22, 2010 2:27 pm
by bhumireddy564
we don't have any pre defined functions like string reverse() by using reference modification we can do it[

Re: strings in cobol

PostPosted: Fri Oct 22, 2010 2:29 pm
by bhumireddy564
gangareddy wrote:could u plz anyone tell how can we display a string in reverse order?

By using String concatenate , we have reference modification(stringstart index:length) by using this we print the string reverse

Re: strings in cobol

PostPosted: Fri Oct 22, 2010 2:50 pm
by Robert Sample
Which version of COBOL are you running?