Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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: 1232
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: 7315

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 Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
No new posts Random Password (in string format) ge... ezhavendhan COBOL Programming 10 Mon Aug 29, 2016 3:18 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us