Finding Bugs In Your Translator - Adobe 38040334 - Dreamweaver CS3 User Manual

Extending dreamweaver
Hide thumbs Also See for 38040334 - Dreamweaver CS3:
Table of Contents

Advertisement

Finding bugs in your translator

If the
translateMarkup()
an error message when you invoke it. Although failing silently prevents Dreamweaver from becoming unstable, it
can hinder development, especially when you need to find one small syntax error in multiple lines of code.
If your translator fails, one effective debugging method is to turn the translator into a command, as described in the
following steps:
1
Copy the entire contents of the translator file to a new document, and save it in the Configuration/Commands
folder inside the Dreamweaver application folder.
At the top of the document, between the
2
function commandButtons(){
return new Array( "OK","translateMarkup(dreamweaver.¬
getDocumentPath('document'), dreamweaver.getSiteRoot(), ¬
dreamweaver.getDocumentDOM().documentElement.outerHTML); ¬
window.close()", "Cancel", "window.close()");
}
3
At the end of the
translateMarkup()
and replace it with
dreamweaver.getDocumentDOM().documentElement.outerHTML =
whateverTheReturnValueIs
// return theCode;
dreamweaver.getDocumentDOM().documentElement.outerHTML = theCode;
}
/* end of translateMarkup() */
4
In the body of the document, add the following form with no text boxes:
<body>
<form>
Hello.
</form>
</body>
5
Restart Dreamweaver, and select your translator command from the Commands menu. When you click OK, the
function is called, which simulates translation.
translateMarkup()
If no error message appears and translation still fails, you probably have a logic error in your code.
Add
statements in strategic spots throughout the
6
alert()
you're getting the proper branches and so you can check the values of variables and properties at different points:
for (var i=0; i< foo.length; i++){
alert("we're at the top of foo.length array, and the value of i is " + i);
/* rest of loop */
}
After adding the
7
alert()
it again. This process reloads the command file and incorporates your changes.
function contains certain types of errors, the translator loads properly, but it fails without
tags, add the following function:
SCRIPT
function, comment out the
, as shown in the following example:
statements, select your command from the Commands menu, click Cancel, and select
return whateverTheReturnValueIs
function so you can make sure
translateMarkup()
DREAMWEAVER CS3
333
Extending Dreamweaver
line,

Advertisement

Table of Contents
loading

This manual is also suitable for:

Dreamweaver cs3

Table of Contents