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

Jan Decroos jan.decroos at groepvanroey.be
Thu Jan 29 03:38:17 EST 2004


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


Sarah Reichelt wrote:
>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

Thanks, Sarah.

The result of the "do tScript as Applescript" can be empty, but also "execution
error" (if you click on the cancel button for instance).
So, I believe the test :
	if tFile is empty then return empty    -- no file chosen
>
should be
	if (tFile is empty) or (tFile is "execution error") then return empty    -- no
file chosen

Regards,
Jan
>
>



More information about the use-livecode mailing list