[OS X TeX] applescripts for TeXShop and iTeXMac?
Will Robertson
will at guerilla.net.au
Sat Aug 28 05:08:56 CEST 2004
On 28 Aug 2004, at 4:43 AM, Matthew Hills wrote:
> Any advice on writing scripts that will run on both TeXShop and
> iTeXMac?
>
> While I can write a script that can run from both environments, there
> is an unfortunate tendancy for the both applications to be opened when
> the scripts are compiled (presumably to access the relevant
> dictionaries?).
As of half and hour ago I thought it couldn't be done robustly. I'm
still pretty sure of this, now. I originally trying distributing my
column macros as dual-app scripts, but there are two problems:
1. If you call things directly with
tell application "TeXShop"
...
end tell
tell application "iTeXMac"
...
end tell
If a user doesn't have one of these programs installed, even if the
code in question will never run for them, the script returns an error
asking for the location of the missing application. People with only
one of the two apps on both sides of the fence emailed me about this.
2. So, you'd think that you could fix this, as you suggested, with
texapp = "TeXShop"
tell application texapp
...
end tell
But now Applescript can no longer find the applescript dictionaries of
the individual apps. The following fails in Script Editor, for example:
set texapp to "iTeXMac"
tell application texapp
activate
insert "hello" in the text of the front document
end tell
However, it DOES work in iTeXMac!
For both apps, you want something like this:
set texapp to "iTeXMac"
set newtext to "hello"
tell application texapp
activate
if texapp = "iTeXMac" then
insert newtext in the text of the front document
else if texapp = "TeXShop" then
set the content of the selection of the front document to newtext
end if
end tell
HOWEVER, this does not work in TeXShop. Dammit! So close. If you can
work anything else out, I'd love to hear it. If you can work out where
the problem is in TeXShop, you could get Richard Koch to fix it in a
subsequent release...that's beyond my level at this stage,
unfortunately.
Best of luck,
Will Robertson
--------------------- Info ---------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
& FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>
More information about the macostex-archives
mailing list