View previous topic :: View next topic
|
Author |
Message |
trushant.w
New User
Joined: 22 Sep 2013 Posts: 81 Location: pune india
|
|
|
|
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 |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|