newbie: foreach
- From: "Kev P." <kev.parsons@xxxxxxxxxx>
- Date: 16 Aug 2005 06:15:59 -0700
I'm sure the below can be simplified with some sort of "foreach", but
so far I've failed. Anyone help please?
Snippet of code attached:
#######################################################################
# Display prompt; push the partial line of text to the console
proc yes_no {userlib} {
puts -nonewline "Do you want $userlib Libraries (enter Y/N)? "
flush stdout
# Loop until we have satisfactory input
while {1} { #loop forever until told to stop
gets stdin line
set ans [string tolower [string index $line 0]]
if {$ans == "y"} {
set yes 1
break ;# get out of while loop
} elseif {$ans == "n"} {
set yes 0
break ;# get out of while loop
} else {
puts -nonewline "Try again: $userlib Libs (Y/N)? "
flush stdout
}
}
return $yes
}
#######################################################################
set yes_Actel_apa [yes_no Actel_apa]
set yes_Actel_act1 [yes_no Actel_act1]
set yes_Actel_act2 [yes_no Actel_act2]
set yes_Actel_act3 [yes_no Actel_act3]
if {$yes_Actel_apa == 1} {
puts $hdsnew "apa = C:/Actel/MS57e_D61_SP1/lib/vtl/95/mti/apa"
}
if {$yes_Actel_act1 == 1} {
puts $hdsnew "act1 = C:/Actel/MS57e_D61_SP1/lib/vtl/95/mti/act1"
}
if {$yes_Actel_act2 == 1} {
puts $hdsnew "act2 = C:/MS57e_D61_SP1/lib/vtl/95/mti/act2"
}
if {$yes_Actel_act3 == 1} {
puts $hdsnew "act3 = C:/MS57e_D61_SP1/lib/vtl/95/mti/act3"
}
.
- Follow-Ups:
- Re: newbie: foreach (oops)
- From: miguel sofer
- Re: newbie: foreach
- From: miguel sofer
- Re: newbie: foreach
- From: Bryan Oakley
- Re: newbie: foreach
- From: Glenn Jackman
- Re: newbie: foreach (oops)
- Prev by Date: problem with rsh using expect
- Next by Date: Re: newbie: foreach
- Previous by thread: problem with rsh using expect
- Next by thread: Re: newbie: foreach
- Index(es):
Relevant Pages
|