Developing Compaq COBOL Programs
1.2 Developing Programs on Tru64 UNIX
You provide definitions for the command-line arguments with the SPECIAL-
NAMES paragraph in your program’s Environment Division, and you include
ACCEPT and DISPLAY statements in the Procedure Division to parse the
command line and access the arguments. Detailed information about command-
line argument capability is in the ACCEPT and DISPLAY sections in the Compaq
COBOL Reference Manual.
1.2.4.2 Accessing Environment Variables
You can read and write environment variables at run time through your Compaq
COBOL program.
Example 1–1 allows you to specify a file specification by putting the directory
in the value of the environment variable COBOLPATH, and the file name in a
command-line argument:
Example 1–1 Accessing Environment Variables and Command-Line Arguments
identification division.
PROGRAM-ID. MYPROG.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
SYSERR
IS STANDARD-ERROR
ENVIRONMENT-NAME
IS NAME-OF-ENVIRONMENT-VARIABLE
ENVIRONMENT-VALUE
IS ENVIRONMENT-VARIABLE
ARGUMENT-NUMBER
IS POS-OF-COMMAND-LINE-ARGUMENT
ARGUMENT-VALUE
IS COMMAND-LINE-ARGUMENT.
WORKING-STORAGE SECTION.
01 howmany-records PIC 9(5).
01 env-dir PIC x(50).
01 file-name PIC x(50).
01 file-spec PIC x(100).
PROCEDURE DIVISION.
BEGIN.
ACCEPT howmany-records FROM COMMAND-LINE-ARGUMENT
ON EXCEPTION
DISPLAY "No arguments specified"
UPON STANDARD-ERROR
END-DISPLAY
STOP RUN
END-ACCEPT.
(continued on next page)
1–24 Developing Compaq COBOL Programs
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......