Re: tcl lists



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

.



Relevant Pages

  • Re: tcl lists
    ... the list consists of:aggrMode and mainMode. ... So the list is defined as(2 lists below to explain better and they are ... For the proc below, 'options' is a command line argument passed to the ... proc SetOpt { ...
    (comp.lang.tcl)
  • Re: Uninterned symbols at macroexpansion time.
    ... (loop for somevar in '(some list here) ... so if we give the macro a gensym in ... collect (BACKQUOTE (UNQUOTE X)))) ... simple type (meaning eg symbols, lists, etc) not ...
    (comp.lang.lisp)
  • Re: Learning Lisp in Linux?
    ... To adapt the language to the task at hand? ... unless (member key excluded-keys) ... (loop (cddr property-list) ... correct property lists as results. ...
    (comp.lang.lisp)
  • Re: Optimize a function for speed
    ... Lists in Common Lisp are ... (loop while ... ... (setf mlist (rest mlist)). ... (setf (aref mtable ind 0) ...
    (comp.lang.lisp)
  • Re: Replacing subsequences
    ... >> different substring, of a different length (for quoting parameters to SQL ... fill-pointer that let me append sequences to my sequence at the fill ... Worth the price of avoiding loop, ... Is there anything besides lists and vectors to worry about? ...
    (comp.lang.lisp)