Forum Discussion
Nik
Cirrus
Feb 07, 2015breaking out of a switch statement?
is it possible to break out of a switch statement like you would a loop? the break command doesn't seem to work.
my goal is to say.. if condition is met then use the default action, like this:
...
Michael_Jenkins
Cirrostratus
Feb 07, 2015tcl switch commands don't allow break or continue because those are specific to loops. There's also not a goto command, so what you'll wind up having to do if you need to do an inner conditional check is either repeat the default code in default and bad condition or else set a flag that gets checked outside the switch statement. Something like this...
switch blah {
"foo" {
if {good condition} {
Do whatever
} else if {bad condition {
set badFlag 1
}
default {
set badFlag 1
}
}
if { [info exists badFlag] && $badFlag } {
tell the user he sucks
}
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects