Re: tcl lists
- From: aniket.khosla@xxxxxxxxx
- Date: 8 Dec 2006 10:32:59 -0800
Thanks for all the feedback.
i need to be able to set ALL the elements of the list in the same loop.
E.g.
set p1_mode {mainMode aggrMode newMode}
what i need to set in runVpn {options} (each loop) is:
if {[catch { ixvpn::ipsec configure -mainMode 100 }]
if {[catch { ixvpn::ipsec configure -aggrMode 0 }]
if {[catch { ixvpn::ipsec configure -newMode 0 }]
All the discussions above tell me to set mainMode to 100(others 0) and
run the test and then set back to 0.
I need all three elements to be set before running the test.
In my next loop i need:
if {[catch { ixvpn::ipsec configure -mainMode 0 }]
if {[catch { ixvpn::ipsec configure -aggrMode 100 }]
if {[catch { ixvpn::ipsec configure -newMode 0 }]
and in the final loop i need:
if {[catch { ixvpn::ipsec configure -mainMode 0 }]
if {[catch { ixvpn::ipsec configure -aggrMode 0 }]
if {[catch { ixvpn::ipsec configure -newMode 100 }]
This is one sample list with the options set as p1_mode. There are
other lists with different numbers or arguments which can be passed to
the runVpn proc.
Thanks
On Dec 8, 1:32 am, Neil Madden <n...@xxxxxxxxxxxxx> wrote:
aniket.kho...@xxxxxxxxx wrote:
My apologies... i didnt realize what i was typing...
ure right... the list consists of :aggrMode and mainMode.
So the list is defined as(2 lists below to explain better and they are
included in common.tcl which is sourced below)_:
set p1_mode {mainMode aggrMode}
set p1_encr {phase1des phase1enc3des phase1encAes128 phase1encAes192
phase1encAes256}
For the proc below, 'options' is a command line argument passed to the
proc from the CLI and can be 'p1_mode' or 'p1_encr'
My proc is:...
Some stylistic comments: Do you really want Common.tcl to be [source]d
every time that the runVpn proc is called, or just once? If the latter,
then move the source outside the procedure definition. Another minor
point would be to use [upvar] rather than [set $options], as it makes
the code clearer. That said, the solution you apparently want is rather
similar to what Don Porter already posted:
source Common.tcl
proc SetOpt {opt val} {
if {[catch { ixvpn::ipsec configure -$opt $val }]} {
handleAttrError $x
# Do you need to return an error here?
}
}
proc runVpn options {
upvar #0 $options opts ;# link in appropriate global
# Set all options to zero initially
foreach opt $opts { SetOpt $opt 0 }
# Now loop through and test each individual option
foreach opt $opts {
SetOpt $opt 100
# Where does $testName come from?
runTest $testName $opt
# Set option back to 0
SetOpt $opt 0
}
}
-- Neil
.
- Follow-Ups:
- Re: tcl lists
- From: Cameron Laird
- Re: tcl lists
- References:
- tcl lists
- From: aniket . khosla
- Re: tcl lists
- From: Don Porter
- Re: tcl lists
- From: aniket . khosla
- Re: tcl lists
- From: Don Porter
- Re: tcl lists
- From: aniket . khosla
- Re: tcl lists
- From: Don Porter
- Re: tcl lists
- From: aniket . khosla
- Re: tcl lists
- From: Neil Madden
- tcl lists
- Prev by Date: Re: what's a Content-Transfer-Encoding named base8 ...
- Next by Date: Re: what's a Content-Transfer-Encoding named base8 ...
- Previous by thread: Re: tcl lists
- Next by thread: Re: tcl lists
- Index(es):
Relevant Pages
|