Page 1 of 1

Avoid duplication in array

PostPosted: Thu Jul 02, 2009 5:47 pm
by senthil
hi all,
i have an array
arr.1 = 'peter'
arr.2 = 'parker'
arr.3 = 'osborn'
arr.4 = 'peter'
arr.5 = 'connor'
arr.6 = 'parker'
arr.7 = 'osborn'
arr.8 = 'peter'
arr.9 = 'parker'
arr.10 = 'kevin'

now i have to copy this to another array without duplications in a rexx exec.
can any one suggest a solution...............

Re: Avoid duplication in array

PostPosted: Thu Jul 02, 2009 11:15 pm
by dick scherrer
Hello,

As you create the new array, scan it to make sure the entry you are about enter is not already present. If it exists, increment to the next "input" entry. If it does not, move the value to the array and then increment to the next.

Re: Avoid duplication in array

PostPosted: Fri Jul 03, 2009 3:55 pm
by expat
Dick, Creating an internal sort or cross reference duplicates routine in REXX is easy enough, but when the number of records gets higher the time taken is much increased. At one site the internal REXX sort ran for 14 hours, but an invoked SORT for the same data took 23 seconds.

The code below will read the contents of the stem FILE99 into the SORTIN DD, perform the external sort, and then read the sorted output back into the stem FILE99.

Obviously you will need to change your SYSOUT parameter to fit with your site standards, also to set the SORT parameters to your requirement, and of course to use the stem name that you have chosen.

X = MSG('OFF')
"FREE  FI(SYSIN,SYSOUT,SORTIN,SORTOUT)"
"ALLOC FI(SYSOUT)   SYSOUT(X)"
"ALLOC FI(SYSIN)    NEW TRACKS SPACE(3 3)     RECFM(F B) LRECL(80)"
"ALLOC FI(SORTIN)   NEW TRACKS SPACE(300 300) RECFM(V B) LRECL(80)"
"ALLOC FI(SORTOUT)  NEW TRACKS SPACE(300 300) RECFM(V B) LRECL(80)"
QUEUE " OPTION VLSHRT VLSCMP"
QUEUE " SORT FIELDS=(5,44,CH,A)"
QUEUE "  SUM FIELDS=NONE"
"EXECIO "QUEUED() "DISKW SYSIN   ( FINIS"
"EXECIO * DISKW SORTIN  ( STEM FILE99. FINIS"
FILE99.0 = 0
DROP FILE99.
"CALL *(SORT)"
"EXECIO * DISKR SORTOUT ( STEM FILE99. FINIS"
"FREE  FI(SYSIN,SYSOUT,SORTIN,SORTOUT)"

Re: Avoid duplication in array

PostPosted: Sat Jul 04, 2009 7:15 am
by dick scherrer
Hi Expat,

Foolish me. . . Believed there were only 10 entries. . .

I've never been a proponent of "whole file" processing in rexx (clist) anyway ;)

d

Re: Avoid duplication in array

PostPosted: Tue Jul 14, 2009 10:21 pm
by parthiban
Hi Expat,

You're right. Same happend to me. So i just used external sort.






Thanks,
Parthiban j