[OS X TeX] Flashmode-Alpha Trial version

Jon Guyer jguyer at his.com
Wed Jan 5 07:12:59 EST 2005

On Jan 4, 2005, at 1:45 PM, Claus Gerhardt wrote:

> The developers of AlphaX obviously never thought that AlphaX itsself 
> might be the target of Applescripts.

With gratuitous and uniformed cracks like that, it sure makes me glad I 
offered to help. 8^P

>  Alpha's Applescript dictionary contains only a minimal amount of 
> classes and commands;

Ultimately, Alpha is scripted in Tcl, not in AppleScript. You can 
control and query absolutely every aspect of Alpha via the AppleScript 
"DoScript" command.

You also can easily add in any way you like to Alpha's 
AppleEvent/AppleScript interface *dynamically, at runtime* with a 
little bit of Tcl code.

> Notice that 'Enable access for assistive devices' has to be checked in 
> 'Universal Access'.

??? That's certainly no requirement on Alpha's part.

> It would be more satisfactory, if the following Applescript commands 
> (and properties) could be implemented in AlphaX (considered only as 
> target)
> 1. get path of front document --unix path

That's not good AppleScript. This is:

set f to file of front document
get POSIX path of f

Paths are not properties of documents, they're properties of files. 
Files are (possibly) properties of documents.

Add the following to your prefs.tcl file (Config -> Preferences -> Edit 
Prefs File) and hit command-L:


tclAE::installEventHandler core getd aeom::handleGet

proc aeom::handleGet {theAppleEvent theReplyAE} {
     set objDesc [tclAE::getKeyDesc $theAppleEvent ----]
     set token [tclAE::resolve $objDesc]
     switch -- [tclAE::getDescType $token] {
         "CHAR" {
             set text [eval getText [tclAE::getData $token]]
             tclAE::putKeyData $theReplyAE ---- utf8 $text
         "WIND" {
             tclAE::putKeyDesc $theReplyAE ---- $objDesc
         "FILE" {
             set fileDesc [tclAE::build::path [tclAE::getData $token]]
             tclAE::putKeyDesc $theReplyAE ---- $fileDesc
         default {
             error -code –1708

tclAE::installObjectAccessor prop WIND aeom::accessor::prop<WIND

proc aeom::accessor::prop<WIND {desiredClass containerToken 
containerClass keyForm keyData theToken} {
     set win [tclAE::getData $containerToken ****]

     switch -- [tclAE::getData $keyData type] {
         "file" {
             if {[win::IsFile $win file]} {
                 tclAE::replaceDescData $theToken FILE $file
             } else {
                 error -code –1728
         default {
             error -code –1708

# fixes a bug in the shipping version
proc aeom::accessor::cwin<null {desiredClass containerToken 
containerClass keyForm keyData theToken} {
     set wins [winNames]

     switch -- $keyForm {
         "name" {
             set winNum [lsearch $wins [tclAE::getData $keyData TEXT]]
             if {$winNum < 0} {
                 error -code –1728
         "indx" {
             # absolute positions are 1-based
             set winNum [expr {[tclAE::getData $keyData long] - 1}]

             if {($winNum >= [llength $wins]) || ($winNum < 0)} {
                 error -code –1728
         default {
             error -code –1708
     tclAE::replaceDescData $theToken WIND [lindex [winNames -f] $winNum]


At least at present, you can't write

get POSIX path of file of front document

I'm not sure whether this is a failing in the AppleEvent Object Model 
(I think so) or a problem in Alpha's AEOM resolution code.

> 2. if document texName is modified then

... something got lost here...

--------------------- 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 MacOSX-TeX mailing list