View previous topic :: View next topic |
Author |
Message |
nguyenh Beginner
Joined: 09 Mar 2004 Posts: 52 Topics: 6
|
Posted: Fri Jul 01, 2005 4:54 pm Post subject: CLIST:Extract matched members from 2 lists & put in a ta |
|
|
Hi expert,
CLIST question: Could someone please show me how to extract matched members(OMEM & NMEM) from OLDLIST and NEWLIST and put them in MTABLE, assume I have MTABLE created, OLDLIST and NEWLIST opened
Thank you very very much!
nguyenh
Code: |
DO WHILE (&NOTEMPTY = 0)
ISPEXEC LMMLIST DATAID(&OLDLIST) OPTION(LIST) MEMBER(OMEM)
IF (&LASTCC > 8) THEN +
DO
ISPEXEC SETMSG MSG(MS1)
ISPEXEC LMCLOSE DATAID(&OLDLIST)
LMFREE DATAID(&OLDLIST)
SET NOTEMPTY = 1
END
ISPEXEC LMMLIST DATAID(&NEWLIST) OPTION(LIST) MEMBER(NMEM)
IF (&LASTCC > 8) THEN +
DO
ISPEXEC SETMSG MSG(MS2)
ISPEXEC LMCLOSE DATAID(&NEWLIST)
LMFREE DATAID(&NEWLIST)
SET NOTEMPTY = 1
END
END
|
|
|
Back to top |
|
|
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Fri Jul 01, 2005 9:08 pm Post subject: |
|
|
If you are doing anything with string processing I would absolutely avoid CLIST and use Rexx instead. CLIST is absolutely AWFUL at string parsing. Rexx is extremely easy to use and has a built in Parse instruction along with many, many useful string processing builtin functions.
As for the problem at hand, with Rexx, use EXECIO to read the file, Parse to extract the data from the listing, and ISPF's TBCREATE, TBADD, etc to handle the table. Search the 'net for examples. There should be many out there.
I know you asked about CLIST, but I can't bring myself to encourage anyone to do anything but the most trivial list of commands with CLIST. |
|
Back to top |
|
|
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Fri Jul 01, 2005 9:12 pm Post subject: |
|
|
Ooops... I assumed you were parsing a SuperC listing which can list matching members. Still, Rexx is the answer because you can call ISPF services and create lists of items like member names and then programatically compare them. The easiest way is to use Rexx "stem" variables, but you can just make 2 variables containing member names and loop through those variables (hint: wordpos()) |
|
Back to top |
|
|
nguyenh Beginner
Joined: 09 Mar 2004 Posts: 52 Topics: 6
|
Posted: Tue Jul 05, 2005 4:10 pm Post subject: |
|
|
Hi Experts,
I Thank you for all replies. For my first question I figured out the following code would give me the result that I want.
[code:1:f7484ef247]/*****************************************************************/
/* WRITE MEMBER NAMES THAT EXIST IN BOTH OLDLIST & NEWLIST */
/* INTO DIFFER TABLE */
/*****************************************************************/
SET RC = 0
DO WHILE (&RC = 0)
ISPEXEC LMMFIND DATAID(&NEWLIST) MEMBER(&OMEM) STATS(YES)
SET RC = &LASTCC
IF (&RC > 8) THEN +
DO
ISPEXEC SETMSG MSG(PD011N) /* LMMFIND ERROR */
GOTO CLEANUP
END
ELSE
IF (&RC = 0 ) THEN +
DO
SET TTLEN = &OMEM
ISPEXEC TBADD DIFFER
SET RC = &LASTCC
IF (&RC |
|
Back to top |
|
|
nguyenh Beginner
Joined: 09 Mar 2004 Posts: 52 Topics: 6
|
Posted: Tue Jul 05, 2005 4:45 pm Post subject: |
|
|
Just to be more clear,
I only want to process those members that have the following names: FILExx, FMT2, SM2, SM4, etc., where xx is 00-99 |
|
Back to top |
|
|
Mervyn Moderator
Joined: 02 Dec 2002 Posts: 415 Topics: 6 Location: Hove, England
|
|
Back to top |
|
|
nguyenh Beginner
Joined: 09 Mar 2004 Posts: 52 Topics: 6
|
Posted: Wed Jul 06, 2005 9:37 am Post subject: |
|
|
Mervyn,
Thank you for your help. That is exactly what I am looking for.
You guys are great!
Thanks! |
|
Back to top |
|
|
Mervyn Moderator
Joined: 02 Dec 2002 Posts: 415 Topics: 6 Location: Hove, England
|
Posted: Wed Jul 06, 2005 9:41 am Post subject: |
|
|
So are the manuals!
_________________ The day you stop learning the dinosaur becomes extinct |
|
Back to top |
|
|
|
|