Are you planning to change this at runtime? I seem to remember a post on the mailing list from very long time ago (years) changing global variables that were being read at the same time had a small risk of a race condition that might segfault.
Answered my own question:
In your dialplan:
<action application="lua" data="script.lua"/>
In script.lua:
mode = freeswitch.getGlobalVariable("mode")
if (mode == "open") then
session:speak("open")
end
if (mode == "techonly") then
session:speak("teck only")
end
if (mode == "event") then
session:speak("event")
else
session:speak("i dont know")
end
Make sure the global is created somewhere, like vars.xml:
<X-PRE-PROCESS cmd="set" data="mode=open"/>
On 06/07/2016 08:50 AM, Pete Ashdown wrote:
> What is the simplest way to have a conditional branch based on a global
> variable in a dialplan? Actually using a global variable and xml is
> giving me mixed results. Do I need to use Lua or another scripting
> language?
>
> This is what I have, which doesn't give the results desired. The
> "speak" actions are merely debug placeholders. I know there are better
> ways to do conditional voice to text.
>
> <condition regex="any" field="${cond(${mode} == 'open' ? YES :
> NO)}" expression="^YES$">
> <action application="speak" data="open"/>
> </condition>
>
> <condition regex="any" field="${cond(${mode} == 'tech only' ? YES
> : NO)}" expression="^YES$">
> <action application="speak" data="teck only"/>
> </condition>
>
> <condition regex="any" field="${cond(${mode} == 'event' ? YES :
> NO)}" expression="^YES$">
> <action application="speak" data="event"/>
> </condition>
>
_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org
http://www.freeswitchsolutions.com
Official FreeSWITCH Sites
http://www.freeswitch.org
http://confluence.freeswitch.org
http://www.cluecon.com
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org