Literals are values that are hard-coded within your script. This section describes the following types of literals:
Whole numbers expressed in one of the following ways:
Decimal (base 10)
Hexadecimal (base 16)
Octal (base 8)
Examples of integer literals include:
-41
0xF3
032
A decimal integer literal is a string of digits that does not begin with zero. Decimal integer literals, which are base 10, contain only numbers.
A hexadecimal integer literal is a string of digits that begins with 0X or 0x. Hexadecimal integer literals, which are base 16, contain the numbers 0-9 and/or the letters a-f or A-F.
An octal integer literal begins with zero. Octal integer literals, which are base 8, contain only the numbers 0-7.
Numbers that contain decimal places. Floating-point literals can contain both decimals and exponents.
The value 3.14 can be represented in the following ways, any of which is recognized by the WMLScript 1.1 compiler:
3.14
3.14e0
3.14E0
.314E1
314e-2
A floating-point literal contains any of the following:
A decimal integer (for example, 3)
A decimal point (for example, .14)
A fraction (for example, 1/2)
An exponent (for example, e0)
A floating-point literal must have at least one digit and either a decimal point or an exponent.
The exponent is an e or E followed by an integer. The exponent describes the number's base 10 logarithmic value. For example, e0 is comparable to 100; e-2 is comparable to 10-2. The exponent can be signed (preceded by + or -, denoting it is positive or negative).
A floating-point literal that is not within the specified value range will result in a compile time error. A floating-point literal underflow results in a floating-point literal of zero (0.0).
Any sequence of zero or more characters enclosed within double quotes ("") or single quotes ('').
Examples of string literals are:
'Goldwater Wins Nomination!'
"Tuesday, June 29, 1999"
"15% off retail"
String literals are pointers to a dynamic memory location that contains the character sequence. The value of the string can be altered by the application. WMLScript 1.1 allows string literals to be enclosed by either single or double quotes, as long as you use the same type each time. That is, beginning a string with a single quote and ending it with a double quote will generate a compiler error.
Some characters cannot be represented within string literals. WMLScript 1.1 supports special escape sequences by which these characters can be represented.
Variables that store values of true or false.
See the Appendix for more information about how WMLScript 1.1 converts and promotes Boolean values.
Variables that denote invalid values.
Invalid
var x = 8;
var y = 0;
if ((x/y) == invalid) {
display error message
};