Finding bugs in your translator
If the
translateMarkup()
but it fails without 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:
Copy the entire contents of the translator file to a new document, and save it in the
1
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()");
}
At the end of the
3
whateverTheReturnValueIs
dreamweaver.getDocumentDOM().documentElement.outerHTML =
whateverTheReturnValueIs
// return theCode;
dreamweaver.getDocumentDOM().documentElement.outerHTML = ¬
theCode;
}
/* end of translateMarkup() */
In the
of the document, add the following form with no text boxes:
4
BODY
<body>
<form>
Hello.
</form>
</body>
Restart Dreamweaver, and select your translator command from the Commands menu. When
5
you click OK, the
If no error message appears and translation still fails, you probably have a logic error in
your code.
Add
6
alert()
you can make sure 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 in the
7
Cancel, and select it again. This process reloads the command file and incorporates
your changes.
352
Chapter 20: Data Translators
function contains certain types of errors, the translator loads properly,
translateMarkup()
line, and replace it with
, as shown in the following example:
translateMarkup()
statements in strategic spots throughout the
statements, select your command from the Commands menu, click
alert()
tags, add the following function:
SCRIPT
function, comment out the
function is called, which simulates translation.
translateMarkup()
return
function so
Need help?
Do you have a question about the DREAMWEAVER MX 2004-EXTENDING DREAMWEAVER and is the answer not in the manual?
Questions and answers