Re: Mounting disk before continuing
Re: Mounting disk before continuing
- Subject: Re: Mounting disk before continuing
- From: Paul Skinner <email@hidden>
- Date: Wed, 23 May 2001 12:17:28 -0400
on 5/21/01 6:20 PM, Darrel Sandall wrote:
>
If I may ask a quick question. I am fairly new to Applescript, so
>
please bear with me. I have written a script to read as follows.
>
The intent of the script is to mount a disk (which requires me typing
>
a password into a dialog box. I want to have the script wait for the
>
disk to successfully mount before continuing, as the second tell
>
statement refers to an Applescript that launches files off of the
>
newly mounted disk.
SNIP
>
Have I done something not quite right, or is there a better way to
>
have the script wait until the disk is successfully mounted to
>
continue?
>
>
Thanks for any help! I appreciate it.
>
>
Darrel
on 5/22/01 3:50 PM, David Graham wrote:
>
You should mount the volume with AppleScript first, then the rest will follow
True, and not always.
You should mount the volume first, but with some constructions this will
cause further complications. When you use mount volume followed by an
attempt to assign a variable to the alias of the mounted disk you'd expect
it to work so long as the mounting succeeds. Not always.
I ran into this issue when rewriting my mountvolume handler for AS1.6. I
found that a mount volume command, followed by an assignment of a variable
to the mounted volume as an alias, always failed to make the alias although
the volume would appear immediately after the script's completion.
If you activate the finder, then mount the volume it allows the finder
to update much more rapidly and the subsequent assignation works
consistently. For me. This is true with ASIP servers and with NT 2000
volumes on my network. YMMV.
--an AFP example
tell application "Finder"
activate
try
mount volume ("afp://" & userName & ":" & userPassword & "@" &
ipaddress & "/" & volumename & "/")
set volumeRef to (disk volumename as alias)
on error
return false
end try
end tell
If you follow this with the code that accesses the files on that volume
using the volumeRef as a base for your file/folder references within a try
statement then you should get consistent results.
--
Paul Skinner