LispMe Importer (AppleScript)

Tuesday, August 26, 2003

LispMe Importer for Macintosh
Drop text documents on this icon to add them as memos to Palm™ Desktop in the category specified by the property pCategoryName, by default “LispMe”.
-- 1.0.2 of 26 August 2003: updated for Palm Desktop 4.1 compatbility, removed bug warning, configurable properties
--
1.0.1 of 5 March 2003: updated for Mac OS X compatibility
--
1.0 of 24 July 2000: initial release

--
category in which to add the notes
property pCategoryName : "LispMe"

--
for Mac line endings; use \n for Unix line endings
property pLineDelimiter : return

on open fileList
   
local numFiles, theCategory, f, fft, fcd, fmd, fti, mmo
   
set numFiles to 0
   
tell application "Palm Desktop"
      
try
         
copy (category pCategoryName) to theCategory
      
on error
         
copy (make new category with properties {name:pCategoryName}) to theCategory
      
end try
      
repeat with f in fileList
         
tell application "Finder"
            
copy (f's file type) to fft
            
copy (f's creation date) to fcd
            
copy (f's modification date) to fmd
         
end tell
         
if fft is "TEXT" or fft is missing value then
            
copy (read f before return) to fti -- title is first line
            
copy (read f from (length of fti) + 2) to ftxt
            
make new memo with properties ¬
               {
title:fti, contents:ftxt, primary category:theCategory, creation date:fcd, modification date:fmd}
            
copy (numFiles + 1) to numFiles
         
end if
      
end repeat
   
end tell
   
display dialog "Imported " & numFiles & " document(s) as Palm Desktop memos in category “" & pCategoryName & ¬
      "
”." buttons {"Quit"} default button 1
end open

on run
   
display dialog "LispMe Importer for Macintosh" & return & ¬
      "
Nicholas Riley <importer@sabi.net>" & return & return & ¬
      "
Drop text documents on this icon to add them as memos to Palm™ Desktop in the “" & pCategoryName & ¬
      "
” category." buttons {"Quit"} default button 1
end run
Top | Made with Script Debugger 3.0