OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Applescript looping and error messages


Post Reply New Thread Subscribe

 
Thread Tools
pcsupport

 
Member Since: Apr 28, 2011
Posts: 1
pcsupport is on a distinguished road

pcsupport is offline
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?
QUOTE Thanks

Post Reply New Thread Subscribe


« Xcode - Newbie | Eventual game design »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

All times are GMT -4. The time now is 01:32 AM.

Powered by vBulletin
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?