Writing ACGIs with MacApp
Volume Number: 14
Issue Number: 3
Column Tag: Webtech
Writing ACGIs with MacApp
by Klaus Halfmann
It's easy and done fast using the simple class introduced in
this article
Introduction
I recently was (and still am) working on a project involving a database to be used on
the web. I had a short look at [Develop #29, March 1997] High Performance ACGIs in
C by Ken Urquhart, but decided against it, for several reasons.
• I don't like to leave the familiar environment of MacApp.
• I want to use C++ not C.
• It would have been more difficult to dig into new ground than just using
MacApp.
• Performance was not such an issue (and we will see that we still can have
reasonable speed).
I thought it would take me about a week to implement the ACGI interface but found that
after two days I was ready with a skeleton ACGI. Because MacApp needs more support I
decided to publish this article. So, maybe some older MacApp Applications can be found
on the web soon.
I use MacApp R12, since R13 was not in a state to be used at the time I started my
project. I do not expect major changes in the idea of the implementation, but many
details (e.g. streaming) will change. I do not know whether I will migrate our
companies project to R13.
You should be familiar with the concept of cgis and ACGIs on the Macintosh in general
and with AppleEvent handling in MacApp. If not, you can still use my code, but will
have trouble using / modifying some parts of it.
As an example I will show how to build a simple Form where you have three fields of a
formula a x b = c. The x can be chosen with a popup out of +, -, * and /.
Building the HTML-Form
Forms can be used with two Methods: Post and Get. The obvious difference is that the
parameters are invisible.
Using Get you get the familiar url ".../myacgi.acgi
?operand1=17&operand2=28&operation=+&result=". Using Post the user can not
see any arguments, but your ACGI gets them nonetheless. The post method allows larger
argument sizes. Also, the arguments are contained in the keyPostArgs otherwise in the
keyPathArgs.
My approach allows you to use both ways. Before you start a larger project you should
decide which of both to use.
Using PathArgs your ACGI can be used by an url from everywhere, but the visible
arguments may confuse the user and tend to become large. An other bad habit is to use
passwords in pathArgs. The password is useless (imho) if the user can create a
Bookmark containing it.
Using PostArgs your ACGI can only be used by forms. The user sometimes becomes
confused because the url stays the same all the time, but the contents changes. The
history also may look strange. Anyway, my approach does support both methods. Lets