I have some code similar to this:
on run ()
tell application "Google Chrome" to launch
repeat --infinitely when deployed, but only once or twice when developing
-- here are maybe 50 lines of code, including a lot of calls to handlers
end repeat
end run
I want this code to execute differently in two ways depending on whether I develop or if it is deployed:
- The deployed version should run continuously
- 20-25 % of the code in the middle (the 50 lines) shouldn’t be run when I’m testing while I develop.
I develop and deploy on different machines, therefore (2) can be handled with something like this surrounding code that only should be executed when deployed
if (computer name of (system info)) is "deploymachine" then
--code that only should be ran when deployed
end if
but that doesn’t work when I want to execute
repeat
or
repeat 3 times
(with corresponding end repeat
)
depending on if it is deployed or in development.
I could create two handlers main-deployed
and main-development
and call them early on in the main
-handler but that would require me to duplicate a lot of code, and there are a lot of code changes in the main loop, which would force me to continuously sync changes between these two handlers.
Are there some smart ways around this?