Re: Newbie wants to move drive icons
Re: Newbie wants to move drive icons
- Subject: Re: Newbie wants to move drive icons
- From: Richard 23 <email@hidden>
- Date: Wed, 24 Jan 2001 07:55:28 -0800
>
Here is my elementary script
>
>
tell application "Finder"
>
activate
>
select disk "Audio CD 1"
>
set position of selection to {80, 711}
>
end tell
>
>
This script of course fails if the drive is empty or the mounted
>
volume name does not match.
>
>
Questions:
>
1-Is there a way to halt a script if *any* error occurs rather than
>
trapping for specific errors?
Yes.
try
-- do something stupid
on error
-- save face
end try
Now when the script tries something stupid and gets caught doing it,
it tries to recover and save face.
>
2-How can I determine if the DVD drive is empty or full?
I don't know that you can. However it may be possible to get the id
of a voulume mounted by the device from Apple System Profiler if it's
feeling cooperative.
I haven't had a lot of luck getting ASP to cough up information other
than that which is contained in the system profile (1st page). This
means I can't tell you how to get at the devices and volumes info
which would be useful in figuring out which volume id is associated
with your DVD drive.
If anyone can tell me how to get at the other info (control panels,
extensions, applications, system folder, and of course devices and
volumes) I'd like to hear about it. I would like to add this
capability to my AspQuery script. I just added a script object
containing the terminology for ASP 1.4.2 (shipped with Mac OS 9)
to help in assembling valid queries. I haven't uploaded it yet.
When I do it will be version 1.0d13 for those who are interested.
<
http://homepage.mac.com/richard23/applescript01.html#ASPquery>
>
3-How can I look for a variable CD name as opposed to a known fixed name?
Well this will get you part of the way there. Unless there's a
way to find out which device a particular volume is associated with
you'll need to rely on your own deductive reasoning but the result
will narrow the list of likely volumes.
-- ---------------------------------------------------------
-- Preprocessed by Convert Script 1.0d2
-- ---------------------------------------------------------
tell application "Finder"
set infoList to {}
set idList to id of disks where id < 0 and ejectable = true
repeat with theId in idList
set end of infoList to info for disk id theId
log result
end repeat
end tell
return {idList, infoList}
-- ---------------------------------------------------------
The id < 0 bit is actually redundant, but its useful to notice
that volume ids are assigned in mount order starting with id 0.
Here's mine at time of this posting:
tell application "Finder"
get id of disks
--> {-4, -5, -3, -2, -1}
get name of disks
--> {"GraphicConverter US PPC", "TELECOMM", "Netweb", ==>
"Macintosh HD", "Private"}
tell (disks where ejectable = true) to get {name, id}
{{"GraphicConverter US PPC", "TELECOMM"}, {-4, -5}}
The info for is also redundant unless you can infer the device
from somthing in the information record. I can't.
The info which would be most useful would be the "Where" text in the
volume's info window. Too bad info for doesn't get it and AppleScript
can't read (extract) the "Where" information from an info window.
On my system here's what the Where looks like for two different
ejectable volumes:
TELECOMM, ATAPI CD-ROM, bus 1, dev 0, v1.3.5"
GraphicConverter US PPC, Image file, ... on volume "Netweb"
Using this information you could easily separate the wheat from
the chaffe. If only the information window record contained the
where property. Wherefore art thou where?
>
4-Can I use a wildcard for the last character when referring to a volume
>
name?
Sort of.
tell application "Finder"
return name of disks where name starts with "Netwe"
--> "Netweb"
end tell
You did say last character, right? 8)
>
5-Could you make this work for *any* disc mounted in the drive (like
>
a DVD or Photo disc rather that an Audio CD?
Yes. That should be self-evident at this point.
>
Please help educate me! My forehead has been banging on the keyboard
>
a lot lately....The only book I own is the Tao of AppleScript.
I know the feeling. Unfortunately self-mutilation accomplishes nothing
and is its own reward.
>
Dale Saukerson
>
email@hidden
>
G4/400 Yikes PCI running OS 9.1 with 256 megs.
sweet. I still haven't found the time to update to 9.1 although I did
download it the first day. With the miscellaneous gripes about it I
guess I'm in no hurry. I try to stay forward and backward compatible
as much as possible anyway, so the next AS can wait a little longer.
R23 (limping along with only 96mb RAM)
Oh, by the way I noticed this in your script fragment:
>
set position of selection to {80, 711}
If you would like to have a script which will work in Mac OS 9.0.x,
AppleScript 1.4.3 you need to dodge the desktop positioning bug where
an error is generated if an attempt to set position is made while snap
to grid is turned on. No, you don't need to fiddle with the snap to
grid setting, you can use bounds, but that's got it's own set of hurdles.
I put up an info page on the bounds/position nonsense. You can read it
and get the bounding solution at:
<
http://homepage.mac.com/richard23/info/positionbug.html>