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.
Syntax | maxInt() |
Parameters | none |
Returns | Integer (2147483647) |
Examples: | var a = Lang.maxInt(); // a = 2147483647 |
minInt()
This function returns the minimum integer value.
Syntax | minInt() |
Parameters | none |
Returns | Integer (-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.
Syntax | float() |
Parameters | none |
Returns | Boolean |
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.
Syntax | exit(value) |
Parameters | value = Any |
Returns | value |
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.
Syntax | abort(value) |
Parameters | value = String |
Returns | value 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()
.
Syntax | random(value) |
Parameters | value = Number |
Returns | integer, 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.
Syntax | seed(value) |
Parameters | value = Number |
Returns | integer 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.
Syntax | characterSet() |
Parameters | none |
Returns | integer |
Examples: | a = characterSet(); // a = 1 |
Next: How to use Float library
Produced by Yehuda Shiran and Tomer Shiran
Created: June 5, 2000
Revised: June 5, 2000
URL: https://www.webreference.com/js/column63/3.html