# if else logic

**URL:** <https://community.f5.com/t/if-else-logic/40661>\
**Category:** Technical Forums\
**Tags:** dev, irules, devops, application-delivery\
**Created:** [March 19, 2009, 6:43pm UTC](https://community.f5.com/t/if-else-logic/40661 "2009-03-19T18:43:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![scott\_sams\_8256](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@scott\_sams\_8256](https://community.f5.com/u/scott_sams_8256)\
**Post date:** [March 19, 2009, 6:43pm UTC](https://community.f5.com/t/if-else-logic/40661/1 "2009-03-19T18:43:34Z")

</div>

i guess this isnt right.

can i get some help on my else if logic. have three conditions, three pools to check based on info in packet. thanks!

when CLIENT\_ACCEPTED {

TCP::collect 15

}

when CLIENT\_DATA {

if { [TCP::payload 15] contains “1” } {

pool 1

} elseif { [TCP::payload 15] contains “2” } {

pool 2

} else {

pool 3

TCP::release

}

---

<div class="post-metadata">

**Author:** ![scott\_sams\_8256](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@scott\_sams\_8256](https://community.f5.com/u/scott_sams_8256)\
**Post date:** [March 19, 2009, 6:54pm UTC](https://community.f5.com/t/if-else-logic/40661/2 "2009-03-19T18:54:35Z")

</div>

did i just miss the last bracket before TCP::release?

}

when CLIENT\_ACCEPTED {

TCP::collect 15

}

when CLIENT\_DATA {

if { [TCP::payload 15] contains “1” } {

pool 1

} elseif { [TCP::payload 15] contains “2” } {

pool 2

} else {

pool 3

}

TCP::release

}

---

<div class="post-metadata">

**Author:** ![lmwf1\_55268](https://avatars.discourse-cdn.com/v4/letter/l/c89c15/32.png) [@lmwf1\_55268](https://community.f5.com/u/lmwf1_55268)\
**Post date:** [March 19, 2009, 9:30pm UTC](https://community.f5.com/t/if-else-logic/40661/3 "2009-03-19T21:30:39Z")

</div>

The last one looks ok, and I was able to save it using iRule Editor.

---

<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:** [March 20, 2009, 9:52am UTC](https://community.f5.com/t/if-else-logic/40661/4 "2009-03-20T09:52:39Z")

</div>

Yeah, I think you would want to call TCP::release after the pool selection regardless of which condition is true, so the last version looks correct.

Aaron

---

<div class="post-metadata">

**Author:** ![scott\_sams\_8256](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@scott\_sams\_8256](https://community.f5.com/u/scott_sams_8256)\
**Post date:** [March 20, 2009, 10:14am UTC](https://community.f5.com/t/if-else-logic/40661/5 "2009-03-20T10:14:15Z")

</div>

thanks!
