GrazrScript Tutorial

Catching script errors

As you start programming with the script tag you are bound to enter errors into your applications. If an error occurs in a script block, an error message will be displayed in the result. The error message will include the line number where we think the error is located. This will not always be exact, but it will help you find the problem. Here is a version of the first baseball program without parentheses around the if condition.

<grazr:script>
<!--
if other != "" {
team=other;
}
-->
<grazr:script>

http://docs.grazr.com/script/tutorial/baseballerror.xml
<?xml version="1.0" encoding="UTF-8"?>
<opml version="2.0" xmlns:grazr="http://docs.grazr.com/script/spec/1.0">
<head>
<title>Baseball Search #1</title>
</head>
<body>
<grazr:form name="teamform">
<strong>Baseball Search</strong>
<input type="submit" value="Ok" /><br />
Favorite team: <select name="team">
<option value="Red Sox">Red Sox</option>
<option value="Yankees">Yankees</option>
</select>
Choose another team: <input type="text" name="other" />
</grazr:form>

<grazr:formtemplate name="teamform">
<grazr:script><!--
if other != "" {
team=other;
}
--></grazr:script>
<outline type="rss" text="%team% News"
xmlUrl="http://news.google.com?q=baseball+%team%&amp;output=rss" />
</grazr:formtemplate>
<grazr:formresult text="Latest stories:" name="teamform" />

</body>
</opml>


Since error messages appear in the results seen by the user, you will have to test all your applications for errors in advance. Welcome to the world of procedural programming.

Procedural programmingCreating outline nodes