Up: Summer Course 1996: CMWH Schedule

Strategies for Using Scripts

Used creatively, CGI scripts are a powerful tool for presenting interactive scientific material.

A GUI model

One strategy that we have used to good effect at the Center is to use forms and image maps to create a graphical user interface, combined with CGI scripts that typically invoke other software packages to regenerate the form and image maps.


Examples

In the rest of this section, we will consider several demo scripts illustrating the important concepts of designing a CGI application. More sophisticated examples illustrating this strategy can be found in the lab materials from the University of Minnesota Calculus Initiative.


Coordinate Systems

To obtain the coordinates of a user click on an image, one uses the follow form tag:
<INPUT TYPE=image SRC="filename.gif">
A user click submits the form. The form passes "x" and "y" name/value pairs to the CGI script.

The coordinates passed to the CGI script by a click are gif coordinates. That is, they are pixel coordinates. One can determine the pixel coordinates by using a program like xv for example.

Typically, the picture contains a mathematical picture (like a graph) that has its own coordinate system. Call these coordinates the user coordinates.

If the image is being created by software, it is quite possible, there will be yet another coordinate system in which the drawing operations take place. For example, the CGI script may create a PostScript file which is converted into a .gif file. In this case the programmer must also keep track of PostScript Coordinates.

A Perl library for handling coordinate systems contains a number of useful routines.


Returning New Images

There are two reasonable ways of generating a new graphic in response to user input: invoke another program to do it, like Maple or Mathematica, or create it yourself -- typically as a PostScript file which you then convert.

Persistant Properties and Managing Files

Very frequently, an application will require some sort of persistant memory such as remembering the coordinates of the last user click, etc.

A closely related problem is managing temporary files created by CGI scripts.

Other Resources


Up: Summer Course 1996: CMWH Schedule

[HOME] The Geometry Center Home Page

Comments to: webmaster@geom.umn.edu
Created: May 10 1996 --- Last modified: Thu May 30 15:47:05 1996