Compaq AAQ2G1FTK Marine Radio User Manual


 
Developing Compaq COBOL Programs
1.2 Developing Programs on Tru64 UNIX
Example 1–1 (Cont.) Accessing Environment Variables and Command-Line
Arguments
DISPLAY "COBOLPATH" UPON NAME-OF-ENVIRONMENT-VARIABLE.
ACCEPT env-dir FROM ENVIRONMENT-VARIABLE
ON EXCEPTION
DISPLAY "Environment variable COBOLPATH is not set"
UPON STANDARD-ERROR
END-DISPLAY
NOT ON EXCEPTION
ACCEPT file-name FROM COMMAND-LINE-ARGUMENT
ON EXCEPTION
DISPLAY
"Attempt to read beyond end of command line"
UPON STANDARD-ERROR
END-DISPLAY
NOT ON EXCEPTION
STRING env-dir "/" file-name delimited by " " into file-spec
DISPLAY "Would have read " howmany-records " records from " file-spec
END-ACCEPT
END-ACCEPT.
This example requires that the following command has been executed to set an
environment variable:
% setenv COBOLPATH /usr/files
When you execute the following command lines:
% cobol -o myprog myprog.cob
% myprog 1028 powers.dat
The following will result:
howmany-records will contain ‘‘1028’’
env-dir will contain ‘‘/usr/files’’
file-name will contain ‘‘powers.dat’’
file-spec will contain ‘‘/usr/files/powers.dat’’
For additional information, see the ACCEPT and DISPLAY statements in the
Compaq COBOL Reference Manual.
1.2.4.3 Errors and Switches
See Section 1.4 for a discussion of errors that can cause incorrect or undesirable
results when you run a program.
See Section 1.5 for a discussion of controlling program execution with switches.
1.2.5 Program Development Stages and Tools
This manual primarily addresses the program development activities associated
with development and testing phases. For information about topics usually
considered during application design, specification, and maintenance, see your
operating system documentation, appropriate reference pages, or appropriate
commercially published documentation.
Developing Compaq COBOL Programs 1–25