1 /* Handle required apple events -EAD */
2
3 #include <Files.h>
4 #include <string.h>
5 #include <AppleEvents.h>
6 #include "macstuff.h"
7 #include "MacCommandWin.h"
8 #include "MacFileUtils.h"
9 //#include "MiscellaneousUtilities.h"
10
11 #define TEXTREC (*hTERec) // the command
12 extern TEHandle hTERec; // window text record
13
14
15 //=========================================================================
16 // Handle quit apple event
17 //=========================================================================
18
AEQuit(AppleEvent * theAppleEvent,AppleEvent * theReply,long Refcon)19 pascal OSErr AEQuit (AppleEvent *theAppleEvent, AppleEvent *theReply, long Refcon)
20 {
21 osfinish();
22 }
23
24 //=========================================================================
25 // Handle Open Document apple event by trying to load it.
26 //=========================================================================
27 extern xlload (char *, int, int);
28 extern xlabort(char *);
29
AEOpenFiles(AppleEvent * theAppleEvent,AppleEvent * theReply,long Refcon)30 pascal OSErr AEOpenFiles(AppleEvent *theAppleEvent, AppleEvent *theReply,
31 long Refcon)
32 {
33 AEDescList docList;
34 AEKeyword keywd;
35 DescType returnedType;
36 Size actualSize;
37 long itemsInList;
38 FSSpec theSpec;
39 CInfoPBRec pb;
40 Str255 name;
41 short i;
42
43 if (AEGetParamDesc(theAppleEvent, keyDirectObject, typeAEList, &docList) !=
44 noErr) return;
45 if (AECountItems (&docList, &itemsInList) != noErr) return;
46
47 SetSelection (TEXTREC->teLength, TEXTREC->teLength);
48 for (i = 1; i <= itemsInList; i++) {
49 AEGetNthPtr (&docList, i, typeFSS, &keywd, &returnedType,
50 (Ptr) &theSpec, sizeof(theSpec), &actualSize);
51
52 GetFullPath(&theSpec, name);
53 P2CStr(name); // was: pstrterm(name);
54 if (xlload ((char *)name + 1, 1, 0) == 0) xlabort ("load error");
55 }
56 macputs ("> ");
57 PrepareForInput ();
58 }
59