# Does the dial plan support arrays or multivalue variables?

**URL:** <https://community.asterisk.org/t/does-the-dial-plan-support-arrays-or-multivalue-variables/88170>\
**Category:** Asterisk Dialplan\
**Created:** [April 3, 2021, 9:29am UTC](https://community.asterisk.org/t/does-the-dial-plan-support-arrays-or-multivalue-variables/88170 "2021-04-03T09:29:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iforgetmyaccountofte](https://avatars.discourse-cdn.com/v4/letter/i/a9a28c/32.png) [@Iforgetmyaccountofte](https://community.asterisk.org/u/Iforgetmyaccountofte)\
**Post date:** [April 3, 2021, 9:29am UTC](https://community.asterisk.org/t/does-the-dial-plan-support-arrays-or-multivalue-variables/88170/1 "2021-04-03T09:29:35Z")

</div>

According to the wiki asterisk does have an array function however it appears to only be a shortcut for declaring multiple separate variables.  
[https://wiki.asterisk.org/wiki/display/AST/Function\_ARRAY](https://wiki.asterisk.org/wiki/display/AST/Function_ARRAY)  
Example:

`Set(ARRAY(var1,var2)=1,2) will set var1 to 1 and var2 to 2`

I’m looking for a way to preform logical operations on an entire set of variables, not just define multiple variables at once.

In short, I’m looking for a better way to write:

`same => n,GotoIf($[${var1} != 1] & $[${var2} != 1] & $[${var3} != 1] & $[${var4} != 1] ?label1:label2)`

I would like to be able to do:  
`same => n,GotoIf($[${contenceOfarrayName} != 1]?label1:label2)`  
But that does not work.

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [April 3, 2021, 10:07am UTC](https://community.asterisk.org/t/does-the-dial-plan-support-arrays-or-multivalue-variables/88170/2 "2021-04-03T10:07:17Z")

</div>

Not directly, but variable names are also subject to the same macro expansion as top level variables, so you can dynamically create a variable name.

---

<div class="post-metadata">

**Author:** ![sedwards](https://avatars.discourse-cdn.com/v4/letter/s/838e76/32.png) [@sedwards](https://community.asterisk.org/u/sedwards)\
**Post date:** [April 3, 2021, 4:54pm UTC](https://community.asterisk.org/t/does-the-dial-plan-support-arrays-or-multivalue-variables/88170/3 "2021-04-03T16:54:36Z")

</div>

Referencing my snippet from your [earlier post](https://community.asterisk.org/t/can-you-make-functions-within-the-dialplan/88135/11).

You could think of:

```auto
                        switch (${STEP-${IDX}-TYPE})

```

kind of like

```auto
typedef struct
        {
// ints
       	int active;
        int type;
// strings
        char data[256];
        char prompt[256];
        } STEP;

static STEP step[100];

        switch (step[idx].type)

```

But Asterisk really sees it as:

```auto
                        switch (${STEP-42-TYPE})

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/asterisk/original/2X/4/475d0c889911cfb84ac4881ad6df8b523e3f9105.png) [@system](https://community.asterisk.org/u/system)\
**Post date:** [May 3, 2021, 4:55pm UTC](https://community.asterisk.org/t/does-the-dial-plan-support-arrays-or-multivalue-variables/88170/4 "2021-05-03T16:55:05Z")

</div>

Closed on May 3, 2021, 4:55pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
