Skip to Content
Learning WML, and WMLScript
book

Learning WML, and WMLScript

by Martin Frost
October 2000
Intermediate to advanced
200 pages
5h 31m
English
O'Reilly Media, Inc.
Content preview from Learning WML, and WMLScript

What Is WMLScript?

WMLScript is loosely based on JavaScript but is much simpler in order to reduce the requirements on the device running the browser. (JavaScript can require quite large amounts of memory, and the interpreter to run it is complex.)

If you’ve ever done any programming in Java, JavaScript, C, C++, ECMAScript, or any of the large variety of other languages that borrow bits of syntax from each other, then a lot of the syntax of WMLScript should look familiar.

For example, a WMLScript function to calculate the factorial of a positive integer can be written as:

/* Calculate factorial of n. */
function factorial (n)
{
    var result = 1;

    for (var i=2; i<n; i++) {
        result *= n;
    }

    return result;
}

The curly braces, the for statement in the middle, and the return statement at the end are all similar to languages such as C, Java, JavaScript, or C++. The function line and the var line may be less familiar; they will be covered in later chapters.

WMLScript comments can have two forms: like in C, starting with /* and continuing until */ even across lines, and like in C++, starting with // and continuing until the end of the line:

/* C comments look like this. */

// C++ comments look like this.

/*
    C comments may span
    as many lines as you like.
*/

// C++ comments must have a
// new // at the start of every
// line of the comment.

Everything in WMLScript is case-sensitive, including function names, variable names, literal values, keywords, and everything else.

Spacing, however, is flexible. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

WAP Development with WML and WMLScript

WAP Development with WML and WMLScript

Ben Forta, Keith D. Lauver, Paul Fonte, Robert M. Juncker, Amy O'Leary, Ronan Mandel, Dylan Bromby
Expert Access™ 2007 Programming

Expert Access™ 2007 Programming

Rob Cooper, Michael Tucker
Mac OS X Panther in a Nutshell, 2nd Edition

Mac OS X Panther in a Nutshell, 2nd Edition

Chuck Toporek, Chris Stone, Jason McIntosh

Publisher Resources

ISBN: 1565929470Catalog PageErrata