When a Format 6 DISPLAY statement is specified, environment-value receives the value stored in envlog-value. The environment variable or logical is the one named by a Format 5 DISPLAY statement. See ENVIRONMENT-VALUE in the SPECIAL-NAMES paragraph. Format 6 - DISPLAY envlog-value UPON environment-value [ ON EXCEPTION stment ] [ NOT ON EXCEPTION stment2 ] [ END-DISPLAY ]
1 – envlog-value
references an alphanumeric data item, or is a nonnumeric literal.
2 – environment-value
is a mnemonic name associated with ENVIRONMENT-VALUE in the SPECIAL-NAMES paragraph in the Environment Division, representing the contents of the variable associated with the ENVIRONMENT-NAME.
3 – Example
Example of Formats 5 and 6. IDENTIFICATION DIVISION. PROGRAM-ID. SAMPLE. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. ENVIRONMENT-NAME IS NAME-OF-EVAR ENVIRONMENT-VALUE IS VALUE-OF-EVAR. DATA DIVISION. WORKING-STORAGE SECTION. 01 NAME-1 PIC X(20). 01 VALUE-ACCEPTED PIC X(20). PROCEDURE DIVISION. P1. * The name of the environment variable MOVE "TESTPATH1" TO NAME-1. * Create an environment with the name "TESTPATH1" DISPLAY NAME-1 UPON NAME-OF-EVAR. * Set the value of "TESTPATH1" DISPLAY "/USER/MYNAME" UPON VALUE-OF-EVAR. * Read the value of TESTPATH1 into a variable ACCEPT VALUE-ACCEPTED FROM VALUE-OF-EVAR. * Display the value of TESTPATH1" DISPLAY VALUE-ACCEPTED. STOP RUN.