Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
meen

New User

Joined: 23 Jun 2008
Posts: 15
Location: bangalore

 Posted: Fri Aug 14, 2009 12:04 pm    Post subject: Counting characters in a string and splitting the string My requirement is to Count the number of characters in a string. After counting I need to divide this string into small strings. Suppose after counting I got the number of characters as 95.. Now I need to divide this into strings of 10 characters each. Pls suggest how to do this? Thanks in Advance

Active User

Joined: 29 Jun 2009
Posts: 197
Location: Mumbai

 Posted: Fri Aug 14, 2009 12:25 pm    Post subject: Hi, Use a perform vaying to move the 10 10 byte of the string and keep a diff counter for the lenght of the string you can achive the desired result Hope this help Ketan
Pankaj Shrivastava
Currently Banned

New User

Joined: 24 Jul 2009
Posts: 51
Location: Pune

 Posted: Fri Aug 14, 2009 12:48 pm    Post subject: Calculate the lenght of string first : PERFORM VARYING var FROM length_of_string BY -1 UNTIL var < 1 OR string(var:1) NOT = SPACE CONTINUE END-PERFORM DIVIDE length_of_string BY 10 GIVING length_of_string REMAINDER WS-rem If ws-rem not equal to zero compute length_of_string = length_of_string +1 end-if Define the splited vars with OCUURS clause in working storage as : 01 string pic x(99). 01 var-split redefines var pic x(99). 05 ws-split occurs 0 to 10 times depending on length_of_string . 10 ws-split-var pic x(10).
Robert Sample

Global Moderator

Joined: 06 Jun 2008
Posts: 8231
Location: Dubuque, Iowa, USA

Posted: Fri Aug 14, 2009 5:04 pm    Post subject:

 Quote: My requirement is to Count the number of characters in a string. After counting I need to divide this string into small strings. Suppose after counting I got the number of characters as 95.. Now I need to divide this into strings of 10 characters each. Pls suggest how to do this?
Your requirements are not clear enough to me to make suggestions. How long is the variable you're calling "a string" (not a standard COBOL term for a variable, by the way)? If the length is 1000 bytes and you're got 95 bytes scattered every 10 bytes or so, do you still want 10 outputs or 100 outputs? Do spaces count as characters in your requirement? Since COBOL does not allow variables to be undefined, pretty much by definition your variable will be fully populated with something -- SPACES, LOW-VALUES, junk data, or actual data.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics how to display APL characters? Pedro TSO/ISPF 6 Wed Mar 14, 2018 5:07 am Find a string in PS file opened in br... mukkas CLIST & REXX 3 Sat Feb 24, 2018 2:15 pm line 52: Name or string > 250 char... Ashishpanpaliya CLIST & REXX 5 Sat Oct 14, 2017 2:29 am Binary to display characters Roy Ware SYNCSORT 3 Tue Sep 19, 2017 8:46 pm Search for a string in many PDS KARTHIGADEVI CLIST & REXX 5 Fri Sep 08, 2017 2:32 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us