Re: Opening File Dialog error
Re: Opening File Dialog error
- Subject: Re: Opening File Dialog error
- From: email@hidden
- Date: Tue, 03 May 2005 13:36:37 -0500
- Priority: normal
Hi Gary,
Thanks for your reply. There's still a problem though... In the
following code:
-----
try
open file filePath
on error the error_message number the error_number
if error_number is -54 then
-- no line break next line
display dialog "That file is currently being edited." buttons
{"OK"}
default button 1 with icon stop
else
-- some other error, do what's needed or continue to if-sift,
etc.
display dialog "[" & error_number & "]" & return &
error_message
end if
end try
-----
QuarkXPress 6.5 pauses the script on the 'open file filePath' line,
which holds the script from continuing. If I place a 'timeout' around
the open statement like so:
-----
try
with timeout of 4 seconds
open file filePath
end timeout
on error the error_message number the error_number
if error_number is -54 then
-- no line break next line
display dialog "That file is currently being edited." buttons
{"OK"}
default button 1 with icon stop
else
-- some other error, do what's needed or continue to if-sift,
etc.
display dialog "[" & error_number & "]" & return &
error_message
end if
end try-----
the script continues to work but doesn't error inside the 'try' block.
It just simply continues on while the 'File is Locked' dialog stays
open. I'm thinking the only way around this is to have a timeout of
possibly 10 seconds, and then if window 1 contains an 'OK' button then
click it and force an error. Not a very efficient method, but the only
one I can think of.
I did an 'info for file filePath' to see if there were any differences
from a non-open file, but didn't see anything promising in there.
Thanks again for your thoughts with this. I appreciate it! :-)
Jay
-----
"email@hidden" wrote:
> I've run into a problem where when a script is opening a QuarkXPress
> 6.5 document, sometimes the user on another machine has it open (the
> file resides on a server) and I get this dialog:
>
> File is locked [-54]
>
> Is there a way to get around this dialog without using GUI scripting?
Jay, you've got nearly all the pieces you need, so that's good. The
plan is
to "trap" for that error condition, and then branch as you would like.
You have an 'on error' handler in your script chunk (below), so that's
where
you need to put the statements you'd like executed 'on error'. Right
now,
you have none there. You can IF-sift that by checking for your specific
error code.
> I can put a 'timeout' block around the open statement like so:
>
> try
> with timeout of 4 seconds
> open file filePath
> end timeout
> -- Use gui to look for error window and try to click 'ok' button...
> on error
>
> end try
Let's expand the 'on error' handler...here's one example...
try
open file filePath
on error the error_message number the error_number
if error_number is -54 then
-- no line break next line
display dialog "That file is currently being edited." buttons
{"OK"}
default button 1 with icon stop
else
-- some other error, do what's needed or continue to if-sift,
etc.
display dialog "[" & error_number & "]" & return &
error_message
end if
end try
HTH
--
Gary
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden