[Pythonmac-SIG] Need help with AppleEvent bug

bill fancher bfancher@mac.com
Wed, 11 Sep 2002 18:34:04 -0700


On Wednesday, September 11, 2002, at 03:00 PM, Jack Jansen wrote:

> Folks, I need help from some AppleScript gurus. Robin Siebler posted 
> bug http://www.python.org/sf/598981 which has to do with a get() call 
> to CodeWarrior to get the data of the frontmost window returning None. 
> Bill Fancher suggested that this might have to do with Python not 
> supporting the cText AppleScript type, but that would have shown up 
> differently: you would have gotten a return value, but of type 
> aetypes.Unknown('ctxt', 'raw data').

I'm afraid there's been some noise in the transmission lines. Be that 
as it may...

CodeWarrior is like TextEdit (and other Cocoa Apps) used to be: a 
document has text elements. According to the CodeWarrior dictionary, 
you can only refer to a range of them. AppleScript hacks^H^H^H^H^H 
works around this somehow (I suspect the same way it did with 
TextEdit). It appears that you can also refer to the text elements by 
number. It further appears that the one of interest is the first one. 
So...

The following works here, assuming CodeWarrior is running and has an 
open document (Mac OS X 10.2, Python 2.3, CW IDE 4.0.4):

import CodeWarrior

cw = CodeWarrior.CodeWarrior()
txt = CodeWarrior.editor_document(1).text(1)
print cw.get(txt)

It might be worth pointing out that my CW is old enough that it runs 
only in Classic, so YMMV with later Carbon versions.

--
bill

> I ran the thing under the debugger, and it turns out the reply 
> AppleEvent from AESend() indeed doesn't have a '----' parameter, and 
> it doesn't have an 'errn' error code either. So, returning None is the 
> right thing to do. But the corresponding AppleScript works fine...
>
> Now I very vaguely remember something about there being a second 
> protocol for sending replies to AppleEvents (maybe for long replies >= 
> 32K? I don't remember... And maybe I'm completely confused with 
> something else, like the funny CGI protocol with AppleScript) but I 
> can't find anything after looking through the documentation.
>
> So, to sum it up, I'm out of my water and need a bit of help. The bug 
> report has everything you need to reproduce this.
> --
> - Jack Jansen        <Jack.Jansen@oratrix.com>        
> http://www.cwi.nl/~jack -
> - If I can't dance I don't want to be part of your revolution -- Emma 
> Goldman -
>
>
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
>