Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mounting and Dismounting local or server volumes on Tiger



DAL:
If a scripter really wants to get a disk name from "list disks" and then use it with Finder, I merely suggest being explicit about it: [..."eject disk foo" vs "eject foo"...]

On Oct 18, 2005, at 8:08 PM, John C. Welch wrote:
Well, to the casual scripter, they are. High level language. They expect the Finder to be smart enough to look for something that can be ejected with that name and eject it. If you aren't a programmer or a geek, it's perfectly logical.

But there are limits to what the system can infer:

	tell application "Finder"
		every item of disk "BLAH"
			--> { ...a list of the items, as expected... }

		every item of "BLAH"
			--> { "B", "L", "A", "H" }   -- doesn't even run any Finder code
	end tell

In a narrow context like "eject <something>" I agree that it's nice for Finder to figure out that you mean a disk, but I would recommend scripters use Finder objects whenever it makes sense, because once you get into the habit of using "just a string" where you could use a richer object, you'll run into cases like the above.

Another example (which I admit to tripping over more than once, before my fingers learned better):

	tell "Finder" to get item 1
		--> "F"

	tell application "Finder" to get item 1
		--> startup disk of application "Finder"

AppleScript might be able to figure out, sometimes, that I meant to tell an application something, rather than a string. But it couldn't tell in every case, so it would be unreliable.

Maybe the error messages could be improved, though:

	tell "Finder" to make new folder

	--> Alert:
		AppleScript Error
		"Finder" doesn't understand the make message.

Perhaps it could offer a guess:
--> Alert: The string "Finder" doesn't understand the make message. Perhaps you meant 'application "Finder"'.


Do others trip over this? I'll file it in Radar if someone thinks it's worthy.

Cheers,

--Dave

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-users/email@hidden

This email sent to email@hidden
References: 
 >Re: Mounting and Dismounting local or server volumes on Tiger (From: "John C. Welch" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.