IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Breaking a String


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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: 1353
Location: Israel

PostPosted: Wed Mar 26, 2014 2:31 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Mar 26, 2014 2:38 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts file manager is doing string conversion IBM Tools 3
No new posts Search string in job at regular Spool... CLIST & REXX 0
Search our Forums:

Back to Top