home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Add-Ons / AppleScript / Fragen / Fragen.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-21  |  1.6 KB  |  57 lines  |  [TEXT/MMCC]

  1. #include <AppleEvents.h> 
  2. //enum {
  3. //    uppMainEntryProcInfo = kPascalStackBased
  4. //         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  5. //         | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(AppleEvent *)))
  6. //         | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(AppleEvent *)))
  7. //         | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long *)))
  8. //};
  9. //
  10. ////This is necessary for an accelerated resource (if it were one)
  11. //ProcInfoType    __procinfo = uppMainEntryProcInfo;
  12.  
  13. pascal OSErr main(    AppleEvent *theAEEvent, AppleEvent *theReply, long *theRefCon) 
  14. {     
  15.     OSErr            theErr = noErr;     
  16.     Boolean            result = false;
  17.     AEEventHandlerUPP            JunkA;
  18.     long            JunkB;
  19.     unsigned char    tempstring[8]="mongfrag";
  20.     AEKeyword        AEClass;
  21.     AEKeyword        inType;
  22.     AEKeyword        AEid;
  23.     Size            theMaxSize,theSize=8;
  24.     
  25.     if ( theReply->dataHandle != NULL )
  26.     {
  27.         theMaxSize=8;
  28.         
  29.         theErr =  AEGetParamPtr (theAEEvent,keyDirectObject,typeChar,&inType,(Ptr)&tempstring,theMaxSize,&theSize);
  30.  
  31.         if (theErr) return theErr;
  32.         if ((theSize !=8)&&(theSize!=4)) theErr=errAEEventNotHandled;
  33.         if (!theErr)
  34.         {
  35.             if (theSize == 4)
  36.                 AEid='xist';
  37.             else
  38.                 AEid=(long)tempstring[4]*256*65536+(long)tempstring[5]*65536+(long)tempstring[6]*256+(long)tempstring[7];
  39.  
  40.             AEClass=(long)tempstring[0]*256*65536+(long)tempstring[1]*65536+(long)tempstring[2]*256+(long)tempstring[3];
  41.     
  42.             if (noErr==AEGetEventHandler (AEClass,AEid,&JunkA,&JunkB,true))
  43.                 result=true;
  44.             else
  45.                 result=false;
  46.             theErr = AEPutParamPtr(theReply, keyDirectObject, typeBoolean, 
  47.                     &result,  sizeof(result));
  48.  
  49.          }
  50.     }
  51.     else
  52.         theErr = errAEEventNotHandled;
  53.                                  
  54.     return theErr;
  55.         
  56.  }
  57.