Dialplan ARRAYS

From FreeSWITCH Wiki
Jump to: navigation, search

Contents

Introduction

The Dialplan ARRAYS were introduced during ClueCon 2011.

- Indexable
- Serializable
- Compatible with FreeSWITCH regular expressions

Appending to an ARRAY with PUSH

<action application="push" data"myvar,test A"/>
<action application="push" data"myvar,test B"/>
<action application="push" data"myvar,test C"/>

Prepending to an ARRAY with UNSHIFT

<action application="unshift" data="myvar,test X"/>
<action application="unshift" data="myvar,test Y"/>
<action application="unshift" data="myvar,test Z"/>

Setting a specific element

<action application="set" data="myvar[0]=Test A"/>
<action application="set" data="myvar[1]=Test B"/>
<action application="set" data="myvar[2]=Test C"/>

Are there limits to what the key value is? -Avi Marcus

Serializing an ARRAY

<action application="log" data="INFO ${myvar}"/>

produces:

ARRAY::test X|:test Y|:test Z|:test A|:test B|:test C

Referencing an ARRAY element

- ${myvar} (serialized)
- ${myvar[2]}

Capturing with REGEX

<action application="set" data="num=2121231234"/>
<action application="capture" data="myvar|${num}|(\d{3})(\d{3})(\d{4})"/>

Capture from ${num} and save the results into myvar.


DP_MATCH Special Variable

<extension name="arrays">
 <condition field="destination_number" expression="(\d{3})(\d{3})(\d{4})"/>
  <action application ="bridge" data="${DP_MATCH[1]}${DP_MATCH[2]}/>
 </condition>
</extension>

How is this any different than simply using $1, $2..? -Avi Marcus