Forum Discussion
kai_wang_48807
Nimbostratus
Feb 04, 2007if syntax help!
1. Whether the if could be nested in iRule?
E.g if {} {
if {} {
}
elseif {} {
}
}
2. Whether the when could be nested in iRule? ...
Feb 05, 2007
Nested conditional statements are absolutely legal.
So, this IS legal:
when HTTP_REQUEST {
if { condition_1 } {
if { condition_2 } {
if { condition_3 } {
} elseif { condition_4 } {
and on and on an on...
} else {
}
} elseif { condition_5 } {
} else {
}
} elseif { condition_6 } {
} else {
}
}
But the when statement is a special F5 extension to TCL that allows for event triggering. Think of it like a function in C. These are only allowed at the outermost scope within an iRule.
This is NOT legal:
when HTTP_REQUEST {
when HTTP_RESPONSE {
}
}
But, this IS legal:
when HTTP_REQUEST {
...
}
when HTTP_RESPONSE {
...
}
-Joe
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