View previous topic :: View next topic
|
Author |
Message |
VijayKrish
New User
Joined: 30 Jun 2010 Posts: 10 Location: India
|
|
|
|
Hi,
I have a requirement to code in REXX. My Input file looks like below.
MODULEA RGN1
MODULEB RGN1
MODULEC RGN3
MODULEA RGN2
MODULEA RGN3
MODULEB RGN4
MODULEA RGN5
MODULEC RGN6
I wanted to remove the record from the file, where the module name occurs for the second time. My output should look like this.
MODULEA RGN1
MODULEB RGN1
MODULEC RGN3
Please provide me the code in REXX to this activity. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
I realize that it is not REXX, but instead a CLIST, and it excludes the dups
Code: |
ISREDIT MACRO
CONTROL NOLIST NOCONLIST NOSYMLIST NOPROMPT NOMSG NOFLUSH ASIS END(ENDO)
ISREDIT RESET
ISREDIT (NUMLNS) = LINENUM .ZL
ISREDIT (CURLN) = LINENUM .ZF
SET LASTLN = &STR()
SET THISLN = &STR()
SET &STCOL = 1
SET &ENDCOL = 40
DO WHILE &CURLN < &NUMLNS + 1
ISREDIT (THISLN) = LINE &CURLN
SET THISLN = &SUBSTR(&STCOL:&ENDCOL,&THISLN)
IF &STR(&THISLN) = &STR(&LASTLN) THEN +
DO
ISREDIT CURSOR = &CURLN
ISREDIT EXCLUDE ALL .ZCSR .ZCSR
ENDO
SET LASTLN = &STR(&THISLN)
SET LSTLN = &CURLN
SET CURLN = &CURLN + 1
ENDO
EXIT
|
a quick attempt to convert to rexx is as follows:
Code: |
/* REXX */
ISREDIT MACRO
ISREDIT RESET
ISREDIT (NUMLNS) = LINENUM .ZL
ISREDIT (CURLN) = LINENUM .ZF
LASTLN = ""
THISLN = ""
STCOL = 1 /* change the start col and endcol */
ENDCOL = 40 /* depending on your need */
/* or simply enter the start col and end column */
/* as arguments */
/* */
DO WHILE CURLN < NUMLNS + 1
ISREDIT (THISLN) = LINE CURLN
THISLN = SUBSTR(THISLN,STCOL,ENDCOL)
IF THISLN = LASTLN THEN +
DO
ISREDIT CURSOR = CURLN
ISREDIT EXCLUDE ALL .ZCSR .ZCSR
END
LASTLN = THISLN
LSTLN = CURLN
CURLN = CURLN + 1
END
EXIT
|
at the end of the rexx you can type in DELETE ALL X
or you can put the command in the REXX macro. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
Please provide me the code in REXX to this activity. |
as soon You have provided the proper fee
this is a help forum, not a do it for me one |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Sorry enrico,
could not help myself.
we can charge we he starts asking for explanation. |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
Note that if it is a large dataset, an Edit-Macro won't do the job.
I recommend invoking SORT from within REXX - much faster & possibly less error-exposed.
O. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
ofer71 wrote: |
Note that if it is a large dataset, an Edit-Macro won't do the job.
I recommend invoking SORT from within REXX - much faster & possibly less error-exposed.
O. |
Ditto, also if the dataset is on tape and the REXX runs in foreground.
Quotes for code and testing available on request |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
I have a requirement to code in REXX. |
Someone "who must be obeyed" may have dictated that rexx be used, but there is no business requirement to use rexx. . .
The business requirement is to deal with the duplicates.
Whichever is a proper tool should be used. . .
Sounds like once again, someone has found a neat little hammer (rexx) and wants everything to be done to be a nail . . . |
|
Back to top |
|
|
|