home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / mac / programm / 12906 < prev    next >
Encoding:
Internet Message Format  |  1992-07-22  |  4.0 KB

  1. Path: sparky!uunet!comp.vuw.ac.nz!waikato.ac.nz!ldo
  2. From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: appleevents to hypercard
  5. Message-ID: <1992Jul23.180919.9580@waikato.ac.nz>
  6. Date: 23 Jul 92 18:09:19 +1200
  7. References: <1992Jul21.171805.13264@kronos.arc.nasa.gov>
  8. Followup-To: joshr@kronos.arc.nasa.gov
  9. Distribution: comp.sys.mac.programmer, comp.sys.mac.hypercard
  10. Organization: University of Waikato, Hamilton, New Zealand
  11. Lines: 105
  12.  
  13. In article <1992Jul21.171805.13264@kronos.arc.nasa.gov>, joshr@kronos.arc.nasa.gov (Joshua Rabinowitz-Summer-91) writes:
  14. > I have included
  15. > sample source code, written in think c 5.02, that I believe shoud
  16. > send the string "hello" to hypercard.
  17.  
  18. Yeah, but what do you expect HyperCard to do with the string? If you want it
  19. to display it, then you have to send it a complete HyperTalk command to do so,
  20. such as
  21.  
  22.     answer "hello"
  23.  
  24. or
  25.  
  26.     put "hello"
  27.  
  28. >  I receive a -609 error (connection is invalid) when I get the AESend().
  29.  
  30. Hm, I can't find error -609 anywhere in my interface files.
  31.  
  32. > I believe part of the problem may be
  33. > that Im not sure if hypercard's signature is STAK or WILD (or is it something
  34. > else?), and i'm not sure about the aetype and just how to load the AEAddress
  35. > descriptor.
  36.  
  37. No, you're right, the signature is WILD. STAK is the file type for HyperCard
  38. stacks.
  39.  
  40. >
  41. > ---------------- following is attempted test code ------------
  42. > #include <AppleEvents.h>
  43. > #include <stdio.h>
  44. >
  45. >
  46. > #define kHypercardSignature 'WILD'
  47. >
  48. > #define FailOSError(value) if(value){printf("OSError %ld\n", (long)value);exit(1);}
  49. >
  50. > pascal OSErr myEventHandler(AppleEvent *event, AppleEvent *reply, long ref);
  51. > void main(void);
  52. > void unneeded(void);
  53. > pascal Boolean myIdleProc(EventRecord *theEvent, long *sleepTime, RgnHandle mouseRgn);
  54. >
  55. > void main(void)
  56. > {
  57. >   // from Programming for SYS7, p. 145
  58. >    // pseudocode:
  59. >
  60. >    // determine target address using PPCBrowser() or GetNextProcess() and GetProcessInformation()
  61. >
  62. >    // create address descriptor from above info
  63. >
  64. >    // create apple event with AECreateAppleEvent() and pass it address descriptor
  65. >    //  use AEManager to add descriptors with AEPutParamPtr or AEPutParamDesc
  66. >
  67. >    // call AESend
  68. >    // check for errors
  69. >    // dispose of copies of descriptor records
  70. >    // process the AEReply
  71. >
  72. >    // need appleeventhandler on the other side.
  73. >
  74. >
  75. >    AEDesc theAddressDesc;
  76. >    AppleEvent theAE, theReply;
  77. >    OSErr myError, sendError;
  78. >
  79. >
  80. >    printf("PRINTF\n");
  81. >
  82. >    myError = AECreateDesc(typeApplSignature, (Ptr)kHypercardSignature,
  83.  
  84. No, you have to pass the address of a longword containing the signature.
  85. What you've done is typecast the signature itself to a garbage address!
  86.  
  87. >       sizeof(kHypercardSignature),  &theAddressDesc);
  88. >       // loads into address desciptor
  89. >    FailOSError(myError);
  90.  
  91. >
  92. >    myError = AECreateAppleEvent(kCoreEventClass, typeChar, &theAddressDesc,
  93.  
  94. You're creating an event of class "aevt" and ID "TEXT". I don't recall seeing
  95. such an event anywhere in my copy of the AppleEvent Registry. If you want
  96. HyperCard to execute a HyperTalk sequence, you need an event of class "misc"
  97. and ID "dosc" (do script).
  98.  
  99. >       kAutoGenerateReturnID, kAnyTransactionID, &theAE);
  100. >    FailOSError(myError);
  101. >
  102. >    myError = AEPutParamPtr(&theAE, keyDirectObject, typeChar, "hello", 5);
  103. >    FailOSError(myError);
  104.  
  105. This part looks fine, except the string should be a valid piece of HyperTalk
  106. for a misc:dosc event. Try replacing the "hello" with either "answer \"hello\""
  107. or "put \"hello\"". On the other hand, if HyperCard reports an error because
  108. it can't understand the message you sent it, then you know the event is
  109. getting through!
  110.  
  111. [rest of the code deleted, as it's probably OK. :-)]
  112.  
  113. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  114. Computer Services Dept                     fax: +64-7-838-4066
  115. University of Waikato            electric mail: ldo@waikato.ac.nz
  116. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  117. Does "future-proof" strike you as a phrase that can be taken two ways?
  118.