Collecting Data through HTML Forms

There is yet another mechanism to write information to a Server data file, besides the use of program cgientry.exe. This technique is described in this section.

It is possible to create two files to present an entry form for data submission to a server computer and to collect the data sent by use of a Submit button found in the form to a companion program file which executes on the server. This server program reformats the received data and writes the data to a file on the server computer.

The first of these files is written in the HyperText Markup Language (HTML) and is given the filename extension of .htm. The second of these files as written as an Active Server Page (ASP). This file is given a filename extension of .asp. Both of these files are installed on the server computer in a place that can be found and used by a Web browser.

Using customary techniques, programming these two files can be a tedious process, because it requires the detailed knowledge of both HTML and ASP. Writing programs directly in HTML and ASP is normally a rather formidable undertaking, but there is a direct way to get help doing these programming tasks through the use of three SCIOS utility programs.

A pair of files can be created through the use of two SCI programs, sciosHTM.exe and sciosASP.exe. These may be used to create a 'form' (named this because of the use of the html command "form" in the .htm file) The .asp file is called into action by this command, by a statement which may look like:

    form method="POST" action=""

which is enclosed by the normal < and > characters.

Many of the lines in the .htm and .asp files are 'boilerplate'; that is, this text is invariant from one project to another, except that certain specific items may be changed for the convenience of the programmer.

Let us break the HTML and ASP files into three parts. The first section, called the 'prefix' is comprised of perhaps of a hundred or so lines of text that is normally required by the programmer in every file which he creates. Similarly, after the second section (the part that actually 'does the work', there is a section, called the 'suffix' or 'postfix', that also is comprised of lines of code that do not change from one form to another.

Let us say that the boilerplate that precedes the lines that actually refer to the data items of the forms, the prefix code, is placed a file called HTML1. Similarly, let the boilerplate that follows the data items be placed in a file, the suffix code, called HTML2. Also, let this process be done for the .asp file. The prefix and suffix text is placed in files called ASP1 and ASP2, respectively.

The text that is to be placed between the prefix and suffix text is generated by the program sciosHTM.exe for the .htm file and sciosASP.exe for the .asp file. These programs also read the prefix and suffix text and writes all of the proper information to the .htm and .asp files.

The two SCIOS programs know what program file text to produce by reading an SCIOS format file (.f). Additional capabilities may be given to these programs by people knowledgeable in textareas and drop-down-lists of HTML. This additional information is placed in a file, called the Select file, that shall be named HTML3.

To prepare for the creation of the .htm and .asp files, the following process is followed:

The SCIOS format file (.f) is copied into a new file with the same name but with the file extension .fx. Then, the new format file is edited, if desired, with additional (or modified) information that 'custom tailor' the form to suit the programmers purposes.

Left to its own devices, the translation programs would create a form that is a sequence of lines, one for each attribute in the format file, with the attribute name followed by a textbox to hold the attribute value to be entered and/or displayed in the form. If this is what is wanted, nothing more need be done to supply information to the translation programs.

However, the programmer may only want a subset of all of the attributes in a data record to be displayed. So, the programmer may prevent showing an attribute by replacing the attribute name in the new format file with blanks. Similarly, if it is desired to show two (or more) attribute values side by side without descriptive text, this is accomplished by replacing the attribute name with the characters "XX" in columns 11 and 12 of the new format file.

Unlike elsewhere in all of SCIOS, the new format file may be sorted to place fields in an order on the screen which is different from the ordering specified by the (.f) format file. However, please note that the actual ordering of the attributes in the data record is not changed. The only thing that is changed is the order in which the visible attributes are displayed in the form.

There are times when it is desired that, instead of using a single textbox for an attribute, either a textarea or a drop-down-menu is used. These options are readily specified by the programmer writing a file, called the Select file. This file is given the name HTML3.

Fields in the Select file must be in the same order as is found in the .fx format file, but necessarily in the same order as the original format file.

For each attribute requiring 'special treatment' by using textareas and drop-down-menus, a line will be written to file HECR3 which is comprised of either a line starting with "SELECT" or "TEXTAREA". Following these are lines that describe what is to be done in programming these items in the form.

The drop-down-menu specifier line has the form:

          SELECT xxx

where xxx is the attribute number. This line is followed by a sequence of lines that will show on the screen for that field in the menu. Each of these lines will contain either a single word (or " ", if nothing is to be displayed) or a sequence of words. The first word of each line is the code that is sent to the Server if this item is selected by the client entering information into the form using a client computer.

If only one word is specified here, the value shown in the drop-down-menu will be the same as the code sent to the Server computer when the form is submitted. If there are multiple words, the first word is the code sent to the computer and all of the remaining text is shown in the menu.

The textarea specifier line has the form

          TEXTAREA xxx [width of textarea] [height of textarea]

Creation of the Form

To create the .htm file for the form, the program sciosHTM.exe is executed by typing its name at a command prompt. The program asks for the following to be supplied:

1. the FORMAT file name -- the file with the .fx extension
2. the PREFIX html file name -- e.g., HTML1
3. the POSTFIX html file name  -- e.g., HTML2
4. the SELECT html file name   --  e.g., HTML3
5. the OUTPUT  html file name  --  the resulting file with the .htm extension

The program may be supplied these data by typing the information on the command line, for example:

        scioshtm  calweb.fx hecr1  hecr2 hecr3 +hecrform.htm

The plus sign in front of the .htm file defines the file, if it is not done already.

To create the .asp file for the form, the program sciosASP.exe is executed by typing its name at a command prompt. The program asks for the following to be supplied:

1. the FORMAT file name -- the file with the .fx extension
2. the PREFIX ASP file name -- e.g., ASP1
3. the POSTFIX ASP file name  -- e.g., ASP2
5. the OUTPUT ASP file name  --  the resulting file with the .asp extension

The program may be supplied these data by typing the information on the command line, for example:

        sciosasp  calweb.fx asp1 asp2 +hecrform.asp

The two files must then be uploaded to the server computer. This must be accomplished by people with special security privileges on the server computer.

Also carried out by a systems programmer with high privilege levels is the task of retrieving the data file on the Server which has been created and written by the form described above, the third SCIOS supplied program, ASPform.exe, is used. This program fetches the data file created by the .asp file from the server and converts the file into a normal SCIOS data file on a local computer. The task of 'retrieving the data file from the Server is accomplished through the use of specialized software, described elsewhere. For the purposes of this document, let the Server data file be called hecrform.dat.

By typing the following lines, the local data file, newweb.da is created:

       rem  copy \hecr\webtek\hecrform.dat .
       shorten hecrform.dat 70
       aspform hecrform.dat +newweb.da newweb.f hecr

the 'hecr' in the previous line is also specified in the .asp file. This makes it possible to having a plurality of forms all accessing the Server, but with the ability to segregate out the information provided by only one form. It is possible to name any number of different character strings as identifiers.