|
WMLScript
Quick Reference: Functions in the Lang Standard Library
|
abort(message)
Ends
the execution of WMLScript, and returns message and control
to the WML browser. It is used for abnormal exit.
Example:
Lang.abort("Error
code 110");
|
abs(numeric_value)
Calculates
the absolute value of numeric_value.
Example:
var
x = Lang.abs(-10.44); var y = Lang.abs(-10);
x
has the floating-point value 10.44. y
has the integral value 10.
|
characterSet()
Returns
a MIBEnum value from IANA that represents the character set
supported by the WMLScript interpreter. The MIBEnum value of
character sets can be found at
http://www.iana.org/assignments/character-sets.
|
exit(value)
Ends
the execution of WMLScript, and returns value and control
to the WML browser. It is used for normal exit.
Example:
Lang.exit(0);
Lang.exit("OK");
|
float()
Returns
a Boolean value that tells whether floating-point numbers are
supported.
|
isFloat(string)
Returns
a Boolean value that tells whether the conversion of string
into a floating-point number is possible.
Example:
var
toFloatOK1 = Lang.isFloat("23.21"); var toFloatOK2 =
Lang.isFloat("WMLScript Reference");
toFloatOK1
has the Boolean value true. toFloatOK2
has the Boolean value false.
|
isInt(string)
Returns
a Boolean value that tells whether conversion of string
into an integer is possible.
Example:
var
toIntegerOK1 = Lang.isInt("22"); var toIntegerOK2 =
Lang.isInt("WMLScript Reference");
toIntegerOK1
has the Boolean value true. toIntegerOK2
has the Boolean value false.
|
max(numeric_value1,
numeric_value2)
Returns
numeric_value2 if numeric_value2 is greater than
numeric_value1. Otherwise returns numeric_value1.
Example:
var
larger_number1 = Lang.max(10.5, 100); var larger_number2 =
Lang.max(10.5, 5.23);
Example:
larger_number1
has the integral value 100. larger_number2
has the floating-point value 10.5.
|
maxInt()
Returns
the largest integer that can be represented, which should be
2147483647.
|
min(numeric_value1,
numeric_value2)
Returns
numeric_value2 if numeric_value2 is smaller than
numeric_value1. Otherwise returns numeric_value1.
Example:
var
smaller_number1 = Lang.min(10, 100.5); var smaller_number2 =
Lang.min(10.5, 5.23);
Example:
smaller_number1
has the integral value 10. smaller_number2
has the floating-point value 5.23.
|
minInt()
Returns
the smallest integer that can be represented, which should be
-2147483648.
|
parseFloat(string)
Converts
string to a floating-point number.
Example:
var
float_number1 = Lang.parseFloat("1.22"); var
float_number2 = Lang.parseFloat("WMLScript Reference");
float_number1
has the floating-point value 1.22. float_number2
has the value invalid.
|
parseInt(string)
Converts
string to an integer.
Example:
var
integer1 = Lang.parseInt("2334"); var integer2 =
Lang.parseInt("WMLScript Reference");
integer1
has the integral value 2334.
integer2
has the value invalid.
|
random(numeric_value)
Returns
a random integer in the range 0 to numeric_value.
Example:
var
random_number = Lang.random(2);
random_number
has an integral value 0, 1 or 2.
|
seed(numeric_value)
If
numeric_value < 0, the
value used to initialize the random number generator will be
determined by the mobile device randomly, otherwise numeric_value
is used to initialize the random number generator.
Example:
Lang.seed(-1);
|
|
Feedback Form (ExpandCollapse)
|