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

Verifying strings

41 views
Skip to first unread message

Bill Ashton

unread,
Mar 23, 2012, 5:34:12 PM3/23/12
to
Hello guys and gals!
I would like to test a variable for multiple string possibilities, and am
looking for the easiest way to do this.

For example, I can have a filename node that says .TXT or .TEXT, another
that may say .TRS, .TERSE or .TERSED, another that might say .BIN or
.BINARY, another that might say .SVC, .SVCDUMP, DUMPSVC or just .DUMP. I
have several more possibilities to test, and am looking for the easiest way
to do this.

I had thought about:
Select
...When Verify(node,"TEXT") > 0 then
...When Verify(node,"TERSED") > 0 then
&c.
But that won't always work. For example, if the node being tested was
"REST", it would get picked up in the TERSED Verify.

I am guessing that I will need to code this:
Select
...When (node = "TXT") | (node = "TEXT") Then
...When (node = "TRS") | (node = "TERSE") | (node = "TERSED") Then
&c

Does anyone have any other ideas for setting up this test of my several
different node naming schemes?

Thanks!

Thank you and best regards,
*Billy Ashton*

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

Bill Schoen

unread,
Mar 23, 2012, 5:45:04 PM3/23/12
to
Use wordpos()

Bill Schoen

Paul Gilmartin

unread,
Mar 23, 2012, 5:51:40 PM3/23/12
to
On 2012-03-23 15:33, Bill Ashton wrote:
> For example, I can have a filename node that says .TXT or .TEXT, another
> that may say .TRS, .TERSE or .TERSED, another that might say .BIN or
> .BINARY, another that might say .SVC, .SVCDUMP, DUMPSVC or just .DUMP. I
> have several more possibilities to test, and am looking for the easiest way
> to do this.
>
>
Stem variable:

unset Valid.
Valid.TRS = 'TERSE'
Valid.TERSE = 'TERSE'
Valid.TERSED = 'TERSE'

if symbol( 'Valid.node' )<>'VAR' then say 'invalid suffix:' node

(This also allows lookup of the node type as a bonus.)
(Beware inadvertent use of tail names as variables!)

wordpos:

if wordpos( node, 'TRS TERSE TERSED' )==0 then say 'invalid suffix:' node

-- gil

Rob Zenuk

unread,
Mar 23, 2012, 5:54:49 PM3/23/12
to
Yup!

/* rexx */
arg file
suffix = substr(file,(lastpos('.',file)+1))
goodstuff = 'TXT TEXT TRS TERSE TERSED BIN BINARY SVC DUMPVC DUMP'
if wordpos(suffix,goodstuff) = 0 then
exit 99
else
exit 0

Walter Pachl

unread,
Mar 24, 2012, 3:44:47 AM3/24/12
to
"Beware" by doing this
type.='unknown'
z='TRS', type.z='TERSE' /* etc. */
Walter

Arthur T.

unread,
Mar 24, 2012, 3:46:20 AM3/24/12
to
On 23 Mar 2012 14:51:40 -0700, in bit.listserv.tsorexx
(Message-ID:<4F6CF018...@AIM.com>)
PaulGB...@AIM.COM (Paul Gilmartin) wrote:


>On 2012-03-23 15:33, Bill Ashton wrote:
>>For example, I can have a filename node that says .TXT or
>>.TEXT, another
>>that may say .TRS, .TERSE or .TERSED, another that might
>>say .BIN or
>>.BINARY, another that might say .SVC, .SVCDUMP, DUMPSVC
>>or just .DUMP. I
>>have several more possibilities to test, and am looking
>>for the easiest way
>>to do this.
>>
>Stem variable:
>
>unset Valid.
>Valid.TRS = 'TERSE'
>Valid.TERSE = 'TERSE'
>Valid.TERSED = 'TERSE'
>
>if symbol( 'Valid.node' )<>'VAR' then say 'invalid
>suffix:' node

I do something similar but that might be of greater use to
Bill. Using his examples, I'd code something along the
lines of:

type. = 'obviously invalid'
type.TXT = 'TXT'
type.TEXT = 'TXT'
type.TRS = 'TRS'
type.TERSE = 'TRS'
type.TERSED = 'TRS'

...

parse upper ext testext

select
when type.testext = 'TXT' then ...
when type.testext = 'TRS' then ...
otherwise ...
end /*select*/

--
I cannot receive mail at the address this was sent from.
To reply directly, send to ar23hur "at" pobox "dot" com

Rob Zenuk

unread,
Mar 24, 2012, 10:03:02 AM3/24/12
to
Personally, I like the STEM approach when there is a large or unknown number
of valid responses that are "learned" during initial reading of the target
data.

I like the WORDPOS approach when the list of valid responses is known ahead
of time and is short. I think the WORDPOS approach (and supporting comments
in the code) is easier to read and understand, but becomes a poor performer
and unwieldy with a large amount of responses. I still tend to maintain the
"valid list" variable in my code anyway since many times I need (or want) to
print it in a final report.

On a side topic since I usually maintain the list of stem tails in a
variable anyway... Has it just eluded me all these years or is there some
trick to getting the list of all stem variables hanging off a stem "base"
(all tails of a stem)?

Example: Get all variables beginning with "Stem."

And have it return something like this:

Stem.1
Stem.first
Stem.x
Stem.z.y.x
Stem.fred
Stem.88
Stem.verylongtail
Stem.Monday.08:00

Thanks,

Rob


-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On Behalf Of
Arthur T.
Sent: Friday, March 23, 2012 10:08 PM
To: TSO-...@VM.MARIST.EDU
Subject: Re: Verifying strings

Paul Gilmartin

unread,
Mar 24, 2012, 10:49:32 AM3/24/12
to
On Mar 24, 2012, at 07:59, Rob Zenuk wrote:
>
> ... is there some
> trick to getting the list of all stem variables hanging off a stem "base"
> (all tails of a stem)?
>
FAQ.

Not in Rexx per se. Rexx is the only language I know of that
supports associative arrays but provides no way to enumerate
the members of one.

I am told that OO Rexx has such a feature. I haven't used
OO Rexx.

Assembler interfaces, documented in the Ref. Man. provide
ways of doing this. Almost. I haven't tried it, but I
understand there's a deficiency. After:

Stem. = "Junk"
drop Stem.42

... those assembler interfaces will not report the distinguished
status of Stem.42.

-- gil

Don Imbriale

unread,
Mar 24, 2012, 10:52:05 AM3/24/12
to
Would Rob Scott's STEMPUSH/STEMPULL provide some direction on retrieving
stems?

- Don Imbriale

Walter Pachl

unread,
Mar 24, 2012, 11:26:32 AM3/24/12
to
xtaillist=''
cnt.=0
Do ....
xtail=c2x(tail) /* if tails may contain blanks!! */
If wordpos(xtail,xtaillist)=0 Then
xtaillist=xtaillist xtail
stem.tail=whatever
cnt.tail=cnt.tail+1
End

xtaillist=wordsort(xtaillist) /* my function */
Do While xtaillist<>''
Parse Var xtaillist xtail xtaillist
tail=x2c(xtail)
Say tail '->' stem.tail
End

Tested
Walter

---- Don Imbriale <don.im...@GMAIL.COM> schrieb:

Paul Gilmartin

unread,
Mar 24, 2012, 11:35:34 AM3/24/12
to
On Mar 24, 2012, at 08:50, Don Imbriale wrote:

> Would Rob Scott's STEMPUSH/STEMPULL provide some direction on retrieving
> stems?
>
Availability? Google gives me several pages, many of which point to:

http://www.secltd.co.uk/

... which seems to be a dead end.

-- gil

Paul Gilmartin

unread,
Mar 24, 2012, 11:53:48 AM3/24/12
to
On Mar 23, 2012, at 23:07, Arthur T. wrote:
>
> I do something similar but that might be of greater use to
> Bill. Using his examples, I'd code something along the
> lines of:
>
> type. = 'obviously invalid'
>
And certainly I'll advocate "drop type." and using the
symbol() function to test for undefined elements, lest
the code get reused and re-reused and finally used in
a context where "obviously invalid" is not so obviously
invalid. Simply it avoids all cogitation over what
value to choose as invalid.

-- gil

Don Imbriale

unread,
Mar 24, 2012, 12:26:08 PM3/24/12
to
Try CBT tape file 411

Paul Gilmartin

unread,
Mar 24, 2012, 3:06:36 PM3/24/12
to
On Mar 24, 2012, at 08:50, Don Imbriale wrote:

> Would Rob Scott's STEMPUSH/STEMPULL provide some direction on retrieving
> stems?
>
Alas, no. It does a fair job at its purpose of copying
compound variables from one EXEC to another, but no means
of enumerating them.

My test Rexx EXEC:

/* Rexx */ signal on novalue; /*
Doc: Test operation of STEMPUSH and STEMPULL from CBTTAPE 411-412.
*/
Token = MakeIt()
Stuff. = '*** incorrect ***'
RC = STEMPULL( Token )
call ShowIt 'Copy', Token
return

MakeIt: procedure
Stuff. = 'Junk'
Stuff.TAIL41 = 'Before'
drop Stuff.TAIL42
Stuff.TAIL43 = 'After'
Token = STEMPUSH( 'Stuff.' )
call ShowIt 'Original', Token
return( Token )

ShowIt:
say
say ' -----' arg( 1 ) 'content of stacked arrays. -----'
call ShowOne 'Stuff.'
do I = 40 to 44
call ShowOne 'Stuff.TAIL'I; end
return

ShowOne:
say left( arg( 1 ), 13 ) 'is' symbol( arg( 1 ) ) value( arg( 1 ) )
return

And the output:

----- Original content of stacked arrays. -----
Stuff. is VAR Junk
Stuff.TAIL40 is VAR Junk
Stuff.TAIL41 is VAR Before
Stuff.TAIL42 is LIT STUFF.TAIL42
Stuff.TAIL43 is VAR After
Stuff.TAIL44 is VAR Junk

----- Copy content of stacked arrays. -----
Stuff. is VAR *** incorrect ***
Stuff.TAIL40 is VAR *** incorrect ***
Stuff.TAIL41 is VAR Before
Stuff.TAIL42 is VAR *** incorrect ***
Stuff.TAIL43 is VAR After
Stuff.TAIL44 is VAR *** incorrect ***
***

The differences are not due to any deficiency in the author's
craftsmanship, but to shortcomings in the Rexx interface design.

-- gil

Rob Zenuk

unread,
Mar 24, 2012, 5:08:12 PM3/24/12
to
I already maintain them in a variable... That was what I was referring to
when I said "valid list" variable. I prefer not to use a stem for that
purpose.

Thanks,

Rob

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On Behalf Of
Adrian Stern
Sent: Saturday, March 24, 2012 7:08 AM
To: TSO-...@VM.MARIST.EDU
Subject: Re: Verifying strings

As far as I know there is no way - unless you record them all in another
stem variable as you create them - how about that?

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On Behalf Of
Rob Zenuk
Sent: den 24 mars 2012 15:00
To: TSO-...@VM.MARIST.EDU
Subject: Re: [TSO-REXX] Verifying strings

Rob Zenuk

unread,
Mar 24, 2012, 6:13:44 PM3/24/12
to
That is exactly what I do today to create the "valid list" variable.
However, "unwinding" the list at the end may take many forms depending on
the project.

BTW, I also have a WORDSORT. In fact it is called from my FMTLIST function
to format a list of blank delimited values stored in a variable. It
provides nice sorted evenly formatted multi-column output.

So my printing of a taillist variable would be:

Call fmtlist 80 'TAIL' taillist

This would format a sorted 80 byte wide columnar report labeled "TAILS".

If I needed the contents of the stem (stem.tail), I would need to do exactly
what you did. Usually when I use this technique it is purely as an
existence check... Probably 90% of the time...

if symbol('stem.tail') = 'VAR' then ...

I also use this technique as a counter when I need to know the number of
occurrences of each unique tail value. Probably 5-10% of the time.

Taillist = ''
do ...
if wordpos(tail,taillist) = 0 then
do
taillist = tailist tail
stem.tail = 1
end
else
do
stem.tail = stemp.tail + 1
end
end

If I truly needed to store something in the stem.tail AND keep a count,
again my code would look almost identical to yours.

Thanks,

Rob


-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On Behalf Of
Walter Pachl
Sent: Saturday, March 24, 2012 8:26 AM
To: TSO-...@VM.MARIST.EDU
Subject: Re: Verifying strings

Mickey

unread,
Mar 25, 2012, 9:32:26 PM3/25/12
to
I would take the dataset name, convert all the periods to spaces via an DSN
= OVERLAY(DSN,' ' ,'.') and then use wordpos.

--------------------------------------------------
From: "Bill Ashton" <bill00...@GMAIL.COM>
Sent: Friday, March 23, 2012 5:33 PM
To: <TSO-...@VM.MARIST.EDU>
Subject: [TSO-REXX] Verifying strings

Marc Irvin

unread,
Mar 26, 2012, 12:56:12 AM3/26/12
to
Guys,

I use my findpos() when I have the kind of problem I think Bill Ashton
is trying to solve. It's wordpos() on steroids. Doing NL I often have
to look for sets of chars or words in strings, but only want the
position of the first match. Neither pos, wordpos, nor parse deliver
that much precision.

/*
example:
The following example finds the position of the first occurance
of ; . ? or ! in a variable filled with english sentences.
endposofsentence = findpos('/; /. /? /! ',englishsentences' ',1,'/')
Bill's example:
files = 'pos.pro findpos.rex data.txt iexplore.exe'
endposoffilename = findpos('com txt htm pro exe rex',files' ',1,' ',1)
*/
/**------------------------------------------------------------------**/
/* FINDPOS SEARCHES FOR MULTIPLE CHARS IN A STRING, NOT JUST ONE. */
/**------------------------------------------------------------------**/
FINDPOS: PROCEDURE
PARSE ARG SCH,STR,POS,DLM,UPR,PFX,OPT /* OPT=1 MEANS RETURN FND VALUE*/
LOC = 0 /* INIT AT NOT FOUND */
if upr \= 1 then upr = 0
if upr then do
str = translate(str)
sch = translate(sch)
end
IF POS = 0 | DATATYPE(POS) \= 'NUM' THEN POS = 1
IF LENGTH(SCH) = 0 | LENGTH(STR) = 0 | POS > LENGTH(STR)
THEN NOP
ELSE DO UNTIL SCH == ''
IF DLM == ''
THEN PARSE VAR SCH 1 FND 2 SCH
ELSE IF DLM = ''
THEN PARSE VAR SCH FND SCH
ELSE PARSE VAR SCH FND (DLM) SCH
IF FND == '' THEN ITERATE
IF PFX = ''
THEN WRK = POS(FND,STR,POS)
ELSE WRK = POS(PFX||FND' ',STR,POS)
IF WRK = 0 THEN ITERATE
/* ONLY KEEP EARLIEST MATCH */
IF LOC = 0
THEN LOC = WRK FND
ELSE IF WORD(LOC,1) > WRK THEN LOC = WRK FND
END
IF OPT = 1
THEN RETURN LOC
ELSE RETURN WORD(LOC,1)


On 3/23/2012 5:33 PM, Bill Ashton wrote:

Bob Bridges

unread,
Mar 26, 2012, 11:33:56 AM3/26/12
to
:) Sounds like my WORDSPOS - or maybe my ABBREVPOS, I'm not sure which. I
suppose we all pump steroids into REXX functions occasionally.

---
Bob Bridges, rhb...@attglobal.net, cell 336 382-7313

/* The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all progress
depends on the unreasonable man. -George Bernard Shaw, "Maxims for
Revolutionists" */

-----Original Message-----
From: Marc Irvin
Sent: Monday, March 26, 2012 00:55

I use my findpos() when I have the kind of problem I think Bill Ashton
is trying to solve. It's wordpos() on steroids. Doing NL I often have
to look for sets of chars or words in strings, but only want the
position of the first match. Neither pos, wordpos, nor parse deliver
that much precision.

--- On 3/23/2012 5:33 PM, Bill Ashton wrote:
> I would like to test a variable for multiple string possibilities, and am
> looking for the easiest way to do this.

Marc Irvin

unread,
Mar 29, 2012, 12:55:55 AM3/29/12
to
Test...
0 new messages