WMLScript Developer's Guide

[Cover] [Previous Section] [Next Section] [Index]

Current chapter: Chapter 2 - WMLScript Overview
Section 12 out of 57 total sections , Section 6 out of 6 sections in this chapter


Debugging WMLScript

Debugging WMLScript files is very similar to debugging any scripting language. Formal debugging facilities are limited, requiring you, the programmer, to build your WMLScript code incrementally, testing and debugging each block as you work. Use your UP.Browser to test your code each time you add a new block of code.

Working carefully and systematically is also important. Whenever you define a new function, loop, or conditional statement, always build the complete structure of the code block before filling in the implementation details. For example, define a function that is structurally complete, but has no implementation:

function countwords() {  
};  

Then, build the function one block at a time, adding parameter(s) and conditional statements as you decide how the function is to do its job:

function countwords(str) {
    while (str !=
"") {
        //fill in the details and test
        //debug code begin
        Console.PrintLn("Current string = " + str);
        //debug code end
    };
};  

Another good practice is to test important expressions using the print and printLn functions in the Console library, so that you can see the results of the code as your script executes.

Following these practices helps you isolate syntactical and logical errors much more quickly than if you write a large block of code and then try to test it all at once.

For a more complete discussion of WMLScript debugging, see Chapter 10, Debugging WMLScripts.


[Cover] [Previous Section] [Next Section] [Index]


Part Number DKDS-41-002, UP.SDK Release 4.1, December 2000

Copyright © 1994-2000 Openwave Systems Inc. All rights reserved.
Please send comments and questions to sdk-doc-comments@openwave.com.