The FooDoo Lounge

Finder sub-routines

Convert class types to strings

Some versions of the classic Finder (possibly just 8.6?) return lists of class types when asked for the creator type or file type of every process. This turns them into strings, as they would otherwise be, using tids.

-- classToString -- by Richard Morton 1999 --
-- Converts a list of class types to their four character strings. For buggy
-- Finder versions. Pass list of class types, returns list of strings.
on classToString from classList
    set clStr to classList as string -- "«class xxxx»«class yyyy»" etc
    tell AppleScript
        set olDel to text item delimiters
        set text item delimiters to "«class "
        set t1 to text items of clStr -- {"xxxx»", "yyyy»"} etc
        set text item delimiters to "" -- reset to empty string for next line
        set t2 to t1 as string -- "xxxx»yyyy»" etc
        set text item delimiters to "»"
        set outList to text items 1 through -2 of t2 -- last item is expected to be empty
        set text item delimiters to olDel
        return outList
    end tell
end classToString

 

The FooDoo Lounge is Copyright © Richard Morton 2002-2005

|| url: http://www.foodoo.sunreal.com.au/code/finder.html
|| created: 4-Aug-03, 10:11 PM; updated: 4-Aug-03, 11:55 AM
|| size: 11520 bytes