Forum Discussion
Mar 07, 2015
BIG-IP : iRule test that variable exists and has certain value
F5 BIG-IP Virtual Edition v11.4.1 (Build 635.0) LTM on ESXi
What is the simplest most elegant syntax to test that a variable exists and has a certain value ?
For example if I want to determine t...
Michael_Jenkins
Mar 07, 2015Cirrostratus
You'll need to use
[info exists myvariable]
(without the $
) to check for variable existence. Then you would do your other conditional check.
So like this in your example
when HTTP_REQUEST {
set myvariable 0
conditional processing ...
set myvariable 1
more processing ...
if {[info exists myvariable] && ($myvariable equals "1")} {
do something
}
}
If you know that your variable is going to be an integer, you could just use
$myvariable
instead of ($myvariable equals "1")
as it will return a true value for any positive value.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