http://qs321.pair.com?node_id=1216744


in reply to How to write apps for macOS/OSX in Perl!

Automator! It's simultaneously awesome and horrible. It has many powers and quirks. Here are some notes on functionality and issues to watch out for:

If you can't see code: Close the Library.

If you can't see Library items: Click "hide description" icon bottom left (or resize its frame).

The Hammer Icon checks syntax and indents your code (if syntax passed). It also does odd things sometimes like rename all instances of a particular uppercase variable to lowercase (but only some variables).

Debug Applescript with try blocks that propogate the error:

try something on error oops # <- oops is my pet name for the error msg :-) display alert oops as critical # let's see wtf display alert MyData # examine some data structure #return # maybe exit too, while debugging end try
Debug Perl the usual ways but, I have to mention something WEIRD about shell. It seems like an Automator bug but who knows. Sometimes the code inside a do shell script stops working for no apparent reason. Nothing is wrong with the previously working code, it was not changed, and it does not work. The solution to this crazy problem is equally crazy: erase the problem code and rewrite the do shell script part by actually typing, then paste your Perl back into place.

Automator has a spectacular built-in Time Machine (that every program should have)! You can restore any version of the file. It's simply magnificent.

Be very careful about using the Play button to test scripts. If you have an infinite loop it can get stranded. You may be able to break out with dot (Command .) or you may have to kill Automator. Luckily the revision system means you'll lose never lose data if it crashes or gets killed. It usually works fine but when Automator crashes on me it's always when going back through multiple levels of undo (Command Z). That crash can be ignored but you have to restart the program to fix undo.

Background apps made with Automator get a cool free animated gear icon in the system menubar! Click the gear to exit or, in some cases, monitor its progress. Love your Gear!