STATEMENT:  if else

There are two possible formats:
 
if
 
The if statement evaluates a specified expression contained in the if statement to determine if it is true or false. If true, a block of statements associated in the if statement is executed. If false, the if statement is immediately exited.
 
if else
 
The if else statement evaluates a specified expression contained in the if statement to determine if it is true or false. If true, the block of statements associated with the if statement is executed. If false, the block of statements associated with the else statement is executed. Note that you cannot provide a test expression for the else statement.
 
The block of statements executed by the if or else statement can be any legal WMLS code (including more if and if else statements).
 
Code for IfElseExample.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>
   if else example
   </p>
   <do type="accept">
      <go href="IfElseExample.wmls#findifelse()" />
   </do>
</card>

<card id="card2">
<p>
   rand is $(str)
</p>
</card>

</wml>

 
Code for IfElseExample.wmls
extern function findifelse()
{
   var str;
   var rand = Lang.random(10000);
   if(rand < 5000)
   {
      str = "less than 5000";
   }
   else
   {
      str = "NOT less than 5000";
   }
   WMLBrowser.setVar("str", str);
   WMLBrowser.go("IfElseExample.wml#card2");
};

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