Sending AppleEvent ansr

  • I am porting an application, Tansa, from Carbon to Cocoa.
    The application communicates with another application (InCopy) via
    AppleEvents.
    When running my application from Xcode, everything works fine, but
    running it from Finder, the other application hangs.
    I have traced the AppleEvents in Terminal, and the difference is that
    I do not get the second event (aevt/ansr) when running my Cocoa
    application. Do I have to do anything in the Cocoa application to
    send this AppleEvent back to the other application?

    When running my application from Xcode, I can see both messages in
    the Run Log.

    Ivan

    ------oo start of event oo------
    { 1 } 'aevt':  TANS/gana (i386){
              return id: 687800323 (0x28ff0003)
          transaction id: 0 (0x0)
      interaction level: 112 (0x70)
          reply required: 1 (0x1)
                  remote: 0 (0x0)
          for recording: 0 (0x0)
      target:
        { 1 } 'psn ':  8 bytes {
          { 0x0, 0x6d40001 } (InCopy)
        }
      fEventSourcePSN: { 0x0,0x6d40001 } (InCopy)
      optional attributes:
        < empty record >
      event data:
        { 1 } 'aevt':  - 1 items {
          key '----' -
            { 1 } 'TEXT':  12 bytes {
              "Adobe InCopy"
            }
        }
    }

    ------oo  end of event  oo------
    AE2000 (10495): Received an event reply:
    ------oo start of event oo------
    { 1 } 'aevt':  aevt/ansr (i386){
              return id: 687800323 (0x28ff0003)
          transaction id: 0 (0x0)
      interaction level: 112 (0x70)
          reply required: 0 (0x0)
                  remote: 0 (0x0)
          for recording: 0 (0x0)
      target:
        { 1 } 'psn ':  8 bytes {
          { 0x0, 0x6d00001 } (Tansa)
        }
      fEventSourcePSN: { 0x0,0x6d00001 } (Tansa)
      optional attributes:
        < empty record >
      event data:
        { 1 } 'aevt':  - 0 items {
        }
    }

    Ivan
  • Hmm. When I commented out some of my code, it started sending aevt/
    ansr, so it looks like this is done automatically by Cocoa.
    Something in my code makes the app hanging.
    Sorry about this noise.

    Ivan
  • Ivan C Myrvold wrote:

    > I am porting an application, Tansa, from Carbon to Cocoa.
    > The application communicates with another application (InCopy) via
    > AppleEvents.
    > When running my application from Xcode, everything works fine, but
    > running it from Finder, the other application hangs.
    > I have traced the AppleEvents in Terminal, and the difference is that
    > I do not get the second event (aevt/ansr) when running my Cocoa
    > application. Do I have to do anything in the Cocoa application to
    > send this AppleEvent back to the other application?

    Sounds like there's a bit of confusion here as to how Apple events
    work. To clarify: aevtansr is the reply event sent by the target
    application back to yours when you pass the kAEWaitReply/
    kAEQueueReply flag to AESend[Message](). It's what you unpack to
    extract the target application's result or error value, not something
    that client programs should send themselves.

    ...

    Anyway, if you're rewriting your existing Carbon-based Apple event
    code using ObjC+Cocoa, I'd recommend taking a look at objc-appscript
    which provides a high-level, easy-to-use ObjC wrapper around the
    Apple Event Manager:

    http://appscript.sourceforge.net/objc-appscript

    OTOH, if you're reusing your existing Apple event code largely as-is,
    I'd suggest posting a testable sample section to the AppleScript-
    implementors list [1] and perhaps folks there can spot what the
    problem is.

    HTH

    has

    [1] In theory you should ask on AppleScript-users since it's a client-
    side question, but experienced developers who can best answer C/ObjC-
    related questions tend to be on AppleScript-implementors so I'd ask
    there.
    --
    http://appscript.sourceforge.net
    http://rb-appscript.rubyforge.org
  • On 24 Oct 2007, at 19:26, Hans van der Meer wrote:

    > On Oct 24, 2007, at 20:11, has wrote:
    >
    >> Anyway, if you're rewriting your existing Carbon-based Apple event
    >> code using ObjC+Cocoa, I'd recommend taking a look at objc-
    >> appscript which provides a high-level, easy-to-use ObjC wrapper
    >> around the Apple Event Manager:
    >>
    >> http://appscript.sourceforge.net/objc-appscript
    >
    > This reference seems interesting. However, I was not able to access
    > it.

    Oops, that should've read:

    http://appscript.sourceforge.net/objc-appscript.html

    Apologies for my doziness,

    has
    --
    http://appscript.sourceforge.net
    http://rb-appscript.rubyforge.org
previous month october 2007 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today