Using the ACCEPT Verb

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

ACCEPT external-form-item

where external-form-item is an input record for an HTML, XML, or WML 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. For "input forms," the association is made using the IDENTIFIED BY clause in the description of the elementary item. The value of external-name is the name of the CGI variable. If the IDENTIFIED BY phrase is omitted, the data item's own name (data-name) is used as the name of the CGI variable.

External-form-item may also be an output record for an HTML, XML, or WML 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 a 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 the external form, 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.

Please note that when some browsers encounter multiple-line entry fields (also known as HTML TEXTAREAs, they send a carriage return line feed sequence to the CGI program. If carriage returns are not desired, as in operating systems that automatically terminate text lines with line feed characters, you can have them removed by using the CGI_STRIP_CR runtime configuration variable.

Also 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.