Forum Discussion
jeff_mccombs_47
Nimbostratus
Aug 05, 2009when EVENT "chaining" and variable scope.
If you do something like:
when HTTP_REQUEST priority 1 {
set somevar "somevalue"
}
Is the variable accessable in other HTTP_REQUEST event blocks with a higher priorit...
hoolio
Cirrostratus
Aug 06, 2009You could test this pretty easily:
when HTTP_REQUEST priority 1 {
This will trigger a runtime TCL error as the variable doesn't exist
log local0. "\$non_existent_variable: $non_existent_variable"
Comment out the above and set the variable in this event
set non_existent_variable "now exists!"
}
when HTTP_REQUEST priority 2 {
This will work now
log local0. "\$non_existent_variable: $non_existent_variable"
}
does that make sense? Does the Tcl interp "chain" events together, executing each event independently in a seperate namespace in order of priority, or does it concatenate them all and execute them under the same namespace?
I think each event on the same virtual server is chained together in order of priority under the same namespace.
Obviously, local variables set in each event probably aren't transferrable - that is, I can't access $somevar under a HTTP_RESPONSE event unless it was global when it was declared. But events of the same type fired sequentially.. what happens then?
As cmbhatt said, yes, you can access a local variable across the same TCP connection in different events as long as the event you're referencing the variable in occurs after the local variable was set.
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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