strings in cobol



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

strings in cobol

Postby gangareddy » Wed Oct 20, 2010 11:37 am

could u plz anyone tell how can we display a string in reverse order?
gangareddy
 
Posts: 1
Joined: Wed Oct 20, 2010 11:29 am
Has thanked: 0 time
Been thanked: 0 time

Re: strings in cobol

Postby GuyC » Wed Oct 20, 2010 12:36 pm

FUNCTION REVERSE ()
GuyC
 
Posts: 315
Joined: Tue Aug 11, 2009 3:23 pm
Has thanked: 1 time
Been thanked: 4 times

Re: strings in cobol

Postby Robert Sample » Wed Oct 20, 2010 2:48 pm

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.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: strings in cobol

Postby bhumireddy564 » Fri Oct 22, 2010 2:27 pm

we don't have any pre defined functions like string reverse() by using reference modification we can do it[
bhumireddy564
 
Posts: 3
Joined: Fri Oct 22, 2010 2:07 pm
Has thanked: 0 time
Been thanked: 0 time

Re: strings in cobol

Postby bhumireddy564 » Fri Oct 22, 2010 2:29 pm

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
bhumireddy564
 
Posts: 3
Joined: Fri Oct 22, 2010 2:07 pm
Has thanked: 0 time
Been thanked: 0 time

Re: strings in cobol

Postby Robert Sample » Fri Oct 22, 2010 2:50 pm

Which version of COBOL are you running?
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post