Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

REXX Parse question

8 views
Skip to first unread message

Ed Benoit

unread,
Oct 30, 2009, 3:30:44 PM10/30/09
to
Hello All,
I am attempting to parse a line in REXX. Some times line has three words
in the line and some times four words. Is there a keyword I can use to
determine how many words in a line before I parse the line.
What REXX manual should I review?

Ed.

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to LIST...@VM.MARIST.EDU with the message: INFO TSO-REXX

Stocker, Herman

unread,
Oct 30, 2009, 3:36:06 PM10/30/09
to
Ed,
Take a look at the Words() function

Regards,
Herman Stocker

Ed.

- --


The sender believes that this E-mail and any attachments were free of any
virus, worm, Trojan horse, and/or malicious code when sent. This message and
its attachments could have been infected during transmission. By reading the
message and opening any attachments, the recipient accepts full
responsibility for taking protective and remedial action about viruses and
other defects. The sender's employer is not liable for any loss or damage
arising in any way from this message or its attachments.

Farley, Peter x23353

unread,
Oct 30, 2009, 3:37:27 PM10/30/09
to
> -----Original Message-----
> From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On
Behalf
> Of Ed Benoit
> Sent: Friday, October 30, 2009 3:30 PM
> To: TSO-...@VM.MARIST.EDU
> Subject: REXX Parse question
>
> Hello All,
> I am attempting to parse a line in REXX. Some times line has three
words
> in the line and some times four words. Is there a keyword I can use
to
> determine how many words in a line before I parse the line.
> What REXX manual should I review?

Assuming these are words separated by spaces, you can use:

NUMWORDS = WORDS(line)

The TSO/E Rexx Language Reference is the one you want, on the TSO/E
shelf in the z/OS library.

HTH

Peter


This message and any attachments are intended only for the use of the addressee and
may contain information that is privileged and confidential. If the reader of the
message is not the intended recipient or an authorized representative of the
intended recipient, you are hereby notified that any dissemination of this
communication is strictly prohibited. If you have received this communication in
error, please notify us immediately by e-mail and delete the message and any
attachments from your system.

Vitonis, Tony

unread,
Oct 30, 2009, 3:38:24 PM10/30/09
to
There is WORDS(Line). But you can also do this:

PARSE VAR Line One Two Three TheRest

IF TheRest = "" THEN
<there were no more than three words in the line>
ELSE
<there were more than three words in the line>

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On Behalf
Of Ed Benoit
Sent: Friday, October 30, 2009 3:30 PM
To: TSO-...@VM.MARIST.EDU
Subject: REXX Parse question

Walter Pachl

unread,
Oct 30, 2009, 3:38:42 PM10/30/09
to
n=words(line) -- but why would you do this?
Read the Reference Manual
Suggested code (untested)
Parse Var line a b c d
d will be empty if line has only three words
etc etc

----- Original Message -----
From: "Ed Benoit" <Ibm...@AOL.COM>
To: <TSO-...@VM.MARIST.EDU>
Sent: Friday, October 30, 2009 8:30 PM
Subject: [TSO-REXX] REXX Parse question

Rick Woods

unread,
Nov 2, 2009, 9:02:00 AM11/2/09
to
Because if the line has 4 words, you want the fourth one. Otherwise, you want the third one.
Do it all in one statement:

FINAL_VALUE = WORD(LINE,3+(WORDS(LINE)=4))
- Rick


>>> Walter Pachl <pa...@CHELLO.AT> 10/30/2009 12:36 PM >>>

Martin Cox

unread,
Nov 2, 2009, 11:51:24 AM11/2/09
to
Or, if that really is what is required, to put it more simply:
FINAL_VALUE = WORD(WORDS(LINE))

Martin

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On Behalf Of

Rick Woods

unread,
Nov 3, 2009, 4:46:54 PM11/3/09
to
Heh!
Or if you want the 4th word if there are 4 or more words, otherwise the 3rd word:
FINAL_VALUE = WORD(LINE,3+(WORDS(LINE)>3))

I used to know two guys who bet cups of coffee on who could get the most work done with a single statement (not in REXX, but similar). It was fun to watch these guys at the blackboard. (Then they'd bet on the poker hands on the paper cups).
- Rick


>>> Martin Cox <Marti...@AOL.COM> 11/2/2009 9:50 AM >>>


Or, if that really is what is required, to put it more simply:
FINAL_VALUE = WORD(WORDS(LINE))

Martin

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On Behalf Of
Rick Woods
Sent: 02 November 2009 14:01
To: TSO-...@VM.MARIST.EDU
Subject: Re: [TSO-REXX] REXX Parse question

Because if the line has 4 words, you want the fourth one. Otherwise, you
want the third one.
Do it all in one statement:

David S Speake

unread,
Nov 3, 2009, 5:08:13 PM11/3/09
to
Guys,

I love both of these.
I neither know nor care whether they are better or not.
They are REXXish, Ricks a bit fiendishly so.
When can I enroll in your next REXX class
Thank you.

F_V = REVERSE(WORD(REVERSE(LINE),1))
Is my one liner.

Martin, I think
FINAL_VALUE = WORD(WORDS(LINE))
seems to have a small problem. Is
FINAL_VALUE = WORD(LINE, WORDS(LINE))
what you had in mind

Still we may have all gone off on a tangent.
Did he say that he was after only the last word?

David.Speake
David....@bcbssc.com
(803)-264-8003
(803)-288-2227 X48003
(800)-288-2227 X48003

Rick Woods

unread,
Nov 4, 2009, 7:19:18 AM11/4/09
to
No, the OP only wanted to know how many words were in the line.
We just got carried away having fun with it!

After all, REXX = King!
- Rick

>>> David S Speake <David....@BCBSSC.COM> 11/3/2009 3:07 PM >>>

0 new messages