WMLScript » Lang » Lang.exit

Syntax:
Lang.exit(value)
value
The mandatory value parameter can be a string (including the empty string), an assigned variable, or a string that contains one or more assigned variables and associated text. This parameter is returned to the WMLS interpretor, not to the calling WML card.

Ends the current code and returns control to the caller.

The Lang.exit function is used to perform a normal exit from a WMLScript program. The execution of the WMLScript code is discontinued, control is returned to the caller of the WMLS program, and the information contained in the value parameter is returned to the WMLS interpretor. Simply put, you use this function to exit a WMLS function and return to the calling WML card.



Examples

Code:
<?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>
   exit example
   </p>
   <do type="accept">
      <go href="ExitExample.wmls#exittest( )" />
   </do>
</card>

<card id="card2">
<p>
   random number
   <br />
   $(randomnum)
</p>
</card>

</wml>
Explanation:

Code for ExitExample.wml

Language(s): WML
Code:
extern function exittest()
{
   var result = Lang.random(100);
   if(result < 50)
   {
      Lang.exit("");
   }
   else
   {
      WMLBrowser.setVar("randomnum", result);
      WMLBrowser.go("ExitExample.wml#card2");
   }
};
Explanation:

In this example, the Lang.random function is used to return a random integer ranging from 0 to 100 in value. A simple if...else test on the value of the random number either returns control to card two or performs an exit which returns control back to card one.

Language(s): WML

See Also: