Download presentation
Presentation is loading. Please wait.
Published byJewel Gibson Modified over 9 years ago
1
2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 23 - Wireless Internet and m- Business Outline 23.1 Introduction 23.2 M-Business 23.3 Identifying User Location 23.3.1 E911 Act 23.3.2 Location-Identification Technologies 23.4 Wireless Marketing, Advertising and Promotions 23.5 Wireless Payment Options 23.6 Privacy and the Wireless Internet 23.7 International Wireless Communications 23.8 Wireless-Communications Technologies 23.9 WAP and WML 23.10 Phone Simulator and Setup Instructions 23.11 Creating WML Documents 23.12 WMLScript Programming 23.13 String Object Methods
2
2001 Prentice Hall, Inc. All rights reserved. 2 Chapter 23 - Wireless Internet and m- Business Outline 23.14 Wireless Protocols, Platforms and Programming Languages 23.14.1WAP 2.0 23.14.2 Handheld Devices Markup Languages (HDML) 23.14.3 Compact HTML (cHTML) and i-mode 23.14.4 Java and Java 2 Micro Edition (J2ME) 23.14.5 Binary Run-Time Environment for Wireless (BREW) 23.14.6 Bluetooth Wireless Technology 23.15 Internet and World Wide Web Resources
3
2001 Prentice Hall, Inc. All rights reserved. 3 23.4 Wireless Marketing, Advertising and Promotions
4
2001 Prentice Hall, Inc. All rights reserved. Outline 4 Fig23_2.wml 1 2<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" 3 "http://www.wapforum.org/DTD/wml12.dtd"> 4 5 6 7 8 9 10 11 Welcome to wireless programming! 12 13 14 This text will be displayed in the browser window.
5
2001 Prentice Hall, Inc. All rights reserved. Outline 5 Program Output
6
2001 Prentice Hall, Inc. All rights reserved. Outline 6 Program Output
7
2001 Prentice Hall, Inc. All rights reserved. 7 23.11 Creating WML Documents Fig. 23.3 Phone Information window showing an error in the deck. List of errors in deck.
8
2001 Prentice Hall, Inc. All rights reserved. Outline 8 Fig23_4.wml 1 2<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" 3 "http://www.wapforum.org/DTD/wml12.dtd"> 4 5 6 7 8 9 10 11 Local Icons 12 13 14 15 16 17 18 Link 19 20 21 22 23 Wrench 24 25 26 27 28 Football 29 30 31 32 Boat 33 34 The text Link is a link to card2.The text Wrench is a link to card3.The text Football is a link to card4 in fig23_5.wml. The boat local icon is a link to card5 in fig23_5.wml.
9
2001 Prentice Hall, Inc. All rights reserved. Outline 9 Fig23_4.wml 35 36 37 38 You chose the link! 39 40 41 42 43 44 You chose the wrench! 45 46 47 Result of choosing the link icon. Result of choosing the wrench icon.
10
2001 Prentice Hall, Inc. All rights reserved. Outline 10 Fig23_5.wml 1 2<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" 3 "http://www.wapforum.org/DTD/wml12.dtd"> 4 5 6 7 8 9 10 11 You chose the football! 12 13 14 15 16 17 You chose the boat! 18 19 20 Result of choosing the football link. Result choosing the boat link.
11
2001 Prentice Hall, Inc. All rights reserved. Outline 11 Program Output
12
2001 Prentice Hall, Inc. All rights reserved. Outline 12 WelcomeDoc.wmls 1// Fig. 23.6: welcomeDoc.wmls 2// Writing a line of text 3 4extern function welcome() 5{ 6 // creating a browser variable and assigning it a value 7 WMLBrowser.setVar( "welcome", 8 "Welcome to WMLScript programming!" ); 9 10 // refresh the display window 11 WMLBrowser.refresh(); 12} Method setVar creates a browser variable welcome with the value of the string “Welcome to WMLScript programming”. Method refresh refreshes the browser and all variable values.
13
2001 Prentice Hall, Inc. All rights reserved. Outline 13 Fig23_7.wml 1 2<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" 3 "http://www.wapforum.org/DTD/wml12.dtd"> 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 $welcome 20 21 22 Dereferencing browser variable welcome displays its value.
14
2001 Prentice Hall, Inc. All rights reserved. Outline 14 Program Output
15
2001 Prentice Hall, Inc. All rights reserved. Outline 15 DialogPrompt.wml s 1// Fig. 23.8: dialogPrompt.wmls 2// Printing multiple lines in a dialog 3 4extern function displayDialog() 5{ 6 Dialogs.alert( "Welcome to\nWMLScript\nProgramming!" ); 7} The alert method displays the string passed to it in a dialog box. Each line break character places the remaining text on the next line in the browser.
16
2001 Prentice Hall, Inc. All rights reserved. Outline 16 Fig23_9.wml 1 2<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" 3 "http://www.wapforum.org/DTD/wml12.dtd"> 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 Setting the type attribute to onenterforward causes the action of the go element to be executed when the card is entered. When the cars is entered, function displayDialog will be called.
17
2001 Prentice Hall, Inc. All rights reserved. Outline 17 Program Output
18
2001 Prentice Hall, Inc. All rights reserved. Outline 18 SquareNumbers.wm ls 1// Fig. 23.10: squareNumbers.wmls 2// Programmer-defined functions 3 4extern function count() 5{ 6 // prompt the user for a number 7 var inputNumber = Dialogs.prompt( 8 "Enter a number to be squared", "" ); 9 10 // convert the number to an integer and pass 11 // the number to function square 12 var numberSquared = square( Lang.parseInt( inputNumber ) ); 13 14 var outputSquare = inputNumber + " squared is " + 15 numberSquared; 16 17 // set the string to a browser variable and 18 // redirect the client to the card named result 19 WMLBrowser.setVar( "result1", outputSquare ); 20 WMLBrowser.go( "#result" ); 21} 22 23function square( y ) 24{ 25 return y * y; 26} Method prompt displays a dialog box that displays a message and an input field. The first argument passed to method prompt is the message that is displayed in the dialog. The second argument passed to methos prompt is the default value for the input field Call function square and pass it the value input by the user. Variable y gets the value of inputNumber.
19
2001 Prentice Hall, Inc. All rights reserved. Outline 19 Fig23_11.wml 1 2<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" 3 "http://www.wapforum.org/DTD/wml12.dtd"> 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Press OK to square a number. 18 19 20 21 22 23 24 25 26 27 28 29 $result1 30 31 32 This soft key calls function count when pressed. The prev element sends the client back to the previous card. Dereferencing variable result displays the result of the calculation.
20
2001 Prentice Hall, Inc. All rights reserved. Outline 20 Program Output
21
2001 Prentice Hall, Inc. All rights reserved. Outline 21 GetVariable.wmls 1// Fig. 23.12: getVariable.wmls 2// Using the WMLBrowser object’s getVar method 3 4extern function getName() 5{ 6 var x = WMLBrowser.getVar( "username" ); 7 var y = x + ", thanks for visiting!"; 8 9 WMLBrowser.setVar( "result", y ); 10 WMLBrowser.go( "#card2" ); 11} Method getVar retrieves the value of browser variable username. The + operator concatenates the value of x and the string “, thanks for visiting”.
22
2001 Prentice Hall, Inc. All rights reserved. Outline 22 GetVar.wml 1 2<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" 3 "http://www.wapforum.org/DTD/wml12.dtd"> 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Enter your name: 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 This soft key calls function getName when pressed. This input field allows the user to enter a username. This soft key sends the client to the previous card.
23
2001 Prentice Hall, Inc. All rights reserved. Outline 23 GetVar.wml Program Output 34 35 $result 36 37 38 Dereferencing browser variable result displays the results of the script.
24
2001 Prentice Hall, Inc. All rights reserved. Outline 24 FunctionSet.wmls 1// Fig. 23.14: functionSet.wmls 2// Demonstrating String object methods 3 4extern function stringMethods() 5{ 6 var string1 = ""; 7 var empty; 8 9 // test if string1 is empty 10 if ( String.isEmpty( string1 ) ) 11 empty = "string1 is empty"; 12 else 13 empty = "string1 is not empty"; 14 15 WMLBrowser.setVar( "emptyString1", empty ); 16 17 // format the string to have 12 spaces between 18 // "Wireless" and "Web" 19 string1 = String.format( "Wireless%15s", "Web" ); 20 21 WMLBrowser.setVar( "formatString1", string1 ); 22 23 // squeeze the string until one space is left 24 string1 = String.squeeze( string1 ); 25 26 WMLBrowser.setVar( "squeezeString1", string1 ); 27 28 // use method element to count the elements in string1 29 // use the toString method to convert the integer to 30 // a string 31 var count = String.toString( String.elements( string1, " ") ); 32 33 WMLBrowser.setVar( "elementsString1", count ); 34 The value of variable string1 begins as an empty string. Method isEmpty determines if the string is empty and returns true if it is. After invoking the format method, the value of string1 will be “Wireless Web” with 12 spaces separating the two words. Method squeeze eliminates all consecutive whitespace leaving one space between Wireless and Web. Method elements determines the amount of elements in a string separated by a space (the second argument). Method toString converts the integer value returns by method elements to a string.
25
2001 Prentice Hall, Inc. All rights reserved. Outline 25 FunctionSet.wmls 35 // find string starting at index 8 and ending with a space 36 var string1Element = String.elementAt( string1, 8, " " ); 37 38 WMLBrowser.setVar( "elementAtString1", string1Element ); 39 40 // get the length of string1 41 var length = String.length( string1 ); 42 43 // insert "Book" at the end of string1 44 string1 = String.insertAt( string1, "Book", length, " " ); 45 46 WMLBrowser.setVar( "insertAtString1", string1 ); 47 48 // replace "Web" with "Deitel" where "Web" has an 49 // index of 1 50 string1 = String.replaceAt( string1, "Deitel", 1, " " ); 51 52 WMLBrowser.setVar( "replaceAtString1", string1 ); 53 54 // remove "Wireless" from string1 55 string1 = String.removeAt( string1, 0, " " ); 56 57 WMLBrowser.setVar( "removeAtString1", string1 ); 58 WMLBrowser.go( "#card2" ); 59} Method elementAt will return a substring from the value of string1 starting at index 8 and ending at a space. Method length returns the number of characters in string1 as an integer. Method replaceAt removes “Web” from string1 and replaces it with the string “Deitel” ( Wireless Deitel Book ). Method insertAt inserts the string “Book” at the end of the value of string1 ( Wireless Web Book ). Method removeAt removes the string “Wireless” from the value of string1 leaving “Deitel Book”.
26
2001 Prentice Hall, Inc. All rights reserved. Outline 26 StringMisc.wml 1 2<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" 3 "http://www.wapforum.org/DTD/wml12.dtd"> 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Click Run to execute the script. 20 21 22 23 24 25 26 27 28 29 30 31
27
2001 Prentice Hall, Inc. All rights reserved. Outline 27 StringMisc.wml 32 33 isEmpty method: 34 35 36 $emptyString1 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 String.format method: 52 53 54 $formatString1 55 56 57 58 59 60 61 62 63 64 65 Display results of invoking method isEmpty. Display result of invoking method format.
28
2001 Prentice Hall, Inc. All rights reserved. Outline 28 StringMisc.wml 66 67 String.squeeze method: 68 69 70 $squeezeString1 71 72 73 74 75 76 77 78 79 80 81 82 83 84 String.elements method: 85 86 87 $elementsString1 88 89 90 91 92 93 94 95 96 97 98 Display results of invoking method squeeze. Display result of invoking method elements.
29
2001 Prentice Hall, Inc. All rights reserved. Outline 29 StringMisc.wml 99 100 String.elementAt method: 101 102 103 $elementAtString1 104 105 106 107 108 109 110 111 112 113 114 115 116 String.insertAt method: 117 118 119 $insertAtString1 120 121 122 123 124 125 126 127 128 129 130 Display results of invoking method elementAt. Display result of invoking method insertAt.
30
2001 Prentice Hall, Inc. All rights reserved. Outline 30 StringMisc.wml 131 132 String.replaceAt method: 133 134 135 $replaceAtString1 136 137 138 139 140 141 142 143 144 145 146 147 String.removeAt method: 148 149 150 $removeAtString1 151 152 153 Display results of invoking method replaceAt. Display result of invoking method removeAt.
31
2001 Prentice Hall, Inc. All rights reserved. Outline 31 Program Output
32
2001 Prentice Hall, Inc. All rights reserved. Outline 32 Program Output
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.