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 priority?
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?
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?
2 Replies
- The_Bhattman
Nimbostratus
I believe if they are declared at the highest priority they can be used at the lower priority ones. However, they must adhere to the contruction and interaction as they remain usable as long as the connection remains present. If the events are triggered across different connections then a global variable should be used. - hoolio
Cirrostratus
You 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" }
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