Re: make command
Re: make command
- Subject: Re: make command
- From: Timothy Bates <email@hidden>
- Date: Wed, 06 Feb 2002 10:26:02 +1100
On 5/2/02 7:39 PM, "Jim Brandt" <email@hidden> wrote:
>
Can some tell me what's wrong with this:
>
>
tell application "Finder"
>
activate
>
set dest_1 to "Macintosh HD:Misc:Descriptions:"
>
set fld_name to "200203"
>
make folder at dest_1 with properties {name:fld_name}
>
end tell
Looks pretty good, eh? This is the single most uncomfortable thing about
AppleScript: coercions and the lack there of.
The Finder is hearing "make me a a folder at a string"
And it thinks to itself (bear of little brain) "I can't make a folder at a
string: I'll tell the user that is a 'bad key form" - that should sned him
off to AppleScripters for at least a day or two and I can go back to
searching for that old desktop file I left here somewhere ... I know I left
it here somewhere. What? Oh you are asking the same thing again, I can't
make folders at strings. Remind to send to send an email to that nice young
Nebel chap and ask him to fix AppleScript so that it tells these other not
so nice young people to give me a folder. Yes, that is the error I want
"can't make a folder at a string - convert to folder before passing to make"
Anyhow, as everyone has else mentioned, you just need to coerce the string
into a folder. Really, the finder should take strings and coerce them
itself. Not to do so is really pretty retarded. However, the lack of this
facility has been shielded from users by the kind uber-fathers and their
osaxen which coerce our variable while we are not looking.
Anyhow for the second time, whenever you see "bad key form" just think
"something was not either a file, or folder"
Safe coding with the Finder often involves coercing inputs to string, and
then up-converting them to files and folders as required. The initial down
convert is necessary because if you get a file, then adding the word file
will end you right back where we started
Make new folder at folder folder
The coercion dummy says I can't make a folder from a folder (like - how hard
would that be - just leave the damn thing alone for *hrists sake!)
Anyhow, you get the picture: Think object oriented and much of this just
goes away, as you say, of course I need to say "make folder at folder x" and
not "make folder at string x"
Tim
>
The event log shows:
>
>
tell application "Finder"
>
activate
>
make at "Macintosh HD:Misc:Descriptions:" with properties
>
{name:"200203"} new folder
>
--> Finder got an error: Invalid key form.
>
>
Jim Brandt
>
_______________________________________________
>
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.
Dr Timothy Bates <
mailto:email@hidden>
Macquarie Centre for Cognitive Science (MACCS)
Macquarie University
Ph 61 (2) 9850 8623
Fx 61 (2) 9850 6059