I'm trying to write an AppleScript for use with Mail (on Snow Leopard) to save image attachments of messages to a folder.  The main part of the AppleScript is:

property ImageExtensionList : {"jpg", "jpeg"}
property PicturesFolder : path to pictures folder as text
property SaveFolderName : "Fetched"
property SaveFolder : PicturesFolder &amp; SaveFolderName

tell application "Mail"
  set theMessages to the selection
  repeat with theMessage in theMessages
    repeat with theAttachment in every mail attachment of theMessage
      set attachmentFileName to theAttachment's name
      if isImageFileName(attachmentFileName) then
        set attachmentPathName to SaveFolder &amp; attachmentFileName
        save theAttachment in getNonexistantFile(attachmentPathName)
      end if        
    end repeat
  end repeat
end tell

on isImageFileName(theFileName)
  set dot to offset of "." in theFileName
  if dot &gt; 0 then
    set theExtension to text (dot + 1) thru -1 of theFileName
    return theExtension is in ImageExtensionList
  end if
  return false
end isImageFileName


When run, I get the error:


  error "Mail got an error: Can’t continue isImageFileName." number -1708


where error -1708 is:


  Event wasnt handled by an Apple event handler.


However, if I copy/paste the isImageFileName() into another script like:

property ImageExtensionList : {"jpg", "jpeg"}

on isImageFileName(theFileName)
  set dot to offset of "." in theFileName
  if dot &gt; 0 then
    set theExtension to text (dot + 1) thru -1 of theFileName
    return theExtension is in ImageExtensionList
  end if
  return false
end isImageFileName

if isImageFileName("foo.jpg") then
  return true
else
  return false
end if


it works fine.  Why does Mail complain about this?


Question: Convert linked html files into a pdf file?
Answer: As mentioned in the instructions you linked:


  The default glob expansion puts the pages in alphabetical order.


The index page links to nine different documents, whose names aren't in alphabetical order. When you say htmldoc ... *.html, the tools sees them in that order and puts the pages into the document alphabetically. You need to list the files on the command line in the order you want htmldoc to process them.

In this specific case you can produce an ordered list of filenames as they're linked in the index with:

awk '/http:|\.\./ {next}; /&lt;a href.*\.html/ { gsub(/.*href="/, "") ; gsub(".html.*", ".html") ; print }' index.html | uniq


so

htmldoc --webpage -f gdb.pdf index.html $(awk '/http:|\.\./ {next}; /&lt;a href.*\.html/ { gsub(/.*href="/, "") ; gsub(".html.*", ".html") ; print }' index.html | uniq)


will have the effect you want.