Applescript looping and error messages

Joined
Apr 28, 2011
Messages
1
Reaction score
0
Points
1
Evening All,

I have an applescript (it was an automater script that was then automagically converted to applescript) that does what it is suppose to do except for two small niggles.

I'm not a programmer at all (the last programming was C# MANY years ago!

Here is the script:

-- Click the “In Tray” URL.
set uiScript to "click static text 1 of UI Element \"In Tray\" of group 23 of UI Element 1 of scroll area 1 of group 3 of window \"OrderWork: Service Partner Work Order Listing\" of application process \"Safari\""
my doWithTimeout(uiScript)

-- Click the text “20110403918”
set uiScript to "click static text 1 of UI Element 1 of row 2 of table 1 of UI Element 1 of scroll area 1 of group 3 of window \"OrderWork: Service Partner Work Order Listing\" of application process \"Safari\""
my doWithTimeout(uiScript)

-- Click the text “ Accept”
set uiScript to "click static text 1 of group 1 of UI Element 58 of UI Element 1 of scroll area 1 of group 3 of window \"OrderWork: Service Partner Work Order Detail\" of application process \"Safari\""
my doWithTimeout(uiScript)

-- Click the “ Accept” URL.
set uiScript to "click static text 1 of UI Element \" Accept\" of group 70 of UI Element 1 of scroll area 1 of group 3 of window \"OrderWork: Work Order Accept\" of application process \"Safari\""
my doWithTimeout(uiScript)

-- Click the text “ Finish”
set uiScript to "click static text 1 of group 1 of UI Element 62 of UI Element 1 of scroll area 1 of group 3 of window \"OrderWork: Work Order Accept\" of application process \"Safari\""
my doWithTimeout(uiScript)

-- Main calling script
on doWithTimeout(uiScript)
set endDate to (current date) + 2 -- 2 second timeout value
repeat
try
run script "tell application \"System Events\"
" & uiScript & "
end tell"
exit repeat
on error errorMessage
if ((current date) > endDate) then
error "Can not " & uiScript
end if
end try
end repeat
end doWithTimeout


As you can see it is 5 subroutines that are called by the main calling script. What I need help with is...

1. If a routine faults then an error message is raised and execution stops. If I remove the following lines then it simply hangs as it doesn't know what to do. How can I get it to continue to run after an error condition?

if ((current date) > endDate) then
error "Can not " & uiScript
end if


2. How can I get the whole thing to continually loop ad infinitum?
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top