Anda di halaman 1dari 42

EXPERIMENT NO: 1

http://sh.st/KWYWt
Aim: Overview of NMIT and WML.
Software Requirement: Windows XP with NMIT installed on it.
Hardware Requirement: IBM PC with Pentium 4 Processor.
Procedure:
1.
2.
3.
4.
5.

Open the NMIT Users Guide.


Study the Users Guide
Open the WAP 2000 overview.
Study the WAP 2000 overview.
Note the observations.

Observations:
The Nokia Mobile Internet Toolkit is an application development and testing
environment for developers of mobile Internet content. It provides tools for
creating mobile Internet services and includes the following features and
components:
Nokia Mobile Browser device simulator on which to display content
WML and WMLScript encoders
WAP Protocol Stack and file access modules
WAP Server Simulator, a WAP Gateway for local Toolkit use only.

DTD (Document Type Definition)


A document type definition defines the elements that are permitted within an
XML document, where these elements may appear within the document, which
attributes and attribute values are permissible, and so on. Basically, a DTD is a
set of rules that an XML parser uses to create a parse tree of a document, which
is required for further processing.

WML (Wireless Markup Language)


The Wireless Markup Language is a markup language based on
XML( Extensible Markup Language) and is used for creating content and user
interface destined for display on wireless mobile devices.
A WML source file has a MIME content type of text/vnd.wap.wml. An encoded
or compiled WML file has a MIME content type of application/vnd.wap.wmlc.
WML is a case-sensitive language.
1

WML also converts one or more contiguous newlines, carriage returns, tabs and
spaces to a single space.
WML inherits most of its syntactic constructs from XML

WMLScript
A scripting language used to program a mobile device. WMLScript is an
extended subset of the JavaScript scripting language.

Deck
A WML file, whether encoded or not, is called a deck. A deck is the smallest
unit of WML that a web server can send to a user agent for processing in the
mobile device. It is a collection of one or more WML cards contained in a file
of type wml.

Card
A single WML navigational and user interface unit.
The basic constituent of a WML deck is the card, which specifies a single
interaction between the device's user agent and the user. When a user agent
receives a deck, it typically activates the first card in the deck, though it can be
directed to any particular card in the deck.

Entities
Entities are used to specify characters in the document character set which must
either be escaped in WML or which may be difficult to enter in a text editor. For
example, the ampersand (&) is represented by the named entity &. All
entities begin with an ampersand and end with a semicolon.

Tags
A tag is a language element descriptor. A tag describes an element and contains
an element type name and a unique identifier. A tag could also include attributes
describing other properties.
WML consists of content surrounded by formatting tags, each enclosed in a pair
of angle brackets < and >.
<tag> This starts an element. The start tag can contain attributes.
</tag> This ends an element.
2

<tag/> This is an empty element, for example <br/>, indicating a line break.

Attributes
Many WML elements allow you to include attributes in them. Attributes specify
additional information for an element. We always specify attributes in the start
tag of an element, using the following syntax:
<tag attribute1="value1" attribute2="value2" attribute3="value3"...>
Note that attribute names must be lowercase.
Some attributes are mandatory. For example, the go element requires the href
attribute:
<go href="http://www.acme.com"/>

Comments
WML comments follow the XML commenting style and have the following
syntax:
<!-- a comment -->
WML comments cannot be nested.

Variables
Parameters can be set for WML cards and decks using variables. To substitute a
variable into a card, the following syntaxes are used:
$identifier
$(identifier)
$(identifier:conversion)
Parentheses are required if white space does not indicate the end of a variable.
Variable syntax has the highest priority in WML, that is, anywhere the variable
syntax is legal, an unescaped $ character indicates a variable substitution.
Variable references are legal in any PCDATA and in any attribute value
identified by the vdata entity type.

Elements
Elements specify all markup and structural information for a WML deck.
Elements may contain a start tag, content, other elements, and an end tag.
Elements have one of two structures:
<tag> content </tag>
- or<tag/>
Elements containing content and other elements are identified by a start tag
<tag> and an end tag </tag>.
An empty-element tag <tag/> identifies elements with no content.
Following table lists some commonly used WML elements:
3

Category

WML elements

Deck and cards

wml
card
template
head
access
meta

Events

do
ontimer
onenterforward onenterbackward
onpick
onevent
postfield

Tasks

go
prev
refresh
noop
setvar

Variables
User Input

Anchors Images
and Timers

Text Formatting

input
select
option
optgroup
fieldset
a
anchor
img
timer
br
p
table
tr
td
pre (WAP 1.2 and 1.3)

Deck and Card Elements


The following table briefly explains the elements you use to define the cards
within a deck.
Element
wml
card
template

Explanation
Defines a deck and encloses all the information and cards in the deck.
Indicates the general layout and user schemes in the user agent
Declares a template for cards in the deck.

head
access

Contains information relating to the deck as a whole, including metadata and access control elements.
Specifies access control information for the entire deck.

meta

Contains generic meta information relating the deck.

card Element
The card is the basic unit of navigation within a deck. It is possible to move
from one card to another within the same deck or to move to another deck.
Unless specified otherwise, upon navigation to another deck, the first card is
displayed.
<card id="card_name" title="title">
<p>
Text containing <i> information </i>.
</p>
</card>
The following table describes the elements and attributes displayed in the above
id="card_name"

Specifies a name that allows you to navigate to


the card from other cards in the same deck.

title="title"

Specifies advisory information on the card.

<p>

Specifies a paragraph.

<i>

Specifies italic text emphasis.

card.

template Element
The template element enables you to specify that certain task elements (listed
below) be executed whenever any card in the deck is entered. The task specified
by the template element will be executed unless that task is overriden by
another task element specified within the card.
Note that when a do element appears inside another element, the element with
the narrower scope takes precedence.
You can include the following elements in a template:
__ do
__ onevent
__ onenterforward
__ onenterbackward
__ ontimer

access Element
When you specify a URL, you gain access to all the variables it uses. To give
you control over this potential security risk, WML supports access control
performed with the access element.
You can use the access element in the deck header to specify access control for
the entire deck.

Secure WML
The following WML elements and attributes help to reduce security risks when
creating WML services.

Event Elements
Several WML elements can generate intrinsic events when the user interacts
with them. These intrinsic events indicate state transitions inside the user agent.
WML defines the four intrinsic events described in this section.
The following table briefly describes these elements.

Element
do

Explanation
Provides a general mechanism for performing
actions on the current card.

ontimer

Specifies an intrinsic event that occurs when a


timer expires.
onenterforward Specifies an intrinsic event that occurs when the
user enters a card under specific circumstances.
onenterbackward Specifies an intrinsic event that occurs when the
user navigates into a card by using a URI retrieved from
the history stack.
Specifies an intrinsic event that occurs when the
onpick
user selects or deselects an item in which the event is
specified.
onevent
Binds a task to a particular intrinsic event.
postfield

Specifies a field name and value for transmission to


an origin server during a URI request.

do Element
A card element can contain do elements that assign a task to a certain key. The
following is a simple example of a do element:

<do type="tasktype" label="label" name="name" optional="false">


<do>

type="tasktype
"

label="label"

Start tag of the doelement. Doelements may


appear inside the cardand template elements.
Note that you may specify only one tThask for
one doelement.
Specifies the type of task to execute. For
example,
acceptnavigates to the next card, and prev
returns to the previous card. The type attribute
is required.
Specifies the label for the soft key.

name="name"
Specifies the name of the do task binding.
optional="false" If you set this attribute to true, the user agent
may ignore this element.
fied.

onevent

Binds a task to a particular intrinsic event.

postfield

Specifies a field name and value for transmission to


an origin server during a URI request.

Task Elements
A do element can specify tasks that the user agent is to do when the user presses
a key or navigates to a card or deck. The go, prev, noop and refresh tasks of
WML are described in the following table.
Task
go

prev
refresh

noop

Explanation
Indicates navigation to a location
specified by href. If the href names
a WML card or deck, it is
displayed.
Indicates navigation to the previous
URI in the history stack.
Indicates an update of the user
agent context as specified by
the setvar tags.
Indicates that nothing should be
done.

go Element
The go element directs the user agent to the location specified by an href. If the
href names a WML card or deck, it is displayed.
The following is a simple example using the go element.
<go href="#card2"/>
The following table describes the elements used in the above example.
<go>

Start tag of a go element, indicating navigation to the


URI specified by href.

href="URI" Specifies the destination, for example, the location of the card to
display. This attribute is required.

refresh Element
The refresh element declares a refresh task, indicating an update of the user
agent context as specified by the setvar element. Side effects of the state
8

changes that are visible to the user (for example, a change in the screen display)
occur during the processing of the refresh task.

noop Element
The noop element specifies that nothing should be done, that is, no operation.
You will find this a useful element when you want to override template action.

anchor Element
The anchor and a elements specify the head of a link. The tail of a link is
specified as part of other elements, for example, a card name attribute. Note that
it is a WML syntax error to nest anchored links.
You can use anchors anywhere formatted text is legal, except for option
elements.
An anchored link must have an associated task that specifies the behavior when
the anchor is selected. You must anchor one of the following task elements to a
link:
__ go
__ prev
__ refresh
Note that it is a WML syntax error to specify more than one task in either an
anchor or a element.
The a element is a short form of the anchor element and is bound to a go task
without variable

Comments:
The Overview of NMIT and WML has been successfully done.

EXPERIMENT NO: 2
Aim: Write a program to check various formatting styles in a WML card.
Software Requirement: Windows XP with NMIT installed on it.
Hardware Requirement: IBM PC with Pentium 4 Processor.
Procedure:
1.
2.
3.
4.
5.

Open the NMIT 4.1 software.


Create a new file by selecting WML 1.3 Deck.
Write the code.
Note the observations.
Write the comments.

Code:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD
"http://www.wapforum.org/DTD/wml13.dtd">
<wml>
<card id=checkformatting title="Formatting">
<p>
normal<br/>
<em>emphasized</em><br/>
<strong>strong</strong><br/>
<b>bold</b><br/>
<i>italic</i><br/>
<u>underline</u><br/>
<big>big</big><br/>
<small>small</small>
</p>
</card>
</wml>

10

WML

1.3//EN"

Observations:

Comments:
The execution of Program checkformatting.wml using WML to create and
execute WML formats has been successfully done.

11

EXPERIMENT NO: 3
Aim: Write a program to check various cards in a WML deck.
Software Requirement: Windows XP with NMIT installed on it.
Hardware Requirement: IBM PC with Pentium 4 Processor.
Procedure:
1.
2.
3.
4.
5.

Open the NMIT 4.1 software.


Create a new file by selecting WML 1.3 Deck.
Write the code.
Note the observations.
Write the comments.

Code:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<!-- Possible <head> elements here. -->
<template>
<!-- Template implementation here. -->
<do type="prev"><prev/></do>
</template>
<card id="card1" title="Card #1">
<p align="center">
<!-- card implementation here. -->
<big><b>First card</b></big>
</p>
<!-- Additional <p> elements here. -->
<do type="accept" label="next">
<go href="#card2"/>
</do>
</card>
<card id="card2" title="Card #2">
<p align="center">
12

<big><b>Second Card</b></big>
</p>
</card>
</wml>

Observations:

Comments:
The execution of Program two_cards.wml using WML to check various cards
in a WML deck has been successfully done.

13

EXPERIMENT NO: 4
Aim: Write a program to check and execute WML links.
Software Requirement: Windows XP with NMIT installed on it.
Hardware Requirement: IBM PC with Pentium 4 Processor.
Procedure:
1.
2.
3.
4.
5.

Open the NMIT 4.1 software.


Create a new file by selecting WML 1.3 Deck.
Write the code.
Note the observations.
Write the comments.

Code:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<wml>
<card id="startcard" title="PG COURSES">
<p>
<a href="#card1"> Mtech Regular </a>
<br/>
<a href="#card2"> Mtech Weekend </a>
<br/>
<a href="#card3"> Others </a>
<do type="prev"><noop/></do>
</p>
</card>
<card id="card1" title="Mtech Regular">
<p align="left">
Mtech in CS<br/>
Mtech in IT<br/>
Mtech in DWC<br/>
Mtech in ECE<br/>
<br/>
<br/>
go back for other options
</p>
</card>
14

<card id="card2" title="Mtech Weekend">


<p align="left">
Mtech in CS<br/>
Mtech in IT<br/>
Mtech in ECE<br/>
<br/>
<br/>
go back for other options
</p>
</card>
<card id="card3" title="Other">
<p align="center">
For detail of other PG courses Check GGSIP University
website<br/>
www.ipu.ac.in
<br/>
<br/>
go back for other options
</p>
</card>
</wml>

Observations:

15

Comments:
The execution of Program cards_a_pg.wml using WML to check and execute
WML links has been successfully done.
16

EXPERIMENT NO: 5
Aim: Write a program to perform navigation between deck to deck in WML.
Software Requirement: Windows XP with NMIT installed on it.
Hardware Requirement: IBM PC with Pentium 4 Processor.
Procedure:
1. Open the NMIT 3.1 software.
2. Create a new file by selecting WML 1.3 Deck.
3. Write the code.
4. Note the observations.
5. Write the comments.
Code:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<wml>
<!-- Possible <head> elements here. -->
<card id="card1" title="Card #1">
<p align="center">
<big><b>First Card</b></big>
</p>
<p>
<a href ="cards_a_pg.wml">go to deck2</a>
<!-- Additional <do> elements here. -->
</p>
<!-- Additional <p> elements here. -->
</card>
<card id="card2" title="Card #2">
<p align="center">
<big><b>Second Card</b></big>
<do type="options" label="previous">
<go href="#card1"/>
</do>
</p>
</card>
</wml>
17

Observations:

Comments:
The execution of Program deck_to_deck.wml using WML to perform
navigation between deck to deck has been successfully done.

18

EXPERIMENT NO: 6
Aim: Write a program to create a table having rows and columns in WML.
Software Requirement: Windows XP with NMIT installed on it.
Hardware Requirement: IBM PC with Pentium 4 Processor.
Procedure:
1. Open the NMIT 4.1 software.
2. Create a new file by selecting WML 1.3 Deck.
3. Write the code..
4. Note the observations.
5. Write the comments.
Code:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<wml>
<card id="tabledemo" title="Table Demo">
<p>
<table align="center" title="Test Table" columns="2">
<!-- Card implementation here. -->
<tr><td><b> ITEM </b></td><td><b> UNITS</b> </td></tr>
<tr><td>Books</td><td>015</td></tr>
<tr><td>Copies</td><td>200</td></tr>
<tr><td>Pencils</td><td>250</td></tr>
<tr><td>Erasers</td><td>400</td></tr> </table>
</p>
</card>
</wml>

19

Observations:

Comments:
The execution of Program table_demo.wml using WML to create a table
having 4 no. rows and 2 columns has been successfully done.

20

EXPERIMENT NO: 7
Aim: Write a program to perform navigation between deck to deck and card to
card in WML.
Software Requirement: Windows XP with NMIT installed on it.
Hardware Requirement: IBM PC with Pentium 4 Processor.
Procedure:
1. Open the NMIT 4.1 software.
2. Create a new file by selecting WML 1.3 Deck.
3. Write the code.
4. Note the observations.
5. Write the comments.
Code:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<wml>
<template>
<do type="options" label="Back">
<prev/>
</do>
</template>
<card id="menudis" title="Welcome">
<p align="center">
<img
localsrc="mobidoll.wbmp"
src="mobidoll.wbmp"
alt="Welcome image"/>
<br/><br/><br/><br/><br/>
<big><em>WELCOME</em></big><br/><br/><br/>
Menu
<br/>
<do type="accept" label="MENU">
<go href="#MENUcard"/>
</do>
</p>
</card>
<card id="MENUcard" title="MENU">
<p>
<a href="#Message">Message</a><br/>
21

<a href="#Contacts">Contacts</a><br/>
<a href="#Setting">Setting</a><br/>
<a href="#Util">Utilities</a><br/>
</p>
</card>
<card id="Message" title="Message Box">
<p>
<a href="#Writemsg">Write Message</a><br/>
<a href="#Inbox">Inbox</a><br/>
<a href="#Outbox">Outbox</a><br/>
<a href="#Sentmsg">Sent Message</a><br/>
<a href="#Draft">Draft</a><br/>
</p>
</card>
<card id="Setting" title="Setting Box">
<p>
<a href="#Setime">Set Time</a><br/>
<a href="#phoneSet">Phone Setting</a><br/>
<a href="#disset">Display Setting</a><br/>
</p>
</card>
<card id="Contacts" title="Contacts Box">
<p>
<a href="#phnbook">Phone Book</a><br/>
<a href="#adcont">Add Contact</a><br/>
<a href="#edcont">Edit Contact</a><br/>
</p>
</card>
<card id="Util" title="Utilities">
<p>
<a href="checkformatting.wml">Formatting Demo</a><br/>
<a href="table_demo.wml">Tabel Demo</a><br/>
<a href="cards_a_pg.wml">PG Programs</a><br/>
</p>
</card>
<card id="Writemsg" title="Write Message">
<p>
You can write your messages here
</p>
</card>
<card id="Inbox" title="Write Message">
<p>
Your messages here
22

</p>
</card>
<card id="Outbox" title="Write Message">
<p>
Your message outbox
</p>
</card>
<card id="Sentmsg" title="Write Message">
<p>
Your sent messages here
</p>
</card>
<card id="draft" title="Write Message">
<p>
Message box Empty
</p>
</card>
<card id="phnbook" title="Phone Book">
<p>
Your Contacts here
</p>
</card>
<card id="adcont" title="Add New Contact">
<p>
Add new contact detail
</p>
</card>
<card id="edcont" title="Edit Contact">
<p>
Edit existing contact
</p>
</card>
<card id="Setime" title="Time set">
<p>
Set time here
</p>
</card>
<card id="phoneSet" title="Phone Settings">
<p>
Do your phone settings here
</p>
23

</card>
<card id="disset" title="Display Settings">
<p>
Edit display settings here
</p>
</card>
</wml>

Observations:

24

25

Comments:
The execution of Program menu_card.wml using WML to perform navigation
between deck to deck and card to card has been successfully done.
26

EXPERIMENT NO: 8
Aim: WAP to create following decks and link them in WML.
1. Messages
2. Contents
3. Setting
4. Utilities
5. Options
Software Requirement: Windows XP with NMIT installed on it.
Hardware Requirement: IBM PC with Pentium 4 Processor.
Procedure:
1. Open the NMIT 4.1 software.
2. Create a new file by selecting WML 1.3 Deck.
3. Write the code in following order.
a.
b.
c.
d.
e.
f.

Menu_card_deck.wml
message.wml
contact.wml
setting.wml
util.wml
options.wml

4. Note the observations.


5. Write the comments.
Code:
Menu_card_deck.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<wml>
<template>
<do type="options" label="Back">
<prev/>
</do>
</template>
<card id="menudis" title="Welcome">
<p align="center">
<img
localsrc="mobidoll.wbmp"
src="mobidoll.wbmp"
alt="Welcome image"/>
27

<br/><br/><br/><br/><br/>
<big><em>WELCOME</em></big><br/><br/><br/>
Menu
<br/>
<do type="accept" label="MENU">
<go href="#MENUcard"/>
</do>
</p>
</card>
<card id="MENUcard" title="MENU">
<p>
<a href="message.wml">Message</a><br/>
<a href="contacts.wml">Contacts</a><br/>
<a href="setting.wml">Setting</a><br/>
<a href="util.wml">Utilities</a><br/>
<a href="options.wml">Options</a><br/>
</p>
</card>
</wml>
Message.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<wml>
<card id="Message" title="Message Box">
<p>
<a href="#Writemsg">Write Message</a><br/>
<a href="#Inbox">Inbox</a><br/>
<a href="#Outbox">Outbox</a><br/>
<a href="#Sentmsg">Sent Message</a><br/>
<a href="#Draft">Draft</a><br/>
</p>
</card>
<card id="Writemsg" title="Write Message">
<p>
You can write your messages here
</p>
</card>
<card id="Inbox" title="Inbox">
28

<p>
Your messages here
</p>
</card>
<card id="Outbox" title="Outbox">
<p>
Your message outbox
</p>
</card>
<card id="Sentmsg" title="Sent Message">
<p>
Your sent messages here
</p>
</card>
<card id="draft" title="Draft Message">
<p>
Message box Empty
</p>
</card>
</wml>
Contact.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<wml>
<card id="Contacts" title="Contacts Box">
<p>
<a href="#Phnbook">Phone Book</a><br/>
<a href="#adcont">Add Contact</a><br/>
<a href="#edcont">Edit Contact</a><br/>
</p>
</card>
<card id="phnbook" title="Phone Book">
<p>
Your Contacts here
</p>
</card>
<card id="adcont" title="Add New Contact">
<p>
Add new contact detail
</p>
29

</card>
<card id="edcont" title="Edit Contact">
<p>
Edit existing contact
</p>
</card>
</wml>
Setting.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<wml>
<card id="Setting" title="Setting Box">
<p>
<a href="#Setime">Set Time</a><br/>
<a href="#phoneSet">Phone Setting</a><br/>
<a href="#disset">Display Setting</a><br/>
</p>
</card>
<card id="Setime" title="Time set">
<p>
Set time here
</p>
</card>
<card id="phoneSet" title="Phone Settings">
<p>
Do your phone settings here
</p>
</card>
<card id="disset" title="Display Settings">
<p>
Edit display settings here
</p>
</card>
</wml>
Util.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<wml>
30

<card id="Util" title="Utilities">


<p>
<a href="checkformatting.wml">Formatting Demo</a><br/>
<a href="table_demo.wml">Tabel Demo</a><br/>
<a href="cards_a_pg.wml">PG Programs</a><br/>
</p>
</card>
</wml>
options.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<wml>
<card id="options" title="Options">
<p>
<a href="converter.wml">Converter</a><br/>
<a href="calculator.wml">Calculator</a><br/>
</p>
</card>
</wml>

Observations:

31

Comments:
The execution of Program menu_card_deck.wml using WML to create
following decks
1. Messages
2. Contacts
3. Setting
4. Utilities
5. Options
and linking them has been successfully done.

32

EXPERIMENT NO: 9
Aim: Write a program to perform following Conversions in WML.
1. Currency
2. Length
3. Weight
Software Requirement: Windows XP with NMIT installed on it.
Hardware Requirement: IBM PC with Pentium 4 Processor.
Procedure:
1. Open the NMIT 4.1 software.
2. Create a new file by selecting WML 1.3 Deck.
3. Write the code in following order.
a.
b.
c.
d.
e.
f.

converter.wml
currency.wml
convert.wmls
length.wml
feetmm.wmls
weight.wml

4. Note the observations.


5. Write the comments.
Code:
Converter.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<wml>
<card id="conversion" title="Converter">
<p>
<a href="currency.wml">Currency</a><br/>
<a href="length.wml">Length</a><br/>
<a href="weight.wml">Weight</a><br/>
</p>
</card>
</wml>
33

Currency.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<wml>
<template>
<do type="options" label="Back">
<prev/>
</do>
</template>
<card id="c1" title=" Conversion ">
<p>
Enter Doller exchange rate:
<input name="exrate" value="45" maxlength="10"/>
You entered: $$ $exrate exchange rate<br/>
Enter Rupee value to convert:
<input name="rupee" value="1" maxlength="10"/>
You entered: $rupee Rs.<br/><br/><br/>
Press options to convert
<do type="accept" label="Go">
<go href="convert.wmls#rupeetodoller($exrate,$rupee)"/>
</do>
<!-- <refresh>-->
<!-<setvar name="exrate" value="55"/>-->
<!-<setvar name="rupee" value="2"/>-->
<!-- </refresh>-->
</p>
</card>
</wml>
convert.wmls
extern function rupeetodoller(exrate,rupee)
{
var result;
if(rupee>"0.0")
{
result=rupee/exrate;
Dialogs.alert("Doller:" +result);
}
else
{
Dialogs.alert("Enter values greater then 0");
}
34

WMLBrowser.newContext();
WMLBrowser.go("converter.wml");
}
Length.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<wml>
<template>
<do type="options" label="Back">
<prev/>
</do>
</template>
<card id="c2" title=" Length Conversion ">
<p>
Enter feet value to convert:
<input name="feet" value="1" maxlength="10"/>
You entered: $feet feet<br/><br/><br/>
Press options to convert
<do type="accept" label="Go">
<go href="feetmm.wmls#feettomm($feet)"/>
</do>
</p>
</card>
</wml>
Feetmm.wmls
extern function feettomm(feet)
{
var result;
if(feet>"0.0")
{
result=feet*304.8;
Dialogs.alert("mm=" +result);
}
else
{
Dialogs.alert("Enter values greater then 0");
}
WMLBrowser.newContext();
WMLBrowser.go("converter.wml");
}
35

Weight.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<wml>
<template>
<do type="options" label="Back">
<prev/>
</do>
</template>
<card id="c3" title=" Weight Conversion ">
<p>
Enter Kg value to convert:
<input name="kg" value="1" maxlength="10"/>
You entered: $kg Kg<br/><br/><br/>
Press options to convert
<do type="accept" label="Go">
<go href="kgpound.wmls#kgtopound($kg)"/>
</do>
</p>
</card>
</wml>
Kgpound.wmls
extern function kgtopound(kg)
{
var result;
if(kg>"0.0")
{
result=kg*2.204623;
Dialogs.alert("Pound=" +result);
}
else
{
Dialogs.alert("Enter values greater then 0");
}
WMLBrowser.newContext();
WMLBrowser.go("converter.wml");
}

36

Observations:

37

Comments:
The execution of Program converter.wml using WML to perform following
Conversions in WML.
1. Currency
2. Length
3. Weight
has been successfully done.

38

EXPERIMENT NO: 10
Aim: Write a program to create a Calculator using WML.
Software Requirement: Windows XP with NMIT installed on it.
Hardware Requirement: IBM PC with Pentium 4 Processor.
Procedure:
1.
2.
3.
4.
5.
6.

Open the NMIT 4.1 software.


Create a new file by selecting WML 1.3 Deck.
Write the code and save the file as calculator.wml.
Now Write the WMLS file and save it as calc.wmls
Note the observations.
Write the comments.

Code:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<wml>
<card id="card1" title="CALCULATOR">
<p align="center">
<b>ENTER VALUES </b><br/>
<b>Enter First No.</b>
<input size="8" format="*N" name="a" title="Number 1 :"/>
<select name="opts">
<option value="adds"> Add </option>
<option value="subs"> Subtract </option>
<option value="muls"> Multiply </option>
<option value="divs"> Divide </option>
<option value="root"> Square Root </option>
<option value="power"> Power </option>
</select>
<b>Enter Second No.</b>
<input size="8" format="*N" name="b" title="Number 2 :"/>
<do type="accept" label="calculator">
<go href="calc.wmls#calculator($(a),'$(opts)',$(b))"/>
</do>
<b>ANSWER :</b> <br/>
39

<big><b>$(result)</b></big><br/>
</p>
</card>
</wml>
Calc.wmls
extern function calculator(aa,optss,bb)
{
var value,result;
if(optss=="adds")
value=aa+bb;
else if(optss=="subs")
value=aa-bb;
else if(optss=="muls")
value=aa*bb;
else if(optss=="divs")
value=aa/bb;
else if(optss=="root")
value=Float.sqrt(aa);
else if(optss=="power")
value=Float.pow(aa,bb);
else
Dialogs.alert(" No Answer");
WMLBrowser.setVar("result",value);
WMLBrowser.refresh();
WMLBrowser.go("calculator.wml");
}

Observations:

40

41

Comments:
The execution of Program calculator.wml using WML to create a Calculator
has been successfully done.

42

Anda mungkin juga menyukai