FFFF000000060001001277AA000000000073000000001001210000001-7FFF6EBE0Â480048021FB20Á-169E069E369E069E31E470Â21FB2248FFFF01020001000003250000000C09264084023522488DD04CE00034223521C1092611C340840352259224887D04CE0005822592BD011C31A1C4084059227F224885504CE0007E227F21701A1C2252408407F22AB22487F504CE000AA22AB2184022522A9D40840AB22D3224880504CE000D222D321B402A9D32C840840D322F222487E204CE000F122F221DC032C83AF440840F22211D22487E204CE00011C2211D21CD03AF443034084011D2213E22487C604CE00013D2213E21CB043034B184084013E2216122487CB04CE0001602216121D504B185320408401612218222487C004CE0001812218221BB053205AC040840182221A1224875804CE0001A0221A121BF05AC069E3408401A1221FB2248EAE048E0001FA221FB2A6000020000092C00000000 926,The Prospects of HCGS as a Web Broswer for the IIgs?????? or Using HyperCard as a CGI application December 15, 1999 By Macprober Reading a post in the Mac Hypercard newsgroup that presented the question of HyperCard as a Web Browser function with the use of a HC stack and the following website URL was given with the suggestion to pay a visit to review the information offered from it. So, I payed a visit to it and have included the main content from the web page for readers to review, think about and comment on. I hope some of you will find it interesting, stimulating and of some potential value. See the reference and web pages contents outlined in full below. --------------------------------------------------------------------- http://yeamob.pci.chemie.uni-tuebingen.de/HyperCGI.html Using HyperCard as a CGI application Some tips and tricks „About CGI „Overview: What HyperCard has to do as a CGI application „The basic handler step by step „Basic HyperCard setup „Optimizing the setup „My use of HyperCard as a CGI application „Other sites using HyperCard as a CGI application/HyperCard CGI Examples „My HyperCGI example: an address database „Some HyperCard sample code „Feedback? About CGI CGI (Common Gateway Interface) is a standard for the communication of Web servers with other programs, allowing the output of dynamic information. These programs, usually labelled with the suffixes .cgi or .acgi, process data received from the client via the server (e.g., they enter data into a database which have been submitted as a form entry) and/or reply in response to information provided by the client (either by constructing and sending a complete page, or by sending a http address (URL redirection) which the client then requests; the client information is not restricted to user input, you can determine the client software and return a page optimized for the respective client). Many complete CGI applications are available for different purposes, most of them as Freeware. If none of those can perform the tasks you need, it is up to you to write your own CGI application. If you are a "real" programmer, Perl or C/C++ definitely are the way to go. Then there are AppleScript, much easier to program in (especially when you start with Jon Wiederspan's wonderful tutorial) and Frontier, but their 0002000008A300000926 89D,applications are far slower than those compiled from C. StarNine (makers of WebStar) provides a list of tutorials and examples about producing CGI applications in any of those languages. And finally there is HyperCard. It is definitely the easiest way for a non-programmer to start with, and while it is far slower than a C-based CGI application, it does not compare unfavourably with AppleScript (to say it cautiously) if you optimize the setup. And if you want your CGI application to link a simple database to the Web, you are much better off using HyperCard's own database abilities (including its fairly fast "find" command) than to program your own database tools. Many tasks can be accelerated enormously when you use an external command (XCMD/XFCN) for the time critical step, and there are loads and loads of these available (it would be unfair from me not to note that AppleScript and Frontier also make use of similar externals). I know of two ways of communication between WebSTAR/MacHTTP and Hypercard: directly via an Apple event, or indirectly via an AppleScript CGI application which is called by WebSTAR and then uses Apple events to communicate with HyperCard. The only reason to use the indirect strategy I can think of is that something must be done which HyperCard can't do, but AppleScript can (and probably an Xternal exists somewhere which allows to do it in HyperCard), otherwise, the longer chain of programs will run slower and will be more prone to crashes and timeouts. In a word: I use and will describe only the direct communication (and I have no experience with server software other than WebSTAR/MacHTTP, so I have no idea whether the following is true for other Mac Web servers). To write a CGI application in any language, you must know what kind of data you will have to deal with. Jon Wiederspan's tutorial contains so much basic information about how CGI applications work (and is easy and fun to read) that you should check it out even if you intend to script your Web site using Hypertalk only. He describes in detail what kind of data (arguments) are transmitted and in which format, so there is no need for me to repeat it here. 00020000085F000011C3 859,Overview: What Hypercard has to do as a CGI application WebSTAR will send its SEARCH or POST data (you had a look at the Wiederspan pages?!) packed up in an Apple event. In HyperCard this triggers the appleEvent system message which you will have to deal with in an "on appleEvent...end appleEvent" handler. The Apple event can be identified by its parameters class, id, and sender which can (and should) be used to make sure that the incoming event really comes from WebSTAR (don't forget to let other Apple events pass). The enclosed data of the Apple event are extracted with the command "request ae data" (returns the path args) respectively "request ae data with keyword" (keyword "meth" returns the method: POST or GET, "post" returns the post args, "kfor" returns the search args, etc.). Your script now has to parse (extract the data and put them into the correct containers) and decode (convert + to space, and convert the coded characters from %##) these data, then you can process them ad libitum (e.g., enter them into your database or use them to search your database). Finally, produce an answer (either a complete HTML document or a redirect to an existing document) and send it back to WebSTAR with "reply yourAnswer". Because the returned data are passed to the client without further processing by the server, you have to provide them with a header (WebSTAR does that for the http documents it reads from disk before it sends them to the client) which describes whether a document (header contains "200 OK") or an address (header contains "302 FOUND") is returned. Omitting the "200 OK" header spares time and usually gives no problems, just like crossing a street when the traffic lights are red... The basic handler step by step The handler has to grab the Apple event on appleEvent class, eventID, sender (...end appleEvent) verify it is a sdoc event from the server if class & eventID is "WWWàsdoc" then (...else_pass appleEvent_end if; the letter after WWW is a capital Omega) extract the relevant data request appleEvent data -- get (and evaluate) the direct parameter (path args) and 00020000083C00001A1C 836,request appleEvent data with keyword "post" -- post args (...put it into postArgs) or request appleEvent data with keyword "kfor" -- search args (...put it into searchArgs) the post args will have to be parsed and decoded set the itemDelimiter to "&" repeat with Element = 1 to the number of items of postArgs if char 1 of item Element of postArgs is "I" then put URLDecoder(item Element of postArgs) into Input put empty into char 1 of Input -- remove inputName=; I use 1 letter names put empty into char 1 of Input ... repeat for all possible elements while the search args have only to be decoded put URLDecoder(searchArgs) into searchFor do whatever you want to (search with them, add them to a database, control other programs, use them to direct your video camera...) produce either a complete http document or redirect to another http file put Header & Sheet & Footer into answerDoc -- here is some work to do: it is your business to mingle the data you want to display with the appropriate HTTP tags send it back to the server reply answerDoc Basic HyperCard setup, adapted from Chuck Shotton's CGI Demo Stack Put an alias to HyperCard (version at least 2.1) into the same folder as WebSTAR respectively MacHTTP, and name it "HyperCard.acgi"; put the HyperCard stack with the "on appleEvent" handler ("CGI-Stack") into the same folder. Start HyperCard by dragging the CGI-Stack on the HyperCard.acgi alias. A form which calls the CGI-Stack should contain