What am I doing wrong here?

this is bizarre…

When I save this all colors up nicely. Except the Catch?

If I comment out the little android typing handler it works… I’m sure I’m missing something obvious. ???

try
	
	AndroidTypeText formattedTime("%m/%d/%Y", the date + 30 days) 
	
to AndroidTypeText text2Type
	put the remoteWorkInterval into RWI
	set the remoteWorkInterval to the nextKeyDelay
	repeat with each character of text2Type
		if it is not "/" then
			typeText it
		else
			If ImageFound (2.0, "AndroidInputToggle")
				Click "AndroidInputToggle"
			End if
			Click "AndroidForwardSlash"
		end if
	end repeat
	set the remoteWorkInterval to RWI
end AndroidTypeText

catch -- FAIL

Put "whatever"

end try

You can’t wrap a handler in a try catch block. There’s a bunch of things to explain here: The handler is called and executed in it’s own space – the try isn’t even part of what’s being executed/evaluated. All the code in a script that isn’t in a handler has to appear before the first handler is defined. That code is referred to as the initial handler. Any “bare” code that you put in a script after a handler has been declared is ignored. So in this case, the code that your “try” statement appears in ends at the “to” where you declare your AndroidTypeText handler. If you want to catch any exception that’s thrown during the execution of that handler, then your code should look like this:

try   
   AndroidTypeText formattedTime("%m/%d/%Y", the date + 30 days)
catch -- FAIL
    Put "whatever"
end try
 
to AndroidTypeText text2Type
   put the remoteWorkInterval into RWI
   set the remoteWorkInterval to the nextKeyDelay
   repeat with each character of text2Type
      if it is not "/" then
         typeText it
      else
         If ImageFound (2.0, "AndroidInputToggle")
            Click "AndroidInputToggle"
         End if
         Click "AndroidForwardSlash"
      end if
   end repeat
   set the remoteWorkInterval to RWI
end AndroidTypeText

This way the command is being executed from the initial handler in the context of the try/catch block.

Thanks! Good explanation… as you can see… I learn as I go…