[OS X TeX] Applescript changes in TS

Michael Sharpe msharpe at ucsd.edu
Sat Dec 31 01:37:59 EST 2011


I have a number of applescripts that work correctly from the Applescript Editor but fail with strange error messages when run from the TeXShop Macro Menu with header 

--Applescript direct

I tracked down two of the problems that were show-stoppers for me:

(i) length no longer functions correctly with either strings or lists in the Macro Menu, though it does under Applescript Editor. You need to change all instances of length to count. (This affects several macros distributed with TeXShop.)

(ii) offset is not functional under the Macro Menu (no problem under AppleScript Editor), and I replaced it in my macros with the function stroffset:

on stroffset(find_str,whole_str) 
	if (count of whole_str)=0 then return 0
	if (count of find_str)=0 then return 0
	set tid to Applescript's text item delimiters
	set Applescript's text item delimiters to {find_str}
	set lst to text items of whole_str
	set Applescript's text item delimiters to tid
	if (count of lst)=1 then
		return 0
	else
		return (count of (item 1 of lst)+1)
	end if
end stroffset

I'd appreciate any postings of other fixes as it's a tiresome business to track down Applescript errors that occur only in the Macro Menu. A couple of scripts I just fixed are available at

http://math.ucsd.edu/~msharpe/fontset.dmg

They may be useful to those who have large collections of fonts and wish to be able to switch a saved set of fonts quickly. (To install, select Macros/Macro Editor, then select Macros/Add Macros from file, selecting each .plist from the dmg as the target.)

Michael




More information about the MacOSX-TeX mailing list