WMLScript Standard Libraries: The Lang Library - Part II | WebReference

WMLScript Standard Libraries: The Lang Library - Part II


WMLScript Standard Libraries

The Lang Library - Part II

These are the rest of the functions in the Lang library:

maxInt()

This function returns the maximum integer value.

SyntaxmaxInt()
Parametersnone
ReturnsInteger (2147483647)
Examples:var a = Lang.maxInt(); // a = 2147483647

minInt()

This function returns the minimum integer value.

SyntaxminInt()
Parametersnone
ReturnsInteger (-2147483648)
Examples:var a = Lang.minInt(); // a = -2147483648

float()

This function returns true if floating-point numbers are supported, and false otherwise. Note, some systems do not support floating-point numbers.

Syntaxfloat()
Parametersnone
ReturnsBoolean
Examples:var a = Lang.float();

exit()

This function ends the interpretation of the WMLScript bytecode and returns to its caller with a given return value. This function usually is used to perform a normal exit from a function in cases where the execution of the WMLScript bytecode should be terminated.

Syntaxexit(value)
Parametersvalue = Any
Returnsvalue
Examples:Lang.exit("Script Ends with " + result); // Returns a string
Lang.exit(invalid); // Returns invalid

abort()

This function aborts the interpretation of the WMLScript bytecode and returns to its caller with a given return message. This function usually is used to perform an abnormal exit from a function in cases where the execution of the WMLScript bytecode should be terminated. invalid is returned if the parameter is not a string value.

Syntaxabort(value)
Parametersvalue = String
Returnsvalue or invalid if value is not a string.
Examples:Lang.abort("Script aborts with " + result); // Returns a string
Lang.abort(invalid); // Returns invalid

random()

This function returns a random integer between 0 and the given parameter. If the given parameter is a floating-point number, it is first converted to an integer using Float.int().

Syntaxrandom(value)
Parametersvalue = Number
Returnsinteger, 0 if value = 0, invalid if value is less than 0 or not a number.
Examples:a = Lang.random(8.2); // a = 0..8
b = Lang.random("foobar"); // b = invalid

seed()

This function initializes the random number generator with the given parameter, and returns an empty string. If the given parameter is a floating-point number, it is first converted to an integer using Float.int(). If the given parameter is negative or not a number, system-dependent initialization is used.

Syntaxseed(value)
Parametersvalue = Number
Returnsinteger or invalid.
Examples:a = Lang.seed(8.2); // a = ""
b = Lang.seed("foobar"); // b = invalid (random seed left unchanged)

characterSet()

This function returns the character set supported by the WMLScript interpreter. The return value is an integer that denotes the character set.

SyntaxcharacterSet()
Parametersnone
Returnsinteger
Examples:a = characterSet(); // a = 1

Next: How to use Float library

http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

Created: June 5, 2000
Revised: June 5, 2000

URL: http://www.webreference.com/js/column63/3.html