FUNCTION:  Lang.exit

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

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

</wml>

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


Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information