Compaq AAQ2G1FTK Marine Radio User Manual


 
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