R4R provide basic WMLScript Tutorials concept with WMLScript Examples .Through R4R you can develop WMLScript programming concept. R4R provide WMLScript Interview Questions with answers.R4R provide WMLScript Languages study materials in easy way.
The WMLScript language is part of the industry-wide standard for wireless applications called Wireless Application Protocol (WAP) .WMLScript (Wireless Markup Language Script) is the client-side scripting language of WML (Wireless Markup Language). WMLScript is work with WML pages. And WML pages can displayed on WAP browser. Using WMLScript we can validate user input, generate dialog boxes, view error messages, access facilities of the user agent etc.
A scripting language is similar to a programming language, but it is light weight. With WMLScript , the wireless device can do some of the processing and computation. This reduces the number of requests and responses to/from the server. In the old days, fewer round-trips can improve the performance of your WAP site significantly since data transmission over wireless networks is slow.
Today, the performance gained may not be so significant any more as data transmission speed has improved a lot. However, you may still find WMLScript useful since putting some operations at the client-side can reduce the load of your servers.
WMLScript is based on ECMAScript (European Computer Manufacturers Association Script), which is JavaScript's standardized version. So, the syntax of WMLScript is very similar to JavaScript. (In case you do not know, JavaScript is a scripting language commonly used on the web.) If you have some programming experience with JavaScript, you should be able to learn WMLScript quickly.
A most important difference between JavaScript and WMLScript is that JavaScript code can be embedded in the HTML markup, whereas WMLScript code is always placed in a file separated from the WML markup. URLs are used to refer to the actual WMLScript code in the WML document.
Feature | WMLScript | JavaScript |
Semicolons | Mandatory | Optional |
Supports HTML Comments | No | Yes |
Non-escape characters preceded by a backslash | No | Yes |
Names may include $ characters | No | Yes |
Supports global variables | Yes | Yes |
typeof returns | an integer | a string |
Supports arrays | No | Yes |
Supports objects | No | Yes |
WMLScript has a core group of six standard libraries. Each of the various libraries contains from three to seventeen functions that perform useful tasks related in concept to the library name.
- Lang Library
- Float Library
- String Library
- URL Library
- WMLBrowser Library
- Dialogs Library
- To check the legitimacy of user input
- To expand the functions of the user's browser, for example, allows programmers to develop mobile phone calls, send text messages, store phone numbers, phone book or SIM card management, etc.
- To generate the client confirmed that prompts a warning message or dialog box operation, and quickly displayed in the browser.
- Change the user's browser, the browser client to the software and the expansion and configuration parameters.
WMLScript functions or statements are not defined inside a WML page. Instead, all WMLScript language or statements are stored in another file with file extension .wmls (Wireless Markup Language Script).When your WML page calls a WMLScript function, you call the reference of the function by URL. When a function of WMLScript is called, the script is compiled into byte code by the WAP gateway and then sent to the micro-browser for interpretation.
<?xml version="1.0" ?> <!DOCTYPE wml PUBLIC " -//WAPFORUM//DTD WML 1.3//EN" "http://www.wapforum.org/DTD/wml_1.3.xml" > <wml> <card id="Line" title="First WMLScript" > <onevent type="onenterforward" > <go href="ashish.wmls#hello()" /> </onevent> <p> $message </p> </card> 11: </wml>
<go href="ex21-16.wmls#hello()" /> Example: ashish.wmls - WMLScript File For ashish.wml 1: extern function hello() 2: { 3: WMLBrowser.setVar( "message", 4: "Hello World! \n I know WMLScript now." ); 5: WMLBrowser.refresh(); 6: }
This WMLScript contains one function called hello(). The function is declared as extern (external) so that it can be called by other cards and applications.
WMLBrowser.refresh();This refresh() function from the WMLBrowser object is to refresh the WML page ashish.wml so that the message is displayed. A screen shot is shown in Fig.