Re: Coercion question
Re: Coercion question
- Subject: Re: Coercion question
- From: Paul Berkowitz <email@hidden>
- Date: Fri, 15 Jun 2001 08:40:35 -0700
On 6/15/01 1:07 AM, "Jan Pieter Kunst" <email@hidden> wrote:
>
>
Is it possible to coerce this:
>
>
alias "Disk:Folder:File"
>
>
to this:
>
>
{file "File" of folder "Folder" of startup disk}
>
>
Reason: I can ask for 'class of item 1 of' the second form, and get
>
"folder", "document file", etc., regardless of OS language (thanks JJ). With
>
the alias, I can ask for 'kind of' the alias, and get the kind as reported
>
in the Finder 'kind' column, which is language-specific and, in the case of
>
documents, too detailed for my use. I just want to know if something is a
>
document or a folder.
>
>
So I was thinking: if I can coerce the alias to the second form (don't know
>
what it's called), I can get the 'class' of the item. Or is there a way to
>
get the 'class' of an alias directly somehow?
I think you're not clear on what's pure applescript and what's an the
Finder. If you're looking for what _Finder_ class some object might be, just
put in the Finder and ask. As far as pure applescript goes, it will be
alias "Disk:Folder:File"
or
file "Disk:Folder:File"
as you like (the latter 'file' or file specification can be stipulated as a
location for file that doesn't exist yet, 'alias' must exist.)
I think you must be looking for Finder classes? (i.e. folder, container,
file, etc.?) The Finder's 'file' class is a different thing from pure
AppleScript's, being what we we normally think of as a file vs. a folder,
for example, with a number of subclasses too. Just pop it in the Finder:
tell application "Finder"
get alias "Disk:Folder:File"
end tell
--> file "File" of folder "Folder" of startup disk
It won't be in list braces {} unless you want it be - I'm not quite sure why
you included those. You can just use it as you like:
tell application "Finder"
{container of alias "Disk:Folder:File"}
end tell
--> {folder "Folder" of startup disk}
is a single-item list of the parent folder of your file, which the Finder
will automatically coerce to the format you're looking for.
You should probably download both the AppleScript Language Guide and the
Finder Applescript Guide, both available free via Apple's AppleScript page,
if you don't have them. They're a bit out of date (ASLG applies to OS 8.6,
Finder Guide to OS 8.5, I think, maybe a little earlier) but not too much as
far as OS's up to 9.1 are concerned.
--
Paul Berkowitz