Writing more than one cards in a WML deck.

Writing more than one cards in a WML deck. Tutorial First Card Writing more than one cards in a deck. In this lesson we will write application that uses two cards in a deck. First card is displayed only for some time and after that it directly

Writing more than one cards in a WML deck.


First Card

  

Writing more than one cards in a deck.

In this lesson we will write application that uses two cards in a deck. First card is displayed only for some time and after that it directly go to the second card. 

 


Second Card

   Using this code you can display some information in your application that automatically goes after specified time. Here we are displaying "Get ready to learn WAP in record time!" in first Card and second card displays "Welcome to the exciting world of WAP!" message.   
  

Now here is the code of the program.

<?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" title="Learning WML"> 
<onevent type="ontimer">
<go href="#menu"/>
</onevent>
<timer value="30"/>
<p>
Get ready to learn WAP in record time!
</p>
<do type="accept" name="card2" label="Continue">
<go href="#menu"/>
</do>
</card> 
<card id="menu" title="Learning WML">
<p>Welcome to the exciting world of WAP!</p>
</card>
</wml>

First of all copy the above code in the following text box and then press test button to test it.


In the above example we have created two cards. You can create as many as you want, but the card ids should the unique.

Now take a closer look at <timer> element. Timer element invokes a task after some period of user inactivity. Syntax of time element is:

   <timer name="variable" value="value"/>

Attributes

  name: Name of the variable.
  value: 1/10 of seconds. 30 means 3 seconds.

<go> element opens a new URL, in this case it opens the second card "menu".

<do> element is used as a navigational help. With the help of do-element user can start a action on the displayed card. Some of the uses of do-element are-

Jump to previous page: 

<do type="prev" title="Back">
  <prev/>
</do>

Jump to main page:
<do type="accept" title="Main">
  <go href="index.wml"></go>
</do>

Jump to help:
<do type="help" title="Help">
  <go href="#help"></go>
</do>
  

Now try to write a program that uses three cards. First card displays some message and waits for 5 seconds and after that it displays the second card. Second card waits for 10 seconds and it passes the control to the First card.
 
  

Tutorial