Wireless markup language (WML) and WMLScript are programming languages that are used to provide information services to portable wireless devices. This book explains how and why companies use WML to develop and provide information services to mobile communication devices. WML protocols and scripts are used to create web pages.
more....
The <select>…</select> command is used to create selection lists. Options in the list are defined with the <option>…</option> command, or the <optgroup>…</optgroup> command. Each <select> tag has one or more <option> tags, or
The name attribute of the <select/> command is required and defines the name or identifier for the variable selected in the list. The value attribute is used to specify the default selection. When the user makes a choice, the value attribute of the <option/> command becomes the value assigned to the variable. In the case when the multiple attribute is set to true, the different variable values are separated by semicolons.
The iname attribute of the <select/> command defines an alternative name for the variable that receives the number of the selection made. So, if there are three options listed, and the third option is selected, the variable name specified by iname is set to 3. The ivalue attribute is the initial value used for the variable specified in the iname attribute. If both name and iname and value and ivalue are specified, the iname and ivalue are used instead of the name and value attributes.
The title attribute of the <select> command specifies the title that appears as the title of the selection list. The tabindex attribute specifies the order of the list elements with non-negative integers. This attribute is currently not supported in some of the browsers, such as Phone.com’s browser.
Example 4.5 shows the use of the <select> command with the name, iname, value and ivalue attributes. Since ivalue takes precedence over value, the screen in Figure 4.5 shows that the initial value of the variable is set to the value specified in ivalue, not value. On the first screen, the mode is set to “car” not “plane”. The second screen shows what is seen after pressing the “Select” button. And the third screen shows the display after choosing the second choice on the list and then pushing “OK”.
There are two actual methods for pushing messages down to a WAP device, push and pull. Before this chapter we have always thought of a model in which our WAP device requests a file from a server, and that server then delivers the data. This is called the pull method. The push method, on the other hand, uses the server to actually send data to the WAP device without any kind of request.
A pull notification relies on the WAP device to poll the server for new events and information. Therefore, based upon a device’s availability the message might wait at the WAP gateway until the message can be processed.
Figure 8.1 shows how push notification works with a WAP server. This example shows a WAP push proxy gateway that receives a message from a stock news information service that sends a message via the Internet when to a WAP client when a particular stock changes beyond a present limit. When the WAP push proxy gateway receives the message, it immediately alerts the WAP client of an incoming message. Because the WAP client has been setup to automatically receive these pushed messages, the WAP client acknowledges the request from the push sever and the message is delivered (pulled) from the push proxy gateway to the WAP client. This example shows that the information can be automatically displayed on the WAP client without the user having to do anything.
Mr. Routt is a communications product and technology expert and is the department head of Electronics Engineering Technology and Automation/Robotics technology at Wake Technical Community College. Mr. Routt has over 33 years of technical, research, design, development, and instruction experience. He has worked for leading companies including Bell Laboratories, DuPont, Modcomp, Siemens, Gould Computer, and several universities and colleges. Mr. Routt has been published in the Bell System Technical Journal and in the Bell Laboratories Record covering switching system technologies and telecommunications. He continually researches and develops software programs and creates courses on communications and technology automation. Mr. Routt holds many degrees and certificates including a MSEE from Carnegie Institute of Technology and a BSEE from the Pennsylvania State University.
WML Libraries
WMLScript is a client-side scripting language. For
reference, this appendix lists all functions supported by WMLScript. Please note
the following:
Like WML, WMLScript is
case-sensitive.
WMLScript functions are members of function libraries, and
function names are always specified as library.function (for example,
String.length()).
All functions and libraries listed here are supported on
all devices except where noted.
Strings may be enclosed within double quotes (as in
“string”) or single quotes (as in ‘string’).
WML Library List
Lang Library
Float Library
String Library
URL Library
WML Browser Library
Dialogs Library
Debug Library
Console Library
back to top
Lang
Library
The lang library contains functions closely related to the
WMLScript language core.
abort
Description: This function will interrupt the
processing of the WMLScript and return the value of errorDescription
(which must be a string) to the device.
Syntax:
Lang.abort(errorDesciption)
Example: The following example interrupts WMLScript
processing, and displays the error message:
// Compare passwords
if (password1!=password2) {
// Passwords
do not match
Lang.abort(“Passwords do not match!”);
}
Description: This function returns the absolute
value of a specified number. If value is of type floating point, then the result
is of type floating point. If value is not one of these types, then
“invalid” is returned.
Syntax: Lang.abs(value)
Example: The following example returns the absolute
value of the value of a specified variable:
// Get absolute value of a
var b=Lang.abs(a);
Description: The Internet Assigned Numbers Authority
(IANA) has assigned integer values for all character sets. CharacterSet returns
this value.
Syntax:
Lang.characterSet()
Example: The following example checks and returns
the character set supported by the WMLScript interpreter:
//Check character set
function charSetTest()
if (Lang.characterSet()==4)[
return
(“Western Europe!”);
} else {
return (“unkown”);
}
exit
Description: This will end the rendering of the
WMLScript code and present the string value. You can use this function to
normally exit your WMLS code where needed.
Syntax: Lang.exit(value)
Example: The following example exits the current
WMLScript and returns the specified string to the device:
// Check if okay to proceed, exit if not
if (!proceed){
Lang.exit(“Cannot
proceed as requested”);
}
float
Description: This function returns either true or
false. If floating points are supported, the result is true. Otherwise, the
result is false.
Syntax: Lang.float()
Example: The following example returns true if
floating points are supported by the WAP browser:
// Check if floating point is supported before continuing
if (!Lang.float()){
Lang.abort(“Cannot
perform calculation”);
}
Description: If value can be converted into a floating
point, this function returns true. Otherwise, the result is false.
Syntax:
Lang.isFloat(value)
Example: The following converts a floating point
number to its closest integer (if it is a floating number):
// Is “a” a float?
if (Lang.isFloat(a)){
// yes it is,
convert to integer
var b=Float.round(a);
}
isInt
Description: If value can be converted into a
integer, this function returns true. Otherwise, the result is false.
Syntax: Lang.isInt(value)
Example: The following example checks to see that a
specified value is an integer (and not a float); if it is not it prompts for the
value again.
// Is “a” an int?
if (!Lang.isInt(a)){
//prompt for
it again
a=Dialogs.prompt(“Please enter a valid integer value”,
“”);
}
max
Description: Evaluates two values and determines
which is the larger number. Whether the result is an integer or floating point
is determined by the type of value1 and value2.
Syntax:
Lang.max(value1,value2)
Example: The following example saves the greater of
two specified values:
// Get greater value
var a = Lang.max(var1,var2);
// Prompt for temperature and parse into a float
var temp=Lang.parseFloat(Dialogs.prompt(“Temperature:”,””));
parseInt
Description: Converts a
string to type integer.
Syntax:
Lang.parseInt(value)
Example: The following returns the house number
portion of an address:
//get house number
var house_num=Lang.parseInt(address1);
random
Description: Generates a random integer greater or
equal to 0 and less than or equal to a specified value.
Syntax:
Lang.random(value)
Example: The following example is a function that
will return a random number between 0 and 100:
// Return a random number between 0 and 100
function GetRandom(){
return
Lang.random(100;
}
seed
Description: This initializes a random numeric
sequence and also returns an empty string. If value is of type floating point,
then Float.int() should be used first to convert the value to an integer.
Syntax: Lang.seed(value)
Example: The following will initialize the random
numeric sequence based on the number 42:
//Initialize random sequence
Lang.seed(42);
Back to WML Library List
Float Library
The Float library contains
functions used to manipulate floating point numbers.
ceil
Description: This function returns the smallest
integer not less than the specified value.
Syntax: Float.ceil(value)
Example: The following example converts a floating
point number to the smallest integer value not less than itself:
// Convert to integer
var b=Float.ceil(a);
floor
Description: This function returns the largest
integer not greater than the specified value.
Syntax:
Float.floor(value)
Example: The following example converts a floating
point number to the largest integer value not greater than itself:
// Convert to integer
var b = Float.floor(a);
Description: Returns the
integer portion of floating point value.
Syntax: Float.int(value)
Example: The following example returns the integer
portion of a user-specified value:
// Extract integer portion
var b=Float.int(a);
maxFloat
Description: This will
return the largest supported floating point.
Syntax: Float.maxFloat()
Example: The following example initializes a
floating-point value to the highest supported value:
//Initialize to greatest possible value
var a=Float.maxFloat();
Description: This will
return the smallest supported floating point.
Syntax: Float.minFloat()
Example: The following example initializes a
floating point value to the smallest supported value:
// Initialize to smallest possible value
var a = Float.minFloat();
pow
Description: Returns the
value of a number raised to a specified power.
Syntax: Float.pow(value1,value2)
Example: The following example determines the cubed
value of a specified number:
// Determine the cubed value of a
var b=Float.pow(a,3);
Back to WML Library List
String Library
The String library contains a set of string functions. In
WMLScript, a string is essentially an array of characters, the first element of
which is at offset 0.
charAt
Description: Returns the
character at the specified position in a string.
Syntax:
String.charAt(string, index)
Example: The following example returns the first
letter of a user’s name:
// get initial
var initial=String.charAt(first_name,0);
Description: Compares two strings. Returns 1 if
first string is greater than the second string, 0 if both strings are the same,
or –1 if first string is less than the first string.
Syntax:
String.compare(string1,string2)
Example: The following example (part of a sorting
routine) compares two strings and switches them if the first is greater than the
second:
//Is a greater than b?
if (String.compare(a,b)) {
//yes, switch
a and b
a=b;
b=x;
}
Description: Returns the element found at a
specified location within a string (using a specified delimiter).
Syntax:
String.elementAt(string,index,seperator)
Example: The following example returns the first
word in a sentence:
// get first word
var first_word=String.elementAt(sentence,0,” “);
Example: The following example trims all leading and
trailing space from an email address:
// trim address
var email=String.trim(email);
Back to WML Library List
URL
Library
The URL library contains
functions used in URL manipulation.
escapeString
Description: Replaces special characters contained
in a string with hexadecimal equivalents.
Syntax:
URL.escapeString(string)
Example: The following example escapes a URL query
string:
// Escape query string
var qs=URL.escapeString(qs);
// Append to url
url=url+”?”+qs;
Description: Returns the
absolute URL path of the current WMLS file.
Syntax: URL.getBase()
Example: The following example displays the URL of
the script file being executed.
// Display file being executed
dialogs.alert(“Executing “+URL.getBase());
Back to WML Library List
WMLBrowser
Library
Back to WML Library List
Dialogs Library
Back to WML Library List
Debug Library
Back to WML Library List
Console Library