..
In many cases the code WMLScript can go wrong even if correct from a logical point of view and syntax: some user actions or natural events such as the passage of time, however, can play tricks.
To remedy these problems as possible is necessary in the design stage, carry out a detailed debugging and during production to make error handling.
Debugging WMLScript code is done with education Console that provides the print and println methods that print on screen the result of a routine.
The latter, moreover, adds a line of ad text.
For example:
var a = 6; var b = 2; var c = a / b; Console.print (c);Returns the value of the scale, or 3.
Not by chance, we considered the case of a division which, if carried out by zero (0), returns an error.
The error we can control it with try catch construct which functions as in the following syntax:
try
{
/ / Try to execute a routine
}
trow
{
/ / Try to execute a routine alternative
}
catch (e)
{
/ *
tow the script and returns
an error message handled by the developer
* /
}
finally
{
/ / Still performs the part of the specified procedure here
}
The instructions of the construct are mandatory only try and catch.
Let's just an example of division by zero (0):
var a = 6;
var b = 0;
var c = a / b;
try
{
Console.print (c);
}
catch (e)
{
Console.print ("Error: division by zero!");
}
In this case, of course, returned the error message.
| |
CSS (Course)
Web Design and Accessibility according to W3C CSS and XHTML. Starting from 29 €. |
| |
Flash MX (Advanced)
Become a designer of Web sites from 29 €. |
| |
Web Marketing (Course)
Site promotion, search engines and marketing. From 39 €. |