IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search Log in to check your private messages Log in
 

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: 1348
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: 7312
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

 

Search our Forum:

Similar Topics
Topic Forum Replies
No new posts Need to split single line into two li... DFSORT/ICETOOL 7
No new posts how to convert Hex String t char hex PL/I & Assembler 6
No new posts Get next 5 numeric from a string of '... COBOL Programming 4
No new posts Finding a string and concatinating mu... DFSORT/ICETOOL 11
No new posts String to ASCII conversion COBOL Programming 4

Back to Top