From: hrachyag on 4 May 2010 06:20 On Apr 21, 7:33 pm, Glenn Jackman <gle...(a)ncf.ca> wrote: > At 2010-04-21 10:11AM, "hrachyag" wrote: > [...] > > > > > What I am trying to achieve is the following: > > > 1) The input_cap proc will receive input of the form: > > > -pts 'fn40c tt25c sd25c sp8c ff25c' -config PiDoST 'i1 i2' -config > > PiDoIT 'i3 i4' -config PiDoST 'i5 i6 i7 i8' > > > The PiDoST/PiDoIT/PiDoST values in the -config option will be used to > > create three columns of a table with column headings PiDoST/PiDoIT/ > > PiDoST. > > > Each such PiDoST/PiDoIT/PiDoST column will have four nested columns > > whose names will be fn40c tt25c sd25c sp8c ff25c taken from the value > > list of the -pts option. > > > So, both -pts and -config will be provided as input at the same time.. > > Well, then I'd do something like: > > proc input_capargs{ > while {[llength $args] > 0} { > setargs[lassign $argsoption] > switch -exact -- $option { > -pts { > setargs[lassign $argspts] > } > -config { > setargs[lassign $argscolname coltype] > lappend configs [list $colname $coltype] > } > default { > error "oops, found invalid option: $option" > } > } > } > puts "pts = $pts" > puts "configs = $configs" > } > > Then > > input_cap \ > -pts "fn40c tt25c sd25c sp8c ff25c" \ > -config PiDoST "i1 i2" \ > -config PiDoIT "i3 i4" \ > -config PiDoST "i5 i6 i7 i8" > > outputs: > > pts = fn40c tt25c sd25c sp8c ff25c > configs = {PiDoST {i1 i2}} {PiDoIT {i3 i4}} {PiDoST {i5 i6 i7 i8}} > > -- > Glenn Jackman > Write a wise saying and your name will live forever. -- Anonymous Thank you for explanations, Glenn! My implementation is pretty much similar to yours but I chose to do it a bit differently. set argi 0 set configs {} set pts {} while { $argi < $argc } { set option [lindex $args $argi] if { $option == "-pts" } { if { $argi < $argc - 1 } { incr argi set pts [lindex $args $argi] } else { print_usage puts "Error: Missing argument \$pts for option $option" exit 1 } } elseif { $option == "-configs" } ..... .... .... Thank you for pointers again! Hrachya
First
|
Prev
|
Pages: 1 2 Prev: How do I center justify a ttk::button's label ??? Next: using libusb from TCL |