Re: Creator types as Class and I can't coerce it back
Re: Creator types as Class and I can't coerce it back
- Subject: Re: Creator types as Class and I can't coerce it back
- From: Paul Skinner <email@hidden>
- Date: Sat, 12 May 2001 00:53:20 -0400
on 5/11/01 10:56 PM, Andy Wylie wrote:
>
on 12/5/01 2:14 PM, Andy Wylie at email@hidden wrote:
>
>
> on 12/5/01 9:35 AM, Paul Skinner at email@hidden wrote:
>
>
>
>> The following script returns Creator Types as a list of values like
>
>> so...
>
>> <<class 'the 4 letter creator type'>>.
>
>> tell application "Finder"
>
>> set t to {name, creator type} of (every file of folder <optL>
>
>> "dark star:System Folder:Scripting Additions:" whose kind is <optL>
>
>> "application program")
-->{{"AirPort Scripting", "Keychain Scripting", "Network Setup
Scripting", "Sound Scripting", "Speech Listener", "URL Access
Scripting","propertyserver"}, {+class 1wse;, +class kscr;, +class ntex;,
+class sscr;, +class srls;, +class uasc;, +class aplt;}}
>
>
>
> how about...
>
> ------------------------------------------------
>
>
>
> tell application "Finder"
>
> set t to {name, creator type} of every application file of (path to scripting
>
> additions folder)
>
> end tell
>
> -- {"URL Access Scripting", "uasc"}
>
>
Sorry, I see the problem (AS 1.3.7) with more than one item, I vaguely
>
recall a discussion on a problem listing something else with the same
>
<<class 'the 4 letter creator type'>> result in a later AS vers but a
>
reference eludes me.
>
_____________________________ Andy
>
And I hope Andy won't mind my quoting a private message that followed this
up with the reference...
>
Date: Sun, 22 Apr 2001 14:59:05 -0400
>
Subject: Re: creator type of application file of every application
>
process
>
From: "Arthur J Knapp" <email@hidden>
>
To: email@hidden
>
>
> Date: Sat, 21 Apr 2001 16:03:47 -0400
>
> From: "Marc K. Myers" <email@hidden>
>
> Subject: creator type of application file of every application process
>
>
> Under OS 8.1 (AS1.1.2), if I ask the Finder for "creator type of
>
> application file of every application process" I get a list of creator types:
>
> --> {"QkBg", "ttxt", "rasm", "Dock", "npdt", "MOSS", "ToyS", "FTCh"}
>
>
> under OS 9.1 (AS1.6) and got an error. When I tested it I found that
>
> what was being returned was:
>
> --> {<<class QkBg>>, text returned, <<class rasm>>, <<class Dock>>,
>
> <<class npdt>>, <<class MOSS>>, <<class ToyS>>, <<class FTCh>>}
>
>
>
This is an old bug, (one that appearently comes and goes with each new
>
version). Bill Cheeseman has documented this:
>
>
<http://www.AppleScriptSourcebook.com/applescript/applescript112.html#newbug
>
s>
>
>
Bill Cheeseman:
I must visit the sourcebook more often!
>
> Attempting to 'get creator type of every process' returns a list of
>
> classes rather than a list of strings. [Joe Barwell reported this on
>
> the MacScripting mail list on August 1, 1997, before it appeared on
>
> the AppleScript site.] The same problem occurs when attempting to 'get
>
> file type of every process'. It is not possible to work around this
>
> bug by searching for the desired class. As with many of the Finder
>
> scripting bugs, the only workaround is to build the desired list using
>
> a slow repeat loop, as shown below. UNCHANGED IN FINDER 8.1.
>
>
>
>
> I found that I could coerce it back to what I expected by using "as
>
> text", but I'm curious about what I got without it. What do all those
>
> classes mean and why does SimpleText return "text returned" instead of
>
> it's creator type as a class?
>
>
The class of the label "text returned", from the record returned
>
from the Display Dialog command, happens to be the same as the creator
>
code of SimpleText, "ttxt". AppleScript is trying to do what it always
>
does, coerce AppleEvent codes into the AppleScript language.
>
>
>
Here's my solution:
>
>
-- I don't know which bytes are acceptable for use within
>
-- creator codes, but ascii 4 seems pretty unlikely.
>
--
>
set text item delimiters to ASCII character 4
>
>
tell application "Finder"
>
>
-- Get the codes with a direct string coercion:
>
--
>
set creatorList to ,
>
creator type of application file of ,
>
every application process as string
>
>
-- > "MSNMMOSSasDB"
>
>
end tell
>
>
set creatorList to every text item of creatorList
>
set text item delimiters to {""} -- restore
>
>
creatorList
>
-- > {"MSNM", "MOSS", "asDB"}
>
>
>
>
Arthur J. Knapp
>
_____________________________ Andy
Very helpful information! So I played around and got the following...
set AppleScript's text item delimiters to ","
tell application "Finder"
set t to {name of every application file of (path to scripting additions
folder), (every text item of (creator type of every application file of
(path to scripting additions folder) as text))}
-->{{"AirPort Scripting", "Keychain Scripting", "Network Setup Scripting",
"propertyserver", "Sound Scripting", "Speech Listener", "URL Access
Scripting"}, {"1wse", "dpsa", "ascr", "ascr", "kscr", "ascr", "ntex",
"ascr", "aplt", "ascr", "ascr", "MEmE", "MEme", "sscr", "srls", "ascr",
"uasc"}}
end tell
set AppleScript's text item delimiters to ""
Thanks to Andy, Bill and Arthur!
--
Paul Skinner