WMLScript Reference

[Cover] [Previous Section] [Next Section] [Index]

Current chapter: Chapter 2 - Lexical Structure
Section 10 out of 34 total sections , Section 5 out of 6 sections in this chapter


Literals

Literals are values that are hard-coded within your script. This section describes the following types of literals:



Integer Literals


Definition

Whole numbers expressed in one of the following ways:


Examples

Examples of integer literals include:


Comments

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.



Floating-Point Literals


Definition

Numbers that contain decimal places. Floating-point literals can contain both decimals and exponents.


Examples

The value 3.14 can be represented in the following ways, any of which is recognized by the WMLScript 1.1 compiler:


Comments

A floating-point literal contains any of the following:

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).



String Literals


Definition

Any sequence of zero or more characters enclosed within double quotes ("") or single quotes ('').


Examples

Examples of string literals are:

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.

Character represented  Symbol  Sequence 

Apostrophe or single quote 

\'  

Double quote 

\"  

Backslash 

\\  

Slash 

\/  

Backspace 

 

\b  

Form feed 

 

\f  

Newline 

 

\n  

Carriage return 

 

\r  

Horizontal tab 

 

\t  

The character with the encoding specified by two hexadecimal digits hh (Latin-1 ISO8859-1) 

 

\xhh  

The character with the encoding specified by the three octal digits ooo (Latin-1 ISO8859-1) 

 

\ooo  

The Unicode character with the encoding specified by the four hexadecimal digits hhhh

 

\uhhhh  



Boolean Literals


Definition

Variables that store values of true or false.


Comments

See the Appendix for more information about how WMLScript 1.1 converts and promotes Boolean values.



Invalid Literals


Definition

Variables that denote invalid values.


Return Value

Invalid


Examples

var x = 8;

var y = 0;  
if ((x/y) == invalid) {  
     display error message  
};  

[Cover] [Previous Section] [Next Section] [Index]


Part Number DKWS-41-002, UP.SDK Release 4.1, December 2000

Copyright © 1994-2000 Openwave Systems Inc. All rights reserved.
Please send comments and questions to sdk-doc-comments@openwave.com.