Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Breaking a String

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

New User


Joined: 22 Sep 2013
Posts: 81
Location: pune india

PostPosted: Wed Mar 26, 2014 11:08 am    Post subject: Breaking a String
Reply with quote

I want to break a string into differnt occurence of array

Like if ws-string is "THIS IS STRING EXAMPLE"

Here there are four words and hence they will reside in four occurence of array.

BUt problem is this ws-string can be anything at run time,may be 10 words at some another time but the limit is 25.

I declared array using depending on clause but my problem is how to recieve values in array using unstring clause.

Any suggestions.
Back to top
View user's profile Send private message

GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Mar 26, 2014 1:02 pm    Post subject:
Reply with quote

Do NOT declare array "Depending on"
Code:
MOVE 1 TO W-POS
PERFORM VARYING IX FROM 1 BY 1
  UNTIL INDX > 25
     OR WS-STRING(W-POS:) = SPACES
        UNSTRING WS-STRING DELIMITED BY ' '
            INTO TAB-WORD(IX)
            WITH POINTER W-POS
END-PERFORM.
SUBTRACT 1 FROM IX GIVING NUM-WORDS
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1252
Location: Israel

PostPosted: Wed Mar 26, 2014 2:31 pm    Post subject:
Reply with quote

Hi Guy,
I tried your code and I have one small correction:
Code:
MOVE 1 TO W-POS
PERFORM VARYING IX FROM 1 BY 1
  UNTIL IX > 25
     OR WS-STRING(W-POS:) = SPACES
        UNSTRING WS-STRING DELIMITED BY ALL ' '
            INTO TAB-WORD(IX)
            WITH POINTER W-POS
END-PERFORM.
SUBTRACT 1 FROM IX GIVING NUM-WORDS
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Wed Mar 26, 2014 2:38 pm    Post subject: Reply to: Breaking a String
Reply with quote

trushant.w,

UNSTRING is a verb, not a clause.

UNSTRING requires that all fields that are targets are specified (can be done with subscripting).

As GuyC alludes, OCCURS ... DEPENDING ON is not giving you anything on that table.

Without the specifics of the data, I'm not going to comment further for now.
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 line 52: Name or string > 250 char... Ashishpanpaliya CLIST & REXX 5 Sat Oct 14, 2017 2:29 am
No new posts Search for a string in many PDS KARTHIGADEVI CLIST & REXX 5 Fri Sep 08, 2017 2:32 pm
No new posts How to change a string containing the... chong.zhou TSO/ISPF 6 Tue Aug 29, 2017 4:54 pm
No new posts String after '.' (period) is not copy... balaji81_k SYNCSORT 6 Wed Aug 23, 2017 9:35 pm
No new posts change string before sertan string anatol DFSORT/ICETOOL 8 Tue Aug 15, 2017 5:43 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us