contents.gifindex.gifprev1.gifnext1.gif

Using the ACCEPT Verb

To read CGI variables from the client machine, you can use the ACCEPT verb in your CGI program. Version 4.0 and later of ACUCOBOL-GT includes special syntax for accepting HTML form records. The syntax is:

ACCEPT external-form-item

where external-form-item is an input record for an HTML form. It is a group data item (declared with the IS EXTERNAL-FORM clause) that has one or more elementary items associated with CGI variables. The association is made using the IS IDENTIFIED BY clause in the description of the elementary item.

external-form-item may also be an output record for an HTML form. In this case, the group item is declared with both the IS EXTERNAL-FORM and IDENTIFIED BY clauses.

The "external form" is called an "output form" if the IDENTIFIED BY clause is used in the description of the group item to associate it with an HTML template file.

For example, the following is an input form:

01  CGI-FORM IS EXTERNAL-FORM.

03 CGI-VAR1 PIC X(10).

03 CGI-VAR2 PIC X(10).

and here is an output form:

01  HTML-FORM IS EXTERNAL-FORM IDENTIFIED BY "tmplate1".

03 HTML-VAR1 PIC X(10).

03 HTML-VAR2 PIC X(10).

The ACCEPT verb treats input and output forms the same. ACCEPT sets the value of each elementary item, in order, to the value of its associated CGI variable, padding with trailing spaces. ACCEPT automatically decodes and translates the CGI input data before moving it to the elementary items of external-form-item. The value of each CGI variable is converted to the appropriate COBOL data type when it is moved to the external form.

Note that CGI variable names are case-sensitive. However, for convenience, if ACCEPT cannot identify a CGI variable, it will repeat the search for the variable ignoring the case.

If the CGI variable is empty or does not exist, ACCEPT sets the value of numeric data items to zero and nonnumeric data items to spaces.

If the CGI variable is repeated in the CGI input data, as in the case where multiple items have been selected from a "choose-many" list, the external form item that is identified with the CGI variable must be in a table using the OCCURS clause. Otherwise, only the first CGI value is moved to the external form item.

For example:

01  CGI-FORM IS EXTERNAL-FORM.

03 CGI-TABLE OCCURS 10 TIMES.

05 CGI-VAR1 PIC X(10).

05 CGI-VAR2 PIC X(10).

or

01  CGI-FORM IS EXTERNAL-FORM.

03 CGI-VAR1 PIC X(10) OCCURS 10 TIMES.

03 CGI-VAR2 PIC X(10) OCCURS 10 TIMES.

ACCEPT moves the values of the CGI variable to the items in the table. After all of the CGI values have been moved to items in the COBOL table, the remaining items in the table are set to 0 if they are numeric items and spaces otherwise.