Laynetworks  
Web laynetworks.com Google
Home | Site Map | Tell a friends
Management Tutorials
Download
Tutorials
History
Computer Science
Networking
OS - Linux and Unix
Source Code
Script & Languages
Protocols
Glossary
IGNOU
Quiz
About Us
Contact Us
Feedback
 
Sign up for our Email Newsletter
 
Get Paid for Your Tech Turorials / Tips

 

 

Home > Script & Languages > WML Script Reference
 
WML Script Reference
<< Back to Tutorial
Page : 1 2 3

URL

This library contains functions for the manipulation and validaton of URLs.

escapeString

Usage: escapeString(string)

Parameters: string – the string to be escaped

Returns: A string as the result of using normal URL escaping rules on the given string

Comments: URL escaping is the process of taking characters that are illegal or have special

Example: x = URL.escapeString(“The # character has to be escaped”);

// x is assigned “The %23 character has to be escaped”

getBase


Usage: getbase()

Parameters: None

Returns: The Current URL but without the details of the present WMLScript function

Comments: If you call some script using

http://www.companyname.com/testscript.wmls#function the base is http://www.companyname.com/testscript.wmls

Example: x = URL.getBase();

// x is assigned the current URL but without the details of the

// present WMLScript function

getFragment

Usage: getFragment(string)

Parameters: String – an URL

Returns: The fragment part of the URL given as the string parameter

Comments: The fragment part of a URL is the part following the # that is used determine the specific WMLScript function card

Example: x = URL.getFragment (“http://www.companyname.com/test.wml#main”)

GetHost

TOP

Usage: getHost ( string)

Parameters: string-an URL

Returns: The host part of the URL given as the string parameter

Comments: In a URL of the form http://www.companyname.com/testscript.wmls#function the host part is // x is assigned the value www.companyname.com

getPath

Usage: getPath (string)

Parameters: string-an URL

Returns: A string of the path from the URL.

Comments: The path is the location of the card on the current host

Example: x = URL.getPath(http://www.companyname.com/wqp/test.wml#main) ;

GetPort


Usage: getPort(string )

Parameters: string-an URL

Returns: A string of the path from the URL

Comments: The port number is given at the end of the domain and is separated from it by using a colon ( : ).

Example: x = URL.getPath(http://www.companyname.com:8080/test.wml#main);

//x is assigned the value “8080”

TOP

getQuery

Usage: getQuery(string)

Parameters: string – an URL

Returns: The query part of the URL as a string

Comments: The query part of a URL is placed at the end of a URL and its beginning is marked by a question mark (?), each aprameter assigned is separated with an ampersand (&).

Example: x=URL.getQuery

(http://www.companyname.com/test.wmls#main?x=10&y=43);

// x is assigned “x=10&y=43”

getReferer


Usage: get(Referer()

Parameters: None

Returns: The felative URL of the resource that called the current WMLScript

Comments: If there was no referrer, then the function returns an empty string(“”)

Example: x= URL.getReferer ()

// x is assigned a relative URL, to the resource that called the // oresbt WMLScript unit

getScheme


Usage: getScheme(string)

Parameters: string-an URL

Returns: The scheme as a string of the URL given as the string parameter

Comments: The scheme is the protocol given at the front of a URL

Example: x = URL.getScheme(http://www.companyname.com/test.wmls#main)

isValid


Usage: isValid (string)

Parameters: string-an URL

Returns: A Boolean indicating whether the URL given as the string parameter is in a valid form for a URL

Comments:

Example: x = URL.isValid(http://www.companyname.com/test.wmls#main);

// x is assigned the Boolean value true

loadString


Usage: loadString(url, type)

Parameters: url- a string representation of an URL Type- a string giving the MIME type of an URL If the document at the location given by the URL parameter is of the same type as the type parameter, then this document is retuned as a string- otherwise the function returns an integer to signal an error

Comments: The type of the URL to be loaded as a string must be a text type, i.e. the MIME type must start “text/”

Example: x = URL.loadString

(http://www.companyname.com/test.wml, “text/vnd.wap.wml”) ;

resolve

TOP

Usage: resolve(base, relative)

Parameters: base-a string representing a base URL Relative-a string representing a relative path to a resource

Returns: The result of embedding the relative URL into the base URL

Comments:

Example: x = URL.resolve

(http://www.company.com, “test.wml”) ;

unescapeString

Usage: unescapeString(string)

Parameters: string-the string that is to be unescaped

Returns: A string as a result of applying unescaping rules to the strung given as a parameter

Comments: The process of unescaping involves finding escape codes, which are of the form %xx(where xx is the number representing a character),and converting them back to their actual characters

Example: x = URL.unescapeString (“The %23 character has been unescaped”) ;

// x is assigned “The # character has been unescaped”

WMLBrowser


The WMLBrowser library contains functions for controlling the WMLBrowser. These functions have an effect when the script has finished executing and returns control back to the WMLBrowser.

GetCurrentCard


Usage: getCurrentCard( )

Parameters: None

Returns: A string giving a relative URL to the card that is presently being displayed by the browser

Comments:

Example: x = WMLBrowser.getCurrentCard ( )

// x is assigned a string that gives a relative URL to the card

// currently being displayed

getVar


Usage: getVar(variable)

Parameters: variable-a string containing the name of a WML variable

Returns: The value of the WML variable whose name is given as a parameter

Comments: If the variable doesn’t exist then an empty string.(“”) is returned

Example: x = WMLBrowser.getVar(“wmlVar1”) ;

// x is assigned the value of the WML variable with name wmlVari

go


Usage: go(string)

Parameters: string-an URL

Returns: An empty string(“”)

Comments: When the execution of the current script finishes and control is returned to the browser, the card at the location given in the string parameter will be loaded by the browser

TOP

Example: WMLBrowser.go

(http://www.company.com/test.wml#main);

//When the present script has finished executing, the card at the // location http://www.company.com/test.wml#main will be loaded

newContext


Usage: newContext()

Parameters: None

Returns: An empty string (“”)

Comments: This function clears the history stack and all WML variables; it has the same effect as using the newcontext+”true” attribute in a WML <card> element

Example: WMLBrowser.cewContext ( );

// When control is returned to the WML browse all WML variables // have been destroyed and the history lost

prev


Usage: prev()

Parameters: None

Returns: An empty string (“”)

Comments: When returning control to the browser, the prev task will be called.This will cause the browser to return to the previous card

Example: WMLBrowser.prev();

// when control returns to the browser, the previous card will be // displayed

refresh

Usage: refresh()

Parameters: None

Returns: An empty string(“”)

Comments: When returning control to the browser, the refresh task will be called. This will cause the some WLM variables that have been altered in the script

Example: EMLBrowser.refresh();

// when returning to the browser, the display will be refreshed

setVar


Usage: setVar(variable, value)

Parameters: variable-the name of a WML variable

Value – the new value to assign to the WML variable

Returns: A Boolean, true if it succeeds, false otherwise

Comments: This function sets the value of the WML variable, named in the variable parameter, to the value given as the value parameter-if the value is not a string then it is converted to string first.

Example: WMLBrowser.setVar(“WMLvar1”, 12);

// The WML variable WMLvar1 is assigned the string “12"

TOP
 
Page : 1 2 3
 
Donation | Useful links | Link to Laynetworks.com | Legal | SharePoint Development
Copyright © 2000-2010 Lay Networks All rights reserved.