I have a scope problem I cannot figure out.
The global var is declared inside a proc and is
visible outside the procedure, but does not get processed by the switch -- $var.
ex:
if {[string match "debug" $argv]} {
puts "Debug enabled." ; sleep 1s
exp_internal 1
} else {
send_user "No debug.\n"
}
proc mount_ {} {
set timeout -1
global target
puts "
1. Floppy
2. CDROM
3. Other
4. unmount
5. Exit
"
send_user "YOUR CHOICE: "
expect_user -re "\[0-9]+\n"
set target $expect_out(0,string)
string trimright $target "\n"
}
send_user "Menu UP."
mount_
#tshoot
puts $target
switch -- $target "1" {
exec mount /dev/fd0
set target "/dev/fd0"
} "2" {
exec mount /dev/cdrom
set target "/dev/cdrom"
} "3" {
exec mount /dev/$target
} "4" {
umount $target
} "5" {
exit
}
Very simple, but switch nevers see the var, even though
the variable is exported from the procedure.
Strange.
The global var is declared inside a proc and is
visible outside the procedure, but does not get processed by the switch -- $var.
ex:
if {[string match "debug" $argv]} {
puts "Debug enabled." ; sleep 1s
exp_internal 1
} else {
send_user "No debug.\n"
}
proc mount_ {} {
set timeout -1
global target
puts "
1. Floppy
2. CDROM
3. Other
4. unmount
5. Exit
"
send_user "YOUR CHOICE: "
expect_user -re "\[0-9]+\n"
set target $expect_out(0,string)
string trimright $target "\n"
}
send_user "Menu UP."
mount_
#tshoot
puts $target
switch -- $target "1" {
exec mount /dev/fd0
set target "/dev/fd0"
} "2" {
exec mount /dev/cdrom
set target "/dev/cdrom"
} "3" {
exec mount /dev/$target
} "4" {
umount $target
} "5" {
exit
}
Very simple, but switch nevers see the var, even though
the variable is exported from the procedure.
Strange.