A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
20
Task/Menu/Tcl/menu-1.tcl
Normal file
20
Task/Menu/Tcl/menu-1.tcl
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
proc select {prompt choices} {
|
||||
set nc [llength $choices]
|
||||
if {!$nc} {
|
||||
return ""
|
||||
}
|
||||
set numWidth [string length $nc]
|
||||
while true {
|
||||
set i 0
|
||||
foreach s $choices {
|
||||
puts [format " %-*d: %s" $numWidth [incr i] $s]
|
||||
}
|
||||
puts -nonewline "$prompt: "
|
||||
flush stdout
|
||||
gets stdin num
|
||||
if {[string is int -strict $num] && $num >= 1 && $num <= $nc} {
|
||||
incr num -1
|
||||
return [lindex $choices $num]
|
||||
}
|
||||
}
|
||||
}
|
||||
31
Task/Menu/Tcl/menu-2.tcl
Normal file
31
Task/Menu/Tcl/menu-2.tcl
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
% puts >[select test {}]<
|
||||
><
|
||||
% puts >[select "Which is from the three pigs" {
|
||||
"fee fie" "huff and puff" "mirror mirror" "tick tock"
|
||||
}]<
|
||||
1: fee fie
|
||||
2: huff and puff
|
||||
3: mirror mirror
|
||||
4: tick tock
|
||||
Which is from the three pigs: 0
|
||||
1: fee fie
|
||||
2: huff and puff
|
||||
3: mirror mirror
|
||||
4: tick tock
|
||||
Which is from the three pigs: skdfjhgz
|
||||
1: fee fie
|
||||
2: huff and puff
|
||||
3: mirror mirror
|
||||
4: tick tock
|
||||
Which is from the three pigs:
|
||||
1: fee fie
|
||||
2: huff and puff
|
||||
3: mirror mirror
|
||||
4: tick tock
|
||||
Which is from the three pigs: 5
|
||||
1: fee fie
|
||||
2: huff and puff
|
||||
3: mirror mirror
|
||||
4: tick tock
|
||||
Which is from the three pigs: 2
|
||||
>huff and puff<
|
||||
Loading…
Add table
Add a link
Reference in a new issue