[asterisk-users] Check if a variable is set

Ishfaq Malik ish at pack-net.co.uk
Fri Oct 16 09:08:03 CDT 2009


Hi

Here it is

[macro-extcall]
;Macro created by Ish to handle external national calls
exten => s,1,Set(CALLERID(all)=${ARG2})
exten => s,2,ExecIf(${ARG3}=1|Monitor|My monitor arguments)
exten => s,3,Dial(SIP/44${ARG1}@carrier,45)
exten => s,4,Hangup

Execution id Macro(extcall|Dialled Number|Caller CLI)

Now to enable monitoring for an outgoing line it would be

Macro(extcall|Dialled Number|Caller CLI|1)

But I have 79 of these in the system already with just the 2 arguments and we use realtime so they are all in a DB rather than text file so I'd rather not go through all the existing ones and change them to

Macro(extcall|Dialled Number|Caller CLI|0)

If I don't have to.

Also, I don't like getting bested by machines!

Ish


Darrin Henshaw wrote:
> Mind posting the macro itself? I think we might need to store the
> return value of isnull then test with execif.
>
> On 16/10/2009, Ishfaq Malik <ish at pack-net.co.uk> wrote:
>   
>> That fails to execute in both conditions
>>
>> ABBAS SHAKEEL wrote:
>>     
>>> Please try this
>>>
>>> xten => s,2,ExecIf( 0EXISTS(${ARG3})=1 & 0${ARG3}=1|
>>>
>>> On Fri, Oct 16, 2009 at 3:45 PM, Ishfaq Malik <ish at pack-net.co.uk
>>> <mailto:ish at pack-net.co.uk>> wrote:
>>>
>>>     I'm basically trying to make an argument optional in a macro, I'm
>>>     starting to think it's not possible
>>>
>>>     If I do this in my macro
>>>     exten => s,2,ExecIf(EXISTS(${ARG3})=1 & ${ARG3}=1|<whatever I want
>>>     to do>
>>>
>>>     I see this in the console
>>>     Executing [s at macro-extcall:2] ExecIf("SIP/PACK501-08222428",
>>>     "EXISTS()=1
>>>     & =1|<whatever I want to do>
>>>
>>>     As I didn't pass a third argument.
>>>
>>>     Essentially, what I'm trying to do in php terms would be this
>>>     if(isset($var) && $var==1)
>>>
>>>     Ish
>>>
>>>     ABBAS SHAKEEL wrote:
>>>     > Sorry its macro I called it a function.
>>>     >
>>>     > This link will be helpful to you
>>>     > http://www.voip-info.org/wiki/index.php?page=Asterisk+variables
>>>     >
>>>     >
>>>     > On Fri, Oct 16, 2009 at 3:13 PM, ABBAS SHAKEEL
>>>     > <shakeel.abbas.qau at gmail.com
>>>     <mailto:shakeel.abbas.qau at gmail.com>
>>>     <mailto:shakeel.abbas.qau at gmail.com
>>>     <mailto:shakeel.abbas.qau at gmail.com>>> wrote:
>>>     >
>>>     >     If you want to check in Console then NOOP can be used .
>>>     >     if in case of function call you can check its length if there
>>>     >     exists some thing
>>>     >
>>>     >
>>>     >     On Fri, Oct 16, 2009 at 3:04 PM, Ishfaq Malik
>>>     <ish at pack-net.co.uk <mailto:ish at pack-net.co.uk>
>>>     >     <mailto:ish at pack-net.co.uk <mailto:ish at pack-net.co.uk>>> wrote:
>>>     >
>>>     >         Hi
>>>     >
>>>     >         Is there any way to check if a variable is set in asterisk?
>>>     >         I've had a
>>>     >         look around and can't find a purpose built function for it.
>>>     >
>>>     >         I'm going to be using it to see if an argument has been
>>>     passed
>>>     >         with a
>>>     >         macro or not (e.g. see if ${ARG3} is set or not)
>>>     >
>>>     >         Thanks in advance
>>>     >
>>>     >         Ish
>>>     >         --
>>>     >         Ishfaq Malik
>>>     >         Software Developer
>>>     >         PackNet Ltd
>>>     >
>>>     >         Office:   0161 660 3062
>>>     >
>>>     >         _______________________________________________
>>>     >         -- Bandwidth and Colocation Provided by
>>>     >         http://www.api-digital.com --
>>>     >
>>>     >         AstriCon 2009 - October 13 - 15 Phoenix, Arizona
>>>     >         Register Now: http://www.astricon.net
>>>     >
>>>     >         asterisk-users mailing list
>>>     >         To UNSUBSCRIBE or update options visit:
>>>     >           http://lists.digium.com/mailman/listinfo/asterisk-users
>>>     >
>>>     >
>>>     >
>>>     >
>>>     >     --
>>>     >     Best Regards
>>>     >     Shakeel Abbas
>>>     >
>>>     >
>>>     >
>>>     >
>>>     > --
>>>     > Best Regards
>>>     > Shakeel Abbas
>>>     >
>>>     >
>>>
>>> ------------------------------------------------------------------------
>>>     >
>>>     > _______________________________________________
>>>     > -- Bandwidth and Colocation Provided by
>>>     http://www.api-digital.com --
>>>     >
>>>     > AstriCon 2009 - October 13 - 15 Phoenix, Arizona
>>>     > Register Now: http://www.astricon.net
>>>     >
>>>     > asterisk-users mailing list
>>>     > To UNSUBSCRIBE or update options visit:
>>>     >    http://lists.digium.com/mailman/listinfo/asterisk-users
>>>
>>>     --
>>>     Ishfaq Malik
>>>     Software Developer
>>>     PackNet Ltd
>>>
>>>     Office:   0161 660 3062
>>>
>>>     _______________________________________________
>>>     -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>>>
>>>     AstriCon 2009 - October 13 - 15 Phoenix, Arizona
>>>     Register Now: http://www.astricon.net
>>>
>>>     asterisk-users mailing list
>>>     To UNSUBSCRIBE or update options visit:
>>>       http://lists.digium.com/mailman/listinfo/asterisk-users
>>>
>>>
>>>
>>>
>>> --
>>> Best Regards
>>> Shakeel Abbas
>>>
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>>>
>>> AstriCon 2009 - October 13 - 15 Phoenix, Arizona
>>> Register Now: http://www.astricon.net
>>>
>>> asterisk-users mailing list
>>> To UNSUBSCRIBE or update options visit:
>>>    http://lists.digium.com/mailman/listinfo/asterisk-users
>>>       
>> --
>> Ishfaq Malik
>> Software Developer
>> PackNet Ltd
>>
>> Office:   0161 660 3062
>>
>> _______________________________________________
>> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>>
>> AstriCon 2009 - October 13 - 15 Phoenix, Arizona
>> Register Now: http://www.astricon.net
>>
>> asterisk-users mailing list
>> To UNSUBSCRIBE or update options visit:
>>    http://lists.digium.com/mailman/listinfo/asterisk-users
>>
>>     
>
>   

-- 
Ishfaq Malik
Software Developer
PackNet Ltd

Office:   0161 660 3062



More information about the asterisk-users mailing list