# Functions for simulating CMP friendly global vars

**URL:** <https://community.f5.com/t/functions-for-simulating-cmp-friendly-global-vars/28982>\
**Category:** Technical Forums\
**Tags:** dev, irules, devops, application-delivery\
**Created:** [April 24, 2011, 2:50am UTC](https://community.f5.com/t/functions-for-simulating-cmp-friendly-global-vars/28982 "2011-04-24T02:50:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Breedlove](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@Matt\_Breedlove](https://community.f5.com/u/Matt_Breedlove)\
**Post date:** [April 24, 2011, 2:50am UTC](https://community.f5.com/t/functions-for-simulating-cmp-friendly-global-vars/28982/1 "2011-04-24T02:50:55Z")

</div>

Saw Aaron’s post on his work using the session command to simulate the use of incrementing global var’s in order to fully support CMP (related to a different post)

Naturally, it requires several lines to read the current value, expr + 1, and then update the value, as opposed to a one line “incr ::gvar”

Is it possible to create a function that is outside the irules that seek to use CMP compatible gvar incrementing? So rather than declaring the same class in every irule to address this or just doing it inline with a few lines, can something like a global function be saved that can be called from within any irule with the target simulated gvar handle?

Thanks

M

---

<div class="post-metadata">

**Author:** ![JRahm](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/jrahm/32/3327_2.png) [@JRahm](https://community.f5.com/u/JRahm)\
**Post date:** [April 25, 2011, 7:07pm UTC](https://community.f5.com/t/functions-for-simulating-cmp-friendly-global-vars/28982/2 "2011-04-25T19:07:13Z")

</div>

why not use table incr?

---

<div class="post-metadata">

**Author:** ![hoolio](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hoolio](https://community.f5.com/u/hoolio)\
**Post date:** [April 25, 2011, 7:43pm UTC](https://community.f5.com/t/functions-for-simulating-cmp-friendly-global-vars/28982/3 "2011-04-25T19:43:48Z")

</div>

Good idea Jason. That solution was written pre-subtables.

Matt, we’re hoping to see functions sometime soon in iRules. But for now, Jason’s suggestion should make this a simpler process.

Aaron

---

<div class="post-metadata">

**Author:** ![Colin\_Walker\_12](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@Colin\_Walker\_12](https://community.f5.com/u/Colin_Walker_12)\
**Post date:** [May 2, 2011, 5:25pm UTC](https://community.f5.com/t/functions-for-simulating-cmp-friendly-global-vars/28982/4 "2011-05-02T17:25:51Z")

</div>

Good call Jason, this is exactly what table incr was built for, last I checked. 😉

Matt: Let us know if you’ve got any more questions or if you need help getting this working.

Colin
