Re: How to "remember" a disk alias
Re: How to "remember" a disk alias
- Subject: Re: How to "remember" a disk alias
- From: JJ <email@hidden>
- Date: Thu, 19 Apr 2001 13:23:15 +0200
>
The first time the script below runs it prompts for a choice of mounted
>
disks. After that it just opens the disk. I would expect that, if the disk
>
were not mounted, a "Please insert the disk..." message would be produced
>
just as the Finder does when an alias of an unmounted disk is opened.
>
Instead I get a -1753 error from a classic application and a "Could not run
>
the script because of an AppleScript error" from the Script Editor.
>
>
Does anyone know how to do this correctly ?
>
>
-Irwin
>
>
>
property disk_alias : ""
>
tell application "Finder"
>
if disk_alias is "" then
>
set disk_name to (choose from list (list disks)) as string
>
set disk_alias to disk disk_name as alias
>
end if
>
open disk_alias
>
end tell
disk_alias is a route, a relative location, and it's recorded in {property
disk_alias}. So, when you choose a disk from a list, EXISTS property
"disk_alias", BUT NOT NECESSARY the real disk.
Then, if you try to use that property with "disk disk_name" (the real disk)
unmounted, it doesn't exists alias "disk disk_name of application Finder".
So...
I suposse you want mount indistinctely floppies, CD's & appleshare volumes.
With these ones you should use (and me, too) "mount volume" command.
Try this:
-- SCRIPT
property disk_name : ""
property ejected : ""
property the_server : "" (* YOU NEED THIS IF THE DISK IS AN UNMOUNTED
APPLESHARE VOLUME *)
tell application "Finder"
activate
if disk_name is "" then
set disk_name to (choose from list (list disks)) as string
if disk_name = "false" then (* USER-CANCELED *)
set disk_name to ""
return
end if
set ejected to ejectable of disk disk_name (* IS IT FLOPPY DISK,
CD...? *)
open disk disk_name
else
if disk_name is not "" then
if exists disk disk_name then
open disk disk_name (* BECAUSE IT'S MOUNTED *)
else
if not (exists disk disk_name) then (* IT ISN'T MOUNTED *)
if ejected = true then
(* RECURRENT DIALOG UNTIL USER INSERTS REMOVABLE
DISK *)
repeat while not (exists disk disk_name)
display dialog "Please, insert the disk " & ,
disk_name & "." with icon 2
try
open disk disk_name
on error
end try
end repeat
else
if ejected = false then (* MOUNT APPLESHARE VOLUME
*)
mount volume disk_name on server the_server (*
USING your_settings *)
end if
end if
end if
end if
end if
end if
end tell
--END SCRIPT
JJ