string switching
eharetea

Switching the values in strings to be the opposite of the other.

Useful Hscript when working with OTL's and HDA's.

Date Created:Friday December 29th, 2006 03:41 AM
Date Modified:Wednesday July 30th, 2008 02:18 PM


# OPPOSITE ARGUMENTS IN TWO SEPARATE STRING
# arg1 is the field to display in
# arg2 is the field to have opposite args of

set SOP = `oppwd()`
set node ""

foreach noder (`run("opls $OBJECTCONTAINER")`)

    set node $node $noder

end

opparm $SOP $arg1 ("$node")

set wanted = `chs("$SOP/$arg2")`
set check = `chs("$SOP/$arg1")`
set checknum = `argc($check)` 


for 0 to `evals(argc($wanted)-1)`

    # sets $wnew for checking    

    set wnew = `arg($wanted,$i)`

        for 0 to `evals(argc($check)-1)`

            # sets $cnew for checking
            set cnew = `arg($check,$x)`
            set matchme = `strmatch($cnew,$wnew)`

            if "$matchme" == "1" then

                set matched $matched $cnew

            endif

        end
end



for 0 to `evals(argc($matched)-1)`
    set rcheck = `arg($matched,$r)`
    set nvar = `strreplace($check,${rcheck},"")`
    set check $nvar
end

opparm -C $SOP $arg1 ("$nvar")



Downloads:
Download: switch.sh 1 KB

Please login or Click Here to register for downloads
Creative Commons License
string switching by Dan Lynch
is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
Based on a work at www.3daet.com
Permissions beyond the scope of this license may be available at http://www.3daet.com