var statement
continue statement
if statement
while statement
STATEMENT: return
return
The
return
statement is used inside a function to set the value of the function. This is the value returned by the call of the function. A function can only return one value. If no value is assigned during the function call, then the function has a default value of an empty string "". Therefore, a called function always returns a value, even if it is just an empty string.
Note that once the
return
is executed, you immediately leave the function and return to where the function call was made from within the code. The function will now have the value that was returned and you can assign that value to a named variable (use the
var
statement to initialize the variable).
Code for ReturnExample.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.WAPforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1">
<p>
return example
</p>
<do type="accept">
<go href="ReturnExample.wmls#findreturn()" />
</do>
</card>
<card id="card2">
<p>
return = $(rand)
</p>
</card>
</wml>
Code for ReturnExample.wmls
extern function findreturn()
{
var ran = findrandom();
WMLBrowser.setVar("rand", ran);
WMLBrowser.go("ReturnExample.wml#card2");
};
extern function findrandom()
{
return
Lang.random(1000);
};
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information