accept

Command:

ACCEPT

Syntax:

Variant 1:

ACCEPT <accept-variable> FROM DATE.

ACCEPT <accept-variable> FROM DAY.

ACCEPT <accept-variable> FROM DAY-OF-WEEK.

ACCEPT <accept-variable> FROM TIME.

Variant 2:

ACCEPT <accept-variable> FROM KEYBOARD [PROMPT <prompt-string>].

Variant 3:

ACCEPT DATA FROM WEBPAGE.

Description:

The ACCEPT command has three variants:

Variant 1:

The basic variant of ACCEPT can be used to populate a numeric accept-variable with one of a number of variations of the current system date/time. The formats of the data returned to accept-variable by each of the date/time keywords are as follows:

Keyword Format Mask

DATE DDMMYYYY, where DD is the day of the month, ranging from 01

to 31, MM is the month of the year, ranging from 01 to 12, and YYYY

is the four-digit year.

DAY YYDDD, where YY is a two-digit year code, and DDD is a day of the

year ranging from 001 to 366.

DAY-OF-WEEK d, where d = 0 means Sunday, d = 1 means Monday, etc.

TIME hhmmss, where hh corresponds to hour of the day and ranges from

00 to 23, mm corresponds to minutes past the hour and ranges from

00 to 59, and ss corresponds to seconds past the minute and ranges

from 00 to 59.

Variant 2:

ACCEPT <accept-variable> FROM KEYBOARD can be used to read a line from the standard input stream (normally the KEYBOARD) and store it in an alphanumeric accept-variable.

When an ACCEPT FROM KEYBOARD command is processed, program flow is suspended until a line of keyboard input has been received. If the PROMPT clause is specified, prompt-string will display to standard output prior to the cursor prompt. Program execution is resumed when a line of standard input is terminated with a linefeed character; however, the linefeed character is not included in accept-variable. If the standard input stream is greater than the length of accept-variable, the data will be right-truncated.

This variation of the ACCEPT command is also useful for getting raw, unparsed CGI (Common Gateway Interface) data from web pages. This is necessary for retrieving data from GET-method CGI form submissions, or for examining the raw input stream from POST-method submissions. Normally, however, ACCEPT DATA FROM WEBPAGE should be used for POST-method data retrieval - see below for more information.

Variant 3:

The ACCEPT DATA FROM WEBPAGE statement will accept CGI data from an HTML form that was submitted using the POST method, parse it, and place the contents in corresponding CobolScript variables. For this statement to work successfully, use the same field names in the receiving CobolScript program as are in the submitting POST-method CGI form. The ACCEPT DATA FROM WEBPAGE statement will then populate these CobolScript variables with the values that are in the incoming, like-named CGI variables; no additional parsing logic is required.

Refer to Chapters 6 and 8 for a more in-depth discussion of ACCEPT DATA FROM WEBPAGE.

Example Usage:

Variant 1:

ACCEPT date FROM DATE.

ACCEPT day FROM DAY.

ACCEPT day_of_week FROM DAY-OF-WEEK.

ACCEPT time FROM TIME.

Variant 2:

ACCEPT stdin_var FROM KEYBOARD PROMPT `Enter input: `.

ACCEPT raw_buffer FROM KEYBOARD.

Variant 3 (assumes two incoming CGI variables named cust_nm and order_nbr):

1 cust_nm PIC X(50).

1 order_nbr PIC 9(10).

ACCEPT DATA FROM WEBPAGE.

Sample Program:

ACCEPT.CBL