Presentation is loading. Please wait.

Presentation is loading. Please wait.

WML What is WML? WML stands for Wireless Markup Language. It is a mark-up language inherited from HTML, but WML is based on XML, so it is much stricter.

Similar presentations


Presentation on theme: "WML What is WML? WML stands for Wireless Markup Language. It is a mark-up language inherited from HTML, but WML is based on XML, so it is much stricter."— Presentation transcript:

1 WML What is WML? WML stands for Wireless Markup Language. It is a mark-up language inherited from HTML, but WML is based on XML, so it is much stricter than HTML. WML is used to create pages that can be displayed in a WAP browser. Pages in WML are called DECKS. Decks are constructed as a set of CARDS. What is WMLScript? WML uses WMLScript to run simple code on the client. WMLScript is a light JavaScript language. However, WML scripts are not embedded in the WML pages. WML pages only contains references to script URLs. WML scripts need to be compiled into byte code on a server before they can run in a WAP browser.

2 Prolog Every WML document starts with the prolog. The first line is the XML declaration and the second line is the DOCTYPE declaration. The prolog components are not WML elements and they should not be closed, i.e. you should not give them an end tag or finish them with />.

3 example hello.wml anchor tag line break Table previous taskprevious task select list font style Timer save variable

4 The tag The tag always has a task ("go", "prev", or "refresh") specified. The task defines what to do when the user selects the link.

5 The tag The tag always performs a "go" task, with no variables.

6 tag A WML card can be set up to display an image with this tag..wbmp is the only image type that can be displayed in a WAP browser

7 Example multiple selection input tag Image field set Template Onenterbackward onenterforward dotag

8 WMLScript Dialogs Library Functions FunctionDescription alert()alert() Displays a message and waits for a confirmation confirm()confirm() Displays a message and waits for an answer prompt()prompt() Displays a question and waits for an input

9 WMLScript Float Library Functions The Float library works only on clients that support floating-point numbers. If floating-point numbers are not supported, all functions should return invalid. FunctionDescription ceil(x) Returns the nearest integer that is not smaller than a specified numberceil(x) floor(x) Returns the nearest integer that is not larger than a specified numberfloor(x) int(x) Returns the integer part of a specified numberint(x) maxFloat()Returns the largest possible floating-point numbermaxFloat() minFloat()Returns the smallest possible floating-point numberminFloat() pow(x,y)Returns the value of x raised to the power of ypow(x,y) round(x)Rounds a number to the nearest integersqrt(x)Returns the square root of a numberround(x)sqrt(x)

10 WMLScript Lang Library Functions FunctionDescription abort() Aborts a WMLScript and returns a message to the caller of the scriptabort() abs(x) Returns the absolute value of a numberabs(x) characterSet() Returns the character-set supported by the WMLScript interpretercharacterSet() exit()Exits a WMLScript and returns a message to the caller of the scriptexit() float()Returns a Boolean value that indicates whether floating-point numbers are supportedfloat() isFloat()Returns a Boolean value that indicates whether a value can be converted into a floating-point number by the parseFloat() functionisFloat() isInt()Returns a Boolean value that indicates whether a value can be converted into an integer by the parseInt() functionisInt() max(x,y)Returns the number with the highest value of x and ymax(x,y) maxInt()Returns the maximum possible integer valuemaxInt() min(x,y)Returns the number with the lowest value of x and ymin(x,y) minInt()Returns the minimum possible integer valueminInt() parseFloat()Returns a floating-point value defined by a stringparseFloat() parseInt()Returns an integer defined by a stringparseInt() random(x)Returns a random integer between 0 and xrandom(x) seed()Initializes the random number generator with a number, and returns an empty stringseed()

11 WMLScript String Library Functions FunctionDescription charAt()Returns the character at a specified positioncharAt() compare()Compares two strings and returns a value that represents the result of the comparisoncompare() elementAt()Divides a string into elements and returns a specified elementelementAt() elements()Returns the number of times a specified value appears in a stringelements() find()Returns the position of a substring in a stringfind() format()Formats a valueformat() insertAt()Divides a string into elements and inserts a substring at a specified index positioninsertAt() isEmpty()Checks whether a string is emptyisEmpty() length()Returns the length of a stringlength() removeAt()Divides a string into elements and removes a specified elementremoveAt() replace()Replaces a part of a string with a new stringreplace() replaceAt()Divides a string into elements and replaces a specified elementreplaceAt() squeeze()Reduces all multiple spaces to single spaces in a stringsqueeze() subString()Returns a specified part of a stringsubString() toString()Converts a value to a stringtoString() trim()Returns a string without leading and trailing spacestrim()

12 WMLScript WMLBrowser Library Functions FunctionDescription getCurrentCard()Returns the (relative) URL of the current cardgetCurrentCard() getVar()Returns the value of a variablegetVar() go()Goes to a new cardgo() newContext()Clears all variablesnewContext() prev()Goes to the previous cardprev() refresh()Refreshes the current cardrefresh() setvar()Sets the value of a variablesetvar()

13 String library var char = String.charAt("WMLScript Tutorial", 0); After executing the above line of script, char contains the string value W.

14 Float library w = Float.round(10.4); x = Float.round(10.5); y = Float.round(-10.5); z = Float.round(10); After the execution of the above script, w has the integral value 10, x has the integral value 11, y has the integral value -10 and z has the integral value 10. w = Float.int(10.4); x = Float.int(10.5); y = Float.int(-10.5); z = Float.int(10); After the execution of the above script, w and x contain the integral value 10, y contains the integral value -10 and z contains the integral value 10.

15 Lang library Lang.seed(-1); var random_num1 = Lang.random(10); var random_num2 = Lang.random(99); After executing the above code, random_num1 contains an integer in the range 0 to 10 and random_num2 contains an integer in the range 0 to 99.

16 how to call WMLScript code in a WML document. Run WMLScript $(message)

17 WMLScript code extern function helloWorld() { WMLBrowser.setVar("message", "Hello World. Welcome to our WMLScript tutorial."); WMLBrowser.refresh(); }

18 Open the helloWorldEg1.wml file in a mobile phone browser and you can see something like this: Nokia mobile browser 4.0

19 Inside the helloWorld() function, we use two functions of the WMLBrowser standard library, setVar() and refresh(). The setVar() function is used to assign a value to a WML variable. WMLBrowser.setVar("message", "Hello World. Welcome to our WMLScript tutorial."); The refresh() function is used to instruct the WAP browser to refresh the current WML card. WMLBrowser.refresh(); to refresh the WML card so that the change made to the message variable is shown on the screen of the mobile device. To call the WMLScript function helloWorld() in the WML document, we use the URL below: helloWorldEg1.wmls#helloWorld()

20 A function in WMLScript is defined using the following format [extern] function function_name([argument1, argument2...]) { WMLScript statements here [return (some_value);] }

21 wmlscript_1.wmls file contains the following function wmlscript_function(): extern function wmlscript_function() { return "Welcome to our WMLScript tutorial"; }

22 To call wmlscript_function() from a WML card, create an anchor link using the following WML markup. The script will be executed if you click the anchor link. Execute Script Or Execute Script Another way to call wmlscript_function() in a WML card is to place the URL in a WML event handler. The script will be executed when the WML event occurs. The following markup instructs the WAP browser to call wmlscript_function() when the ontimer event is triggered: Four event types are supported in WML. They are ontimer, onenterbackward, onenterforward and onpick.

23 Passing Arguments to Functions Function called addition() that takes two numbers as its arguments: extern function addition(number1, number2) { WMLBrowser.setVar("message", number1 + number2); } To pass two integers 10 and 11 to addition(), use the following WML markup: Execute Script

24 Execute Script... When the WAP browser comes across the terms $(wmlVar1) and $(wmlVar2), it will substitute them with their stored value. So, the WML markup: Execute Script will become: Execute Script

25 WMLScript Example currency_wml currency_wmlscript validateform_wml validateform_wmlscript alert_wml alert_wmls pass by reference_wml pass by reference_wmls


Download ppt "WML What is WML? WML stands for Wireless Markup Language. It is a mark-up language inherited from HTML, but WML is based on XML, so it is much stricter."

Similar presentations


Ads by Google