<www.vxml.co.za>





<training>





<voicexml tutorial>















Advanced Programming

ECMA Scripting

This ECMA Standard is based on several originating technologies, the most well known being JavaScript (Netscape) and JScript (Microsoft). The language was invented by Brendan Eich at Netscape and first appeared in that company's Navigator 2.0 browser. It has appeared in all subsequent browsers from Netscape and in all browsers from Microsoft starting with Internet Explorer 3.0.

ECMAScript was originally designed to be a Web scripting language, providing a mechanism to enliven Web pages in browsers and to perform server computation as part of Web-based client-server architecture. ECMAScript allows for browser and server side scripting. Within the scope of this document the emphasis will be on browser side scripting (voice browser).

ECMAScript source text can contain any of the Unicode characters. All Unicode white space characters are treated as white space, and all Unicode line/paragraph separators are treated as line separators. Non-Latin Unicode characters are allowed in identifiers, string literals, regular expression literals and comments.

A scripting language is a programming language that is used to manipulate, customize, and automate the facilities of an existing system. In such systems, useful functionality is already available through a user interface, and the scripting language is a mechanism for exposing that functionality to program control. In this way, the existing system is said to provide a host environment of objects and facilities, which completes the capabilities of the scripting language. A scripting language is intended for use by both professional and nonprofessional programmers. To accommodate non-professional programmers, some aspects of the language may be somewhat less strict.

ECMAScript can provide core scripting capabilities for a variety of host environments, and therefore the core scripting language is specified in this document apart from any particular host environment.

Some of the facilities of ECMAScript are similar to those used in other programming languages; in particular Java and Self.

Comments can be either single or multi-line. Multi-line comments cannot nest.

Because a single-line comment can contain any character except a LineTerminator character, and because of the general rule that a token is always as long as possible, a single-line comment always consists of all characters from the // marker to the end of the line. However, the LineTerminator at the end of the line is not considered to be part of the single-line comment; it is recognised separately by the lexical grammar and becomes part of the stream of input elements for the syntactic grammar. This point is very important, because it implies that the presence or absence of single-line comments does not affect the process of automatic semicolon insertion.

Comments behave like white space and are discarded except that, if a MultiLineComment contains a line terminator character, then the entire comment is considered to be a LineTerminator for purposes of parsing by the syntactic grammar.

Standard ECMA-262 (3rd Edition, December 1999) can be downloaded free of charge at:
http://www.ecma-international.org/publications/standards/Ecma-262.htm


Arrays

For voice application developers from environments like State Tables, VXML seems initially to be deficient in the area of variable handling and storing. However, VoiceXML makes provision for the use of arrays which is very handy to group information together. Below is an example of an array of names, and depending on the option pressed by the caller, a fixed group of names are assigned to the array. Again a form is used to contain the array.





Loop

When using an array, it is imperative to be able to loop through the array, and handle the information per item. VoiceXML now offers the ability with version 2.1.

The most basic structure of this element is as follow:



An implementation, with relation to the example in section 4.2 would look as follow:





Now we can go to:
Host Interfacing








Copyright 2009 - Computer Assisted Telephony Systems (Pty) Ltd