# TCL Switch command - test multiple variables

**URL:** <https://community.f5.com/t/tcl-switch-command-test-multiple-variables/19830>\
**Category:** Technical Forums\
**Tags:** big-ip, irules, application-delivery\
**Created:** [April 19, 2017, 2:46pm UTC](https://community.f5.com/t/tcl-switch-command-test-multiple-variables/19830 "2017-04-19T14:46:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_McShane\_23](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@Alex\_McShane\_23](https://community.f5.com/u/Alex_McShane_23)\
**Post date:** [April 19, 2017, 2:46pm UTC](https://community.f5.com/t/tcl-switch-command-test-multiple-variables/19830/1 "2017-04-19T14:46:13Z")

</div>

Hi -

I don’t think that the following is possible within the TCL language but I would love to be proven wrong

Can the Switch statement be coded to test multiple variables simultaneously?

Other languages can and it avoids complex nested IF/ELSE statements

For example, using logical “Case” terminology to illustrate the point:-

Case Var-A, Var-B

when “string-A1” and “string-B1”

do action-1

when “string-A2” and “string-B2”

do action-2

I cannot identify corresponding Switch syntax that can accommodate the above

Much appreciated

---

<div class="post-metadata">

**Author:** ![stan\_piron](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@stan\_piron](https://community.f5.com/u/stan_piron)\
**Post date:** [April 19, 2017, 4:36pm UTC](https://community.f5.com/t/tcl-switch-command-test-multiple-variables/19830/2 "2017-04-19T16:36:25Z")

</div>

Hi,

you can concatenate both variables like

```tcl
switch ${a}|${b} {
    "string-A1|string-B1" {
        DO ACTION 1
    }
    "string-A2|string-B2" {
        DO ACTION 2
    }
}

```
