[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
User Manual


Previous Contents Index

Conventions Used in This Document

The following product names may appear in this manual:

  • HP OpenVMS Industry Standard 64 for Integrity servers
  • OpenVMS I64
  • I64

All three names---the longer form and the two abbreviated forms---refer to the version of the OpenVMS operating system that runs on the Intel® Itanium® architecture.

The following table lists the conventions used in this manual:


References

The following table shows certain references and their respective meanings in this manual:

Reference Meaning
Alpha OpenVMS Alpha or Tru64 UNIX operating system
OpenVMS OpenVMS Alpha or OpenVMS I64 or OpenVMS VAX operating system
Tru64 UNIX Tru64 UNIX operating system
DECset DECset for OpenVMS

Tru64 UNIX was formerly known as Compaq Tru64 Unix, DEC OSF/1, or as DIGITAL UNIX. HP COBOL was formerly known as Compaq COBOL, DIGITAL COBOL, or DEC COBOL. HP COBOL for OpenVMS VAX was formerly known as Compaq COBOL for OpenVMS VAX, VAX COBOL, or as DIGITAL VAX COBOL.

Acknowledgment

COBOL is an industry language and is not the property of any company or group of companies, or of any organization or group of organizations.

No warranty, expressed or implied, is made by any contributor or by the CODASYL COBOL Committee as to the accuracy and functioning of the programming system and language. Moreover, no responsibility is assumed by any contributor, or by the committee, in connection therewith.

The authors and copyright holders of the copyrighted material used herein are as follows: FLOW-MATIC (trademark of Unisys Corporation), Programming for the UNIVAC (R) I and II, Data Automation Systems, copyrighted 1958, 1959, by Unisys Corporation; IBM Commercial Translator Form No. F28-8013, copyrighted 1959 by IBM; FACT, DSI 27A5260-2760, copyrighted 1960 by Minneapolis-Honeywell.

They have specifically authorized the use of this material, in whole or in part, in the COBOL specifications. Such authorization extends to the reproduction and use of COBOL specifications in programming manuals or similar publications.

How to Order Additional Documentation

For information about how to order additional documentation, visit the following World Wide Web address:


http://www.hp.com/go/openvms/doc/order

Reader's Comments

HP welcomes your comments on this manual. Please send comments to either of the following addresses:

Internet openvmsdoc@hp.com
Postal Mail Hewlett-Packard Company
OSSG Documentation Group, ZKO3-4/U08
110 Spit Brook Rd.
Nashua, NH 03062-2698


Chapter 1
Developing HP COBOL Programs

HP COBOL is a family of powerful COBOL compilers produced by Hewlett-Packard Company. HP COBOL operates comfortably in the HP common language environment; on Alpha, it is based on GEM, which is the highly advanced code generator and optimizer that Hewlett-Packard uses in its Alpha family of languages, which includes COBOL, C, C++, FORTRAN, BASIC, Ada, and PASCAL. In addition to standard COBOL features, HP COBOL includes extensions that make new application development efficient and effective, with features helpful in porting legacy COBOL programs to OpenVMS Alpha, OpenVMS I64, and Tru64 UNIX systems.

Developing software applications with HP COBOL will be a familiar process. You set up your development environment, create your source, compile, link, and run. A few of the specific tasks are:

  • Choosing a reference format: terminal or ANSI
  • Carefully considering Alpha and Itanium® architecture system resources; for example, you might invest more system resources at compile time to get faster execution at run time
  • Using various system-independent features for program development

1.1 Developing Programs on Tru64 UNIX

This section briefly describes the Tru64 UNIX commands (commands used at the operating system prompt) that you use to create, compile, link, and run HP COBOL programs on Tru64 UNIX systems.

1.1.1 Creating an HP COBOL Program on Tru64 UNIX

Use a text editor, such as vi or emacs , to create and revise your source files. For instance, to edit the file prog1.cob using the vi editor, type:


% vi prog1.cob

Figure 1-1 shows the basic steps in HP COBOL program development on Tru64 UNIX systems.

Figure 1-1 Commands for Developing HP COBOL Programs on Tru64 UNIX


When naming a source file, choose one of the four file name extensions that the cobol compiler recognizes as COBOL file suffixes. These suffixes are:

.cob
.COB
.cbl
.CBL

Table 1-1 shows other file name suffixes.

Table 1-1 Other File Name Suffixes
Suffix Description
.c Identifies C language files passed to the C compiler driver cc , which performs additional command line parsing before invoking the C language compiler.
.s Identifies assembler files passed to cc . HP COBOL does not generate .s files.
.o Identifies object files passed to cc , which are in turn passed to ld .
.a Identifies archive object libraries passed to cc , which are in turn passed to ld . All routines in the specified object library will be searched during linking to resolve external references. This is one method of specifying special libraries for which the cobol command does not automatically search.
.so Identifies shared object libraries passed to cc , which are in turn passed to ld . All routines in the specified object library will be searched during linking to resolve external references. This is one method of specifying special libraries for which the cobol command does not automatically search.

The following cobol command compiles the program named prog1.cob and automatically uses the linker ld to link the main program into an executable program file named a.out (the name used if you do not specify a name):


% cobol prog1.cob

The cobol command automatically passes a standard default list of Tru64 UNIX and HP COBOL libraries to the ld linker. If all external routines used by a program reside in these standard libraries, additional libraries or object files are not specified on the cobol command line.

If your path definition includes the directory containing a.out , you can run the program by simply typing its name:


% a.out

If the executable image is not in your current directory path, specify the directory path in addition to the file name.

The COPY Statement and Libraries

As you write a program, you can use the COPY statement in your source program to include text from another file. With the COPY statement, separate programs can share common source text kept in libraries, reducing development and testing time as well as storage. The HP COBOL Reference Manual explains how to use the COPY statement.

Special Considerations for Routines Named "main"

If you have a program or routine named "main," declared either in an HP COBOL or other module, your application may not work correctly. The HP COBOL library contains a routine named "main," which initializes the run-time environment for the CALL by data name statements, extended ACCEPT and DISPLAY statements, and some error handling. When your application also declares a "main," your routine preempts the HP COBOL routine, and the run-time initialization is not performed.


Previous Next Contents Index