I’m an applescript noob, and I am trying to hack on a file conversion script I’ve found on the net (AppleWorks 5 to Pages)
I need to convert a gazillion files, and retain the directory structure.
I’ve got three different Macs this thing will not run on (Intel OSX 1.4, G4 OSX 1.2 w/ AW6, and a G(?) running OS 9.
From doing some of this manually, I’m pretty sure I’m already in for having to running scripts on one of the two older machines to
do the AW5 ->AW6 conversion; then copying the folders and
files onto the Intel, and running another script. Since the script I’ve got can do both steps of the conversion, I’d rather hack once,
and run it on both architectures. Problem is right now it will not run on any of these machines.
I suspect I don’t need all of the code. Is there a way to get sections of code to compile/not based on which machine its running on?
AppleScript code is not machine dependent. It is Application dependent.
I may have not asked this question pedantically right, but I hope I expressed what I want to do in a way that someone can give
me an answer. Is there a way to do this?
Can I set this code up so that when I compile & run it on one machine which has certain applications on it,
the code will successfully compile/run even though the code has sections which refer to other applications which are
not available on that machine?
Thanks in advance…
Just comment out the sections that you do not want run on that machine.
Otherwise, when you try to compile the script, it is going to ask you to find the “Missing Application.” If you simply comment out those sections, you can compile and run the script fine - so long as the script is not dependent on those commented out sections for the successful continuation of the script.
tell application "Finder"
display dialog "hello."
tell application "Missing App"
tell application "Finder"
display dialog "all done."
Yes and no.
First of all AppleScript code is dependent on its own version. Pure AppleScript code
won’t compile on a Tiger machine if it contains terms of AppleScript 2 introduced in Leopard.
Even a compiled script on Leopard could crash on Tiger, and a carbon application script compiled on an Intel machine
won’t launch on PPC and vice versa
But you’re right, it depends also on the installed applications
I’d recommend to write only code which is available in all used AppleScript versions and compile the script once on a machine with all required applications.
Write code which checks the existence of specified applications and skip the appropriate application tell blocks or use precompiled script objects to be loaded dynamically