Developing Compaq COBOL Programs
1.3 Developing Programs on OpenVMS Alpha
1.3.4 Running a Compaq COBOL Program
After you compile and link your program, use the RUN command to execute it.
In its simplest form the RUN command has the following format:
$ RUN myprog
In the preceding example MYPROG.EXE is the file specification of the image
you want to run. If you omit the file type from the file specification, the system
automatically provides a default value. The default file type is .EXE. If you omit
a path specification, the system will expect MYPROG.EXE to be in the current
directory.
When you run your application it makes calls to the Compaq COBOL Run-
Time Library (RTL) installed on your system. If your application is run on a
system other than the one where the application was compiled, there are two
requirements that must be met:
•
The Compaq COBOL Run-Time Library must be installed.
•
The RTL version must match (or be higher than) the version of the RTL
on the system where the application was compiled. Otherwise, the system
displays a diagnostic message each time you run the application.
1.3.4.1 Accessing Command-Line Arguments at Run Time
Your Compaq COBOL programs can read command-line arguments and access
(read and write) system logicals. Command-line arguments enable you to provide
information to a program at run time. Your program provides the logic to parse
the command line, identify command-line options, and act upon them. For
example, you might develop a program named MYPROG that will extract a
given amount of data from a specified file, where both the number of records to
read and the file name are highly dynamic, changing for each activation of your
program. In this case your program would contain code that reads a command-
line argument for the number of records to read and a second argument for the
file specification.
To run the program with command-line arguments, you must define it as a foreign
command, as follows:
$ MYPROG :== "$device:[dir]MYPROG.EXE"
When you use this command, you will replace device and dir with the valid
device:[dir] names where MYPROG.EXE is located. Your program execution
command could then look like the following:
$ MYPROG 1028 POWERS.DAT
In this hypothetical case, the program MYPROG would read 1,028 records from
the file POWERS.DAT.
Multiple command-line arguments are delimited by spaces, as shown in the
preceding example. If an argument itself contains spaces, enclose that argument
in quotation marks (" ") as follows:
$ myprog2 "all of this is argument 1" argument2
In this example the returned value of argument1 will be the entire string ‘‘all of
this is argument1’’, and argument2 will be simply ‘‘argument2’’.
1–48 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: ......