I’ve adopted a safety technique for my scripts.
It’s simple enough to do: When a script version gets to some fairly stable point, I copy the text over to a text file and save it with the same name and a .txt extension.
This protects me against opening the script, usually after some system change, and seeing all the raw Apple Event codes (the ones with the double chevrons) instead of high level applescript language.
I was wondering whether this trick was commonly used or, conversely, isn’t necessary because of some trick that I don’t know to translate raw event codes back to English. But it’s saved me on several occasions (including just now).
Does anyone else do this step or is it superfluous?
You might notice that one of the menu picks in the Save dialog is text. That does what you want without the necessity of a text editor and copying. The result looks like “myScript.applescript” and belongs to the Script Editor, but will open with any text editor.
Using the Save As Text feature won’t translate the Apple Event Codes back into straight English, will it?
The point isn’t how you make the text file – which is certainly simple enough using either approach. The point is doing it at all. It’s a safety back-up so that when you suddenly get a line like:
«event CAROsnfo» document firstDocumentName given «class inky»:“Author”, input volume:copyrightString
You can go to the text back-up and get the version:
set info document firstDocumentName key “Author” value copyrightString
For me, anyway, turning the first line back into the second is a bit of a head-scratcher. And if a whole script is like that, it might be better to start over.
What application is that for? Something like this doesn’t cause me any problems:
«event sysodlog» "Test"
That little snippet is actually between a tell block targetted to Adobe Acrobat version 6. When I switched over to Acrobat 8, I got the raw Apple Events.
Actually, this particular bit of code has been more troubling because it won’t compile properly. It insists on rewriting the
… key “Author” value copyrightString
part, changing it into
… key “Author”, input volume:copyrightString
And then failing on the compile with an error. So then I rewrite the input volume: part back to value and save and everything’s fine. Next time I change something else and try to save/compile, I go through the same thing.
That’s strange, but I digress.
So do you scriptors save text versions of your significant Applescripts or is there’s some trick to translating raw Apple Events which makes this pointless?