Re: how to suppress or ignore errors?
Re: how to suppress or ignore errors?
- Subject: Re: how to suppress or ignore errors?
- From: "Mark J. Reed" <email@hidden>
- Date: Fri, 9 Oct 2009 18:27:40 -0400
Put the "do shell script" inside a try block.
On Friday, October 9, 2009, Mari Masuda <email@hidden> wrote:
> Hi,
> As you may recall from my question the other day, I am working on a script to convert Adobe InDesign files to HTML. Using AppleScript, I first open the InDesign files and export them to InDesign tagged text files. Then I have a PHP script that turns the tagged text files into HTML that is "good enough" to be understood by someone who knows HTML (but it would never validate). Finally, I run the "good enough" HTML files through tidy to get valid XHTML. The problem I am having is that since the files I am inputting into tidy are not completely correct XHTML, tidy exits with an error code of 1 and a message that shows the errors/warnings. This makes it so only the first "good enough" HTML file gets processed and then my AppleScript exits due to the error handler. I was wondering if there is a way to tell my AppleScript to ignore the errors generated by tidy and just continue processing. I have tried enabling the "-q" (quiet) option of tidy but that doesn't suppress the errors, it only makes the error message shorter. Below are the relevant parts of my AppleScript. Thank you, and sorry for all of these newbie questions!
> Mari
> try -- irrelevant stuff not shown... all of the stuff above here seems to be working fine
> repeat with currentINDDfile in listOfINDDfilesAfterSomeCouldHaveBeenDeleted set quotedPOSIXpathToCurrentINDDfile to (quoted form of POSIX path of currentINDDfile) do shell script ("php -f /Applications/apache/htdocs/INDDtoHTML/index.php " & quotedPOSIXpathToCurrentINDDfile) do shell script ("tidy -m -i -wrap 0 -asxhtml -utf8 -q " & quotedPOSIXpathToCurrentINDDfile) end repeat
>
> tell application "Finder" activate display alert "INDD to HTML processing complete!" end tell
>
> on error errorMessage number errorNumber tell application "Finder" activate display alert "An error has occurred (" & errorNumber & "). " & errorMessage end tell
>
> end try
>
--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden