parrotcode: WMLScript Lang library | |
Contents | Language Implementations | WMLScript |
runtime/wmlslang.pir - WMLScript Lang library
This library contains a set of functions that are closely related to the WMLScript language core.
See "WMLScript Standard Libraries Specification", section 7 "Lang".
abs(value)
Returns the absolute value of the given number. If the given number is of type integer then an integer value is returned. If the given number is of type floating-point then a floating-point value is returned.
value = Number
Number or invalid.
min(value1, value2)
Returns the minimum value of the given two numbers. The value and type returned is the same as the value and type of the selected number. The selection is done in the following way:
value1 = Number
value2 = Number
Number or invalid.
max(value1, value2)
Returns the maximum value of the given two numbers. The value and type returned is the same as the value and type of the selected number. The selection is done in the following way:
value1 = Number
value2 = Number
Number or invalid.
parseInt(value)
Returns an integer value defined by the string value. The legal integer syntax is specified by the WMLScript (see [WMLScript]) numeric string grammar for decimal integer literals with the following additional parsing rule:
The result is the parsed string converted to an integer value.
value = String
Integer or invalid.
In case of a parsing error an invalid
value is returned.
parseFloat(value)
Returns a floating-point value defined by the string value. The legal floatingpoint syntax is specified by the WMLScript (see [WMLScript]) numeric string grammar for decimal floating-point literals with the following additional parsing rule:
The result is the parsed string converted to a floating-point value.
value = String
Floating-point or invalid.
In case of a parsing error an invalid
value is returned.
isInt(value)
Returns a boolean value that is true
if the given value can be converted into an integer number by using parseInt(value).
Otherwise false
is returned.
value = Any
Boolean or invalid.
isFloat(value)
Returns a boolean value that is true
if the given value can be converted into a floating-point number using parseFloat(value).
Otherwise false
is returned.
value = Any
Boolean or invalid.
maxInt()
Returns the maximum integer value.
Integer 2147483647.
minInt()
Returns the minimum integer value.
Integer -2147483648.
float()
Returns true if floating-points are supported and false if not.
Boolean.
exit(value)
Ends the interpretation of the WMLScript bytecode and returns the control back to the caller of the WMLScript interpreter with the given return value. This function can be used to perform a normal exit from a function in cases where the execution of the WMLScript bytecode should be discontinued.
value = Any
None (this function ends the interpretation).
abort(errorDescription)
Aborts the interpretation of the WMLScript bytecode and returns the control back to the caller of the WMLScript interpreter with the return errorDescription. This function can be used to perform an abnormal exit in cases where the execution of the WMLScript should be discontinued due to serious errors detected by the program. If the type of the errorDescription is invalid, string "invalid" is used as the errorDescription instead.
errorDescription = String
None (this function aborts the interpretation).
random(value)
Returns an integer value with positive sign that is greater than or equal to 0 but less than or equal to the given value. The return value is chosen randomly or pseudo-randomly with approximately uniform distribution over that range, using an implementation-dependent algorithm or strategy.
If the value is of type floating-point, Float.int() is first used to calculate the actual integer value.
value = Number
Integer or invalid.
If value is equal to zero (0), the function returns zero.
If value is less than zero (0),
the function returns invalid
.
seed(value)
Initialises the pseudo-random number sequence and returns an empty string. If the value is zero or a positive integer then the given value is used for initialisation, otherwise a random, system dependent initialisation value is used. A seed value of greater than or equal to zero results in a repeatable sequence of pseudo-random numbers. A seed value of less than zero results in a non-repeatable sequence of random numbers.
If the value is of type floating-point, Float.int() is first used to calculate the actual integer value. . If the value is non-numeric, invalid is returned and the current seed is unchanged.
value = Number
String or invalid.
characterSet()
Returns the character set supported by the WMLScript Interpreter. The return value is an integer that denotes a MIBEnum value assigned by the IANA for all character sets (see [WSP] for more information).
Integer.
Francois Perrad.
|