Repeat not working inside another tell block
I'm writing a script that will check that an external drive is mounted on boot, and then when it is to run drop box. I noticed when I first wrote the script with
tell application id "com.getdropbox.dropbox" to activate
It didn't always activate? So I found this to make sure it did
on is_running(appName)
tell application "System Events" to (name of processes) contains appName
end is_running
repeat
set safRunning to is_running("Dropbox")
if safRunning then
exit repeat
else
tell application id "com.getdropbox.dropbox" to activate
end if
end repeat
Then I put it inside a check for the volume drive. Then I get this? Any ideas please?
is_running("Dropbox")
--> error number -1708
Result:
error "Finder got an error: Can’t continue is_running." number -1708
on is_running(appName)
tell application "System Events" to (name of processes) contains appName
end is_running
tell application "Finder"
set allDisks to disks
repeat with theDisk in allDisks
if name of theDisk starts with "CloudStorage" then
repeat
set safRunning to is_running("Dropbox")
if safRunning then
exit repeat
else
tell application id "com.getdropbox.dropbox" to activate
end if
end repeat
end if
end repeat
endtell
Mac Pro, OS X El Capitan (10.11.1)