Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Test for multiple equality

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
prino

Active Member


Joined: 07 Feb 2009
Posts: 984
Location: Oostende, Belgium

PostPosted: Tue Sep 15, 2015 12:47 am    Post subject: Test for multiple equality
Reply with quote

Can anyone come up with a smart way of telling me if all values in a series are equal? The length of the series ranges from 1 to potentially about 200+ vID/value pairs (although in practice the longest series currently counts 15 pairs)

The format of the series is '{X-' followed by ID (3 characters)/space/number (sign+2digits)/space sets, so e.g.

Code:
{X-AA  +00 B   +00 CC  +00 D   +00
{X-AA  +00 B   +00 CC  +00 D   +00 E   +00 FF  +01 G   +00
{X-AA  +00 B   +00 CC  +00 D   +00 H   +00 II  +00 JJ  +01
{X-AA  +00 B   +00 CC  +00 D   +00 H   +00 II  +00 KK  +01 LL  +01 JJ  +01
{X-AA  +00 B   +00 H   +00 II  +00
{X-AA  +00 B   +00 H   +00 II  +00 JJ  +01 CC  +00 D   +00
{X-MM  -01
{X-NN  -08

I need to flag those where the number is not the same for all ID's.

If all values are +00, a simple

Code:
if string = translate(string, '000000000', '1234566789') then

works, but it (obviously) fails for cases where all values are the same, but not +00. One added complication is that the space following the number may in future be replaced by a space, or 'a', or 'b', or 'c', or 'd'.

This long-winded approach obviously works (and can be adapted if/when the a/b/c/d might be added at some stage):

Code:
ok = 1
do i = 2 by 2 to words(string) - 2 while ok
  ok = word(string, i) = word(string, i + 2)
end
Back to top
View user's profile Send private message

Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2019
Location: Silicon Valley

PostPosted: Tue Sep 15, 2015 3:24 am    Post subject: Reply to: Test for multiple equality
Reply with quote

I think your "obvious" approach looks pretty good.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1219
Location: Israel

PostPosted: Tue Sep 15, 2015 12:10 pm    Post subject:
Reply with quote

If a loop cannot be avoided (as I suspect), better stick to the obvious.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts COOLGEN - TSO TEST FACILITY indianrajput CA Products 4 Wed Nov 02, 2016 9:28 pm
This topic is locked: you cannot edit posts or make replies. How to supply called sub-program from... dchristensen JCL & VSAM 25 Wed Sep 14, 2016 11:36 pm
No new posts Converting multiple VB files to FB fi... Viswanath Reddy JCL & VSAM 6 Mon Aug 08, 2016 11:49 pm
No new posts Execute multiple DB2 Load commands in... faizm DB2 4 Wed Aug 03, 2016 12:53 pm
This topic is locked: you cannot edit posts or make replies. JCL MULTIPLE STEP EXECUTION QUERY Susanta JCL & VSAM 18 Sat Jul 30, 2016 1:17 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us