|
List Info
Thread: extra parameter for DB read function
|
|
| extra parameter for DB read function |

|
2006-05-31 13:30:05 |
There are often times that I want to read a DB value from
the dialplan,
and if this family/key pair does not exist, set it to some
default value.
for example:
1234,1 => Set(EMAILADDR=${DB(x/y)}
1234,2 => GotoIf($["$" =
""]?3:4)
1234,3 => Set(EMAILADDR=Someone test.com)
1234,4 => NoOp($)
1234,5 => Hangup()
I have modified the db function to take an optional extra
parameter to
set if the key does not exist. So, the dialplan would now
look like:
1234,1 => Set(EMAILADDR=${DB(x/y/Someone test.com)}
1234,2 => NoOp($)
1234,3 => Hangup()
It's just a shortcut to acheive the same goal, but with
less lines in
the dialplan.
Now, I am *not* a C programmer, so I may have made some
horrendous
mistake or potential segfault, so is there someone who would
look at the
changes before I make a fool of myself and post the patch to
mantis ?
Much appreciated
Julian
_______________________________________________
--Bandwidth and Colocation provided by Easynews.com --
asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-dev
|
|
| extra parameter for DB read function |

|
2006-05-31 13:58:30 |
On Wed, 2006-05-31 at 14:30 +0100, Julian Lyndon-Smith
wrote:
> There are often times that I want to read a DB value
from the dialplan,
> and if this family/key pair does not exist, set it to
some default value.
>
> for example:
>
> 1234,1 => Set(EMAILADDR=${DB(x/y)}
> 1234,2 => GotoIf($["$" =
""]?3:4)
> 1234,3 => Set(EMAILADDR=Someone test.com)
> 1234,4 => NoOp($)
> 1234,5 => Hangup()
I hate to burst your bubble, but what's wrong with using
the DB_EXISTS
dialplan function?
exten => 1234,1,Set(EMAILADDR=
${IF($[${DB_EXISTS(x/y)}]?$:Someone test.com)})
Obviously it's a little harder to read (especially when all
placed on
one line), but it's already quite easy to use without
adding more code
to Asterisk.
-Jared
_______________________________________________
--Bandwidth and Colocation provided by Easynews.com --
asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-dev
|
|
| extra parameter for DB read function |

|
2006-05-31 14:00:34 |
Hey, no bubble to burst - I'm always up for finding an
easier way. I
didn't realise that just by checking the existence of a
pair it stored
it in a variable.
OTOH it *is* more yeuch to read. All of those $ { [ are
soooo easy to
misplace, and sooo easy to misread and not find the problem.
And it is only 3 more lines of code
if no-one wants the patch, I'm more than happy to go with
this method.
Thanks.
Julian.
Jarenessto wrote:
> On Wed, 2006-05-31 at 14:30 +0100, Julian Lyndon-Smith
wrote:
>> There are often times that I want to read a DB
value from the dialplan,
>> and if this family/key pair does not exist, set it
to some default value.
>>
>> for example:
>>
>> 1234,1 => Set(EMAILADDR=${DB(x/y)}
>> 1234,2 => GotoIf($["$" =
""]?3:4)
>> 1234,3 => Set(EMAILADDR=Someone test.com)
>> 1234,4 => NoOp($)
>> 1234,5 => Hangup()
>
> I hate to burst your bubble, but what's wrong with
using the DB_EXISTS
> dialplan function?
>
> exten => 1234,1,Set(EMAILADDR=
> ${IF($[${DB_EXISTS(x/y)}]?$:Someone test.com)})
>
> Obviously it's a little harder to read (especially
when all placed on
> one line), but it's already quite easy to use without
adding more code
> to Asterisk.
>
> -Jared
>
> _______________________________________________
> --Bandwidth and Colocation provided by Easynews.com --
>
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-dev
>
>
_______________________________________________
--Bandwidth and Colocation provided by Easynews.com --
asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-dev
|
|
[1-3]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|