This example produces
a very useful application called PizzaCalc. It inputs the total cost of your pizza bill
and the number of people who've had pizza, and then produces the cost per person.
The application produces a deck with one
dynamic card, either called "calc" or "input" based on the action.
Notice all the escaped characters such as the double quotes. It also shows simple variable
handling, and how to pass variables from one card to another.
With a WML browser, you can try the
application here (http://wap.colorline.no/wap-faq/apps/pizzacalc.html) and choose the
application from there.
<?
header("Content-type: text/vnd.wap.wml");
echo("<?xml version=\"1.0\"?>\n");
echo("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"
\"http://www.wapforum.org/DTD/wml_1.1.xml\">\n\n");
echo("<!-- The application PizzaCalc was originally made by The Crusaders
www.crusaders.no on the Commodore Amiga -->\n");
echo("<!-- It was unfortunately not possible to emulate the crap interger
handling of the original program -->\n");
?>
<wml>
<?
if($action == "calc") {
echo("<card id=\"result\"
title=\"PizzaCalc\">\n");
echo("<do type=\"prev\"
label=\"Back\">\n");
echo("<go
href=\"pizzacalc.html#input\"/>\n");
echo("</do>\n");
echo("<p>\n");
echo("The cost per eater will be ".$total /
$eaters."<br/>\n");
}
else {
echo("<card id=\"input\"
title=\"PizzaCalc\">\n");
echo("<p>\n");
echo("<anchor>Split Pizza bill <go
href=\"pizzacalc.html?total=\$(total)&eaters=\$(eaters)&action=calc\"/></anchor>\n");
echo("<br/>\n");
echo("Total cost: <input type=\"text\"
name=\"total\" format=\"*N\"/>\n");
echo("Eaters: <input type=\"text\"
name=\"eaters\" format=\"*N\"/>\n");
}
?>
</p>
</card>
</wml> |
|