100 rem MacOS Chipmunk Basic 3.4.5 AppleEvent receive and respond 110 ' this untested program might respond to CGI appleEvent 200 ' 220 dim ss$(15),rr$(15) 222 crlf$ = chr$(13) + chr$(10) 238 ' 240 rem AppleEvent receive filter template 250 ' 260 ss$(0) = "aE>WWWO<>sdoc<" 280 ss$(1) = "eval makehtml$()" 290 ss$(2) = "aE>TEXT<>----< path args here" 292 ss$(3) = "aE>TEXT<>kfor< search arguments" 294 ss$(4) = "aE>TEXT<>post< post arguements" 296 ss$(5) = "aE>TEXT<>meth< method" 298 ss$(6) = "aE>TEXT<>scmn< script name" 300 ss$(7) = "aE>TEXT<>refr< referer URL" 302 ss$(8) = "aE>TEXT<>Agnt< WWW client & version" 320 ss$(9) = "" : ss$ = "" 330 ' 390 rem AppleEvent result template 392 ' 400 rr$(0) = "return 0" ' no error 410 rr$(1) = "aE>TEXT<>----<" : ' direct parameter 420 rr$(2) = "" 430 rr$(3) = "" : rr$ = "" 440 ' 490 rem wait for an event 492 ' 500 call "setAEReceive",ss$ ' use ss$ as ae receive filter 505 while inkey$ <> "q" 520 call "wait",0.1 540 wend 590 ' 600 rem print out some status 602 gotanevent: print "I got an event ",date$,time$ 610 for i = 0 to 8 : print ss$(i) : next i 615 print 620 return 690 end 790 ' 792 rem subroutine to create an HTML page 798 ' 800 sub makehtml$() 810 gosub gotanevent: 820 r$ = "aE>TEXT<>----<" 830 r$ = r$ + "HTTP/1.0 200 OK" + crlf$ 832 r$ = r$ + "Server: WebSTAR/1.0 ID/ACGI" + crlf$ 834 r$ = r$ + "MIME-Version: 1.0" + crlf$ 836 r$ = r$ + "Content-type: text/html" + crlf$ + crlf$ 838 ' 850 r$ = r$ + "test" + crlf$ 852 r$ = r$ + "

test

" + crlf$
854   for i=2 to 8
856     r$ = r$ + ss$(i) + crlf$
858   next i
860   r$ = r$ + "
" + crlf$ 880 rr$(1) = "aE>TEXT<>----<" + r$ 882 call "setAEResult",rr$ 884 makehtml$ = "" 890 end sub 980 end