Re: Object types
Re: Object types
- Subject: Re: Object types
- From: John Stewart <email@hidden>
- Date: Tue, 16 Jul 2002 16:54:40 -0400
On 7/15/02 at 8:45 PM, the entity Frank Renner spoke thusly
>
Hi,
>
>
I am not a very frequent scripter.
>
>
Everytime I start with it again after some time, I have a lot of trouble
>
with complaints like "can4t make ... into ...". When I look into the
>
application directories, I find strange descriptions like "folder, by
>
numeric index, by ID, by name". Still I cannot understand why
>
>
set the source_folder to choose folder
>
set item_list to list folder source_folder
>
>
works fine and
>
Yes it does and note that it returns an alias to the chosen folder as a result.
>
set the source_folder to folder "New Folder"
>
set item_list to list folder source_folder
>
>
does not. It4s both folders or what?
>
No both aren't folders and in this instance neither should be a folder although the object they refer to is a folder. They should be either a
file specification, alias or path string
>
When someone tells me the solution, I say "aaaahh, it4s so simple". But
>
sometimes I tried for hours which is pretty much time for a well
>
experienced programmer who has little trouble with other programming
>
languages as I would think about myself.
>
>
So what is the object type of a folder and how can I make a string with
>
a pathname to a folder?
The class of a folder is "cfol" or folder, it's super class is "ctnr" or container
As for coercing or converting strings to paths or aliases -
set source_folder to choose folder -- returns an alias
--> alias "OS X:Users:john:" -- an alias
set source_folder to source_folder as string -- coerce alias to string
--> "OS X:Users:john:" -- path as a string
set source_folder to POSIX path of source_folder -- coerce string to POSIX Path
--> "/Users/john/" -- a POSIX Path (from OS X Standard Additions)
>
>
Where can I get a type list of all the elements of an applications
>
directory and how they can be converted into each other?
If an application is scriptable it will have a dictionary which can be accessed by opening it from the file menu of your favorite script
editor. You can also drag and drop a file onto Script Editor's icon to open it's dictionary. This dictionary will list the relevent information
regarding properties, elements and events. This also applies to AppleScript's Scripting Additions, their dictionaries are accessed by the same
method.
>
>
When I read the beginners documentation, it only tells me about
>
converting numbers into strings which is not what I need. Is there some
>
documentation -anywhere- that avoids the trial and error method? Right
>
now I have to look into lots of code snippets and try many things myself
>
which would be unneccessary if there was a more comprehensive "catalog"
>
(or let me keep calling it a "directory") e.g. of the Finder objects and
>
how they can be used.
The Finder has a dictionary also and you access it as mentioned above.
John
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
References: | |
| >Object types (From: email@hidden (Frank Renner)) |