Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Appendix C. Dialplan Functions

C. Dialplan Functions

In addition to dialplan applications, which have been part of Asterisk almost from the very beginning, Asterisk supports functions as of Asterisk 1.2. This is part of a long-standing effort to make Asterisk behave more like a programming environment. In contrast to applications, functions may not be called directly. Instead, they are called inside applications and return a value, or—in a departure from the classical definition of a function—they may even be written to using the application Set() (see Appendix B, “Dialplan Applications”). Function names are always written in uppercase letters. Surprisingly, functions are written in the same way as variables, inside curly braces and preceded by a $ character (${}). This is necessary because strings are not always bounded by quotation marks.

We could be forgiven for criticizing the less-than-intuitive distinction between Asterisk applications, functions, and even variables. Nor is there a consistently applied naming convention: for example, SIP_HEADER() is broken by an underscore (_) but SIPCHANINFO() is not. This is a problem with many programming languages and environments; these differences in convention add no useful information but make learning more difficult. In addition to this, the use of the delimiters—comma (,), ampersand (&), and pipe (|)—appears arbitrary. The concept of writing to a function in the same way one might write to a variable goes counter to the basic definition of a function in nearly every other programming language and continues to cause confusion, particularly among new Asterisk users with programming backgrounds.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint