Hi Donna,
On Apr 14, 9:51am, Donna Garverick wrote:
> how to nomalize or fix hppath to take out duplicate
> references. i believe someone posted a bit of script to do
> this but i'm not having any luck finding it on raven.
> perhaps the better question is -- is it even worthwhile to do?
I imagine it is worthwhile for long HPPATHs with lots of dups.
Anyways here is a script I wrote that should work. Note, it handles
duplicate MPE and POSIX elements in the path variable.
Jeff Vance, CSY
------------------cut here---------------
PARM path=HPPATH
# This script removes all duplicate entries in the "path" parm. MPE
# and POSIX path elements are accounted for. The "path" parm names
# a CI variable that contains HPPATH-like elements.
#
setvar i 0
while setvar(tok,word(!path,,setvar(i,i+1),n)) <> "" and &
n < len(!path) do
setvar mpe_tok (fsyntax(tok) = "MPE")
# do a token replace rather than a character replace, as repl() does,
# so that substrings of path elements aren't incorrectly replaced
setvar j i
while setvar(next_tok,word(!path,,setvar(j,j+1),m)) <> "" do
setvar mpe_next_tok (fsyntax(next_tok) = "MPE")
if (mpe_tok and mpe_next_tok and dwns(tok) = dwns(next_tok)) or &
(not mpe_tok and not mpe_next_tok and tok = next_tok) then
# remove matching element
setvar !path lft(!path,n)+rht(!path,-m-1)
# decrement target word (j) due to match
setvar j j-1
else
# adjust ending index of the last unique path token
setvar n m
endif
endwhile
endwhile
--
|