Sorry in advance for the long post, but I thought some of you might like a minature AppleEventShell.
Thanks to David Blache for showing me the "Single AE Handler" technique used in this demo - It will help you cut down the amount of code in the first segment. Remember that if your not a "Rez Tolz" user, then you will have to modify the size resource yourself. Also watch for the longer lines of code being wrapped or split by your mail package.
Jamin
----- Cut Here For Sample Code -------
WINDOW OFF : COORDINATE WINDOW
POKE LONG EVENT-8, 50 ' Use WaitNextEvent
OUTPUT FILE "CoreAppleEventsShell"
DIM gUserQuits%
END GLOBALS
COMPILE 0,_strResource ' Added by Rez
Rez$ = "^SIZE: 500/500"
Rez$ = "^APPLE EVENTS: ON"
Rez$ = "^REMOTE APPLE EVENTS: OFF"
GOTO "End of ENTERPROCs"
"AppleEventHandlers"
ENTERPROC(procAEvtPtr&,procAEvtReplyPtr&,procAEvtRefCon&)
osErr% = _noErr
SELECT procAEvtRefCon&
CASE _"oapp"
PRINT "Open Application AppleEvent"
CASE _"odoc"
PRINT "Open Document AppleEvent"
CASE _"quit"
PRINT "Quit Application AppleEvent"
gUserQuits% = _true
END SELECT
EXITPROC = osErr%
"End of ENTERPROCs"
LOCAL FN InstallAEHandlers
osErr% = _noErr
LONG IF SYSTEM(_sysVers) > 699
LONG IF FN GESTALT(_gestaltAppleEventsAttr)
AEEventProcPtr& = LINE "AppleEventHandlers"
IF osErr% = _noErr THEN osErr% = FN AEINSTALLEVENTHANDLER(_"aevt", _"oapp", AEEventProcPtr&,_"oapp",_false)
IF osErr% = _noErr THEN osErr% = FN AEINSTALLEVENTHANDLER(_"aevt", _"quit", AEEventProcPtr&,_"quit",_false)
IF osErr% = _noErr THEN osErr% = FN AEINSTALLEVENTHANDLER(_"aevt", _"odoc", AEEventProcPtr&,_"odoc",_false)
END IF
END IF
IF osErr% <> _noErr THEN END
END FN
WINDOW 1,"Command Period to Quit"
FN InstallAEHandlers
DO
HANDLEEVENTS
UNTIL gUserQuits%
END