Filtering with more than 4 types (OSX) - AppleScript Question

Sarah Reichelt sarahr at genesearch.com.au
Wed Jan 28 17:48:51 EST 2004


On 29 Jan 2004, at 6:51 am, Barry Levine wrote:

> Jan,
>
> Would you mind providing the exact line(s) of Transcript one would use 
> to accomplish that AppleScript task?
>
> TIA,
> Barry

Try this: (watch out for line wraps)

on mouseUp
   put "MooV,JPEG,PNGf,GIFf,TIFF,BMP" into tFilters
   put "Select a Quicktime file:" into tPrompt

   put getFilePath(tFilters, tPrompt) into tFile
   answer tFile
end mouseUp


function getFilePath pFilters, pPrompt
   -- change comma-delimited list of filters to AppleScript list
   -- force each file type to 4 characters
   put "{" into tASfilters
   repeat for each item i in pFilters
     put quote & char 1 to 4 of (i & "    ") & quote & comma after 
tASfilters
   end repeat
   put "}" into last char of tASfilters

   -- do the AppleScript which calls the file selector
   put "choose file with prompt " & quote & pPrompt & quote & \
      " of type " & tASfilters into tScript
   do tScript as AppleScript
   put the result into tFile
   if tFile is empty then return empty    -- no file chosen

   -- format from Mac file path to Rev file path
   delete word 1 of tFile            -- get rid of the word alias
   replace quote with "" in tFile    -- get rid of the quotes
   put revUnixFromMacPath(tFile) into tFile
   return tFile
end getFilePath

Cheers,
Sarah



More information about the use-livecode mailing list