Page 529 - Asterisk™: The Future of Telephony
P. 529

EVAL                                                     Evaluates stored variables
               EVAL(variable)

               EVAL() is one of the most powerful dialplan functions. It permits one to store variable
               expressions in a location other than extensions.conf, such as a database, yet evaluate
               them in the dialplan, as if they were included there all along. You can bet that EVAL()
               is a cornerstone in making a dialplan truly dynamic.
                   ; We might store something like "SIP/${DB(ext2chan/123)}" in the
                   ; database entry for extension/123, which tells us to look up yet
                   ; another database entry.
                   exten => _XXX,1,Set(dialline=${DB(extension/${EXTEN})})
                   exten => _XXX,n,Dial(${EVAL(${dialline})})
                   ; Real world example (taken from production code)
                   exten => _1NXXNXXXXXX,n(generic),Set(provider=${DB(rt2provider/${route})}-nanp)
                   exten => _1NXXNXXXXXX,n(provider),Dial(${EVAL(${DB(provider/${provider})})})
                   exten => _1NXXNXXXXXX,n,Goto(nextroute)

               See Also
               Exec()


               EXISTS                                                  Checks if value is non-blank
               EXISTS(data)

               Existence test: returns 1 if non-blank, 0 otherwise


               FIELDQTY                                                         Counts fields
               FIELDQTY(varname|delim)

               Counts the fields, with an arbitrary delimiter

               See Also
               CUT()


               FILTER                                               Strips string of illegal characters

               FILTER(allowed-chars|string)
               Filters the string to include only the characters shown in allowed-chars:

                   ; Ensure that the Caller*ID number contains only digits
                   exten => Set(CALLERID(num)=${FILTER(0123456789,${CALLERID(num)})})
               This function may only be read, not set.


                                                                               EVAL | 501
   524   525   526   527   528   529   530   531   532   533   534