WMLScript Developer's Guide

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

Current chapter: Chapter 6 - Statements
Section 32 out of 57 total sections , Section 6 out of 11 sections in this chapter


Variable Statements

Variable statements initialize variables. Variable names, which can be any legal identifier, must be unique within a single function. The scope of the declared variable is the rest of the current function; the expression is evaluated every time the variable statement is executed.

Variables can be initialized either to a specified value or, by default, to an empty
string ("").

The following are examples of variable statements:

function count(str) {  
    var result = 0;        // Initialized once  
    while(str != "") {  
        var ind = 0;       // Initialized every time  
         // modify string  
     }  
return result  
}  
function example(param) {  
    var a = 0;  
    if (param > a) {  
        var b = a+1;  // Variables a and b can be used  
    } else {  
        var c = a+2;  // Variables a, b, and c can be used  
    }  
    return a;         // Variables a, b, and c are accessible  
}  

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


Part Number DKDS-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.