• Aucun résultat trouvé

COMPILING SOURCE FILES

Dans le document TRAX Support Environment User's (Page 56-60)

CHAPTERS PROGRAM DEVELOPMENT

5.3 COMPILING SOURCE FILES

TRAX can compile source files written in BASIC or COBOL. The specified source fue is compiled or assembled, thus creating an object file. Optional command qualifIers detail the output required.

For example, you may request a listing file to be produced.

The /SWITCH qualifier available with COBOL tailors translation of the source file to your partic-ular requirements. The relevant language user's guide contains full details concerning the use of the switches controlled by this qualifier.

5.3.1 Using COBOL

Before running a COBOL program you must create a source file, submit it to the compiler and link the object file. This section details how to compile COBOL programs. Linking and execution is described later in this chapter. For futher details concerning programming in COBOL on TRAX systems consult:

TRAX COBOL Language Reference Manual TRAX COBOL User's Guide

5.3.1.1 Compiling Source Files - After creating the source file (using either the EDIT command or other suitable facility as described in Section 5.2) issue the COBOL command to compile the specified COBOL source file. More than one source file can be compiled in one execution of the COBOL command.

Command qualifIers detail the output you require. For example, /OBJECT [:object-file-spec]

produces an object fue named according to object-file-spec. Conversely, jNOOBJECT specifIes that an object fue will not be produced. jOBJECT is the default.

jLIST [:list-fue-spec] produces a listing fue named according to list-fIle-spec. jNOLIST specifies that a listing file is not to be produced. This is the listing facility default qualifier.

· Program Development

The COBOL compiler provides switches that enable you to tailor compilation to your particular requirements. The command qualifier /SWITCHES in conjunction with a particular keyword specify the required switch. The compiler operates according to defaults if you do not specify /SWITCHES. For detailed information on these switches see the TRAX COBOL User's Guide.

For example:

>COBOL/OBJECTtPROG1.0BJ PROG2.CBL

compiles file PROG2.CBL to create the object fIle PROG 1.0Bl. No listing fde is generated.

S.3.1.2 Linking COBOL Object Files - After you have compiled or assembled the source program and obtained an object fde, you must perform one additional step to form the object program into an executable task. This step is called linking.

TRAX is designed to allow routines to access library routines and other user-written routines. All object modules must be processed by the TRAX linker; thus, object fdes, whether or not they access library or other routines, are not in executable condition as produced by the compiler or assembler.

In the TRAX Support Environment, the task is the fundamental executable unit. A task consists of one or more routines, each routine having been derived from an object fde.

As a simple example, assume that you have just compiled a COBOL source program stored in the fde COBPROG.CBL. Thus your directory contains an object fde with the fIle specification

COBPROG.OBJ. This object fue consists of relocatable code; in this conditon, it is called unlinked object module.

The Linker is a system program that takes object modules and system library modules as input, and merges this information to forma task image fue. All object modules require references to a system library to determine fmal storage locations of instructions and data and to establish the required interfaces with the system hardware and software facilities. The Linker resolves these references.

To link the object module COBPROG.OBJ, you could enter the following command:

>LINK COBPROG.OBJ,[l,lJCOBLIB/LIBRARY,Cl,lJRMSLIB/LIBRARY

This is the simplest instance of the LINK command for a COBOL program using RMS I/O. The name of the task image ftle defaults to COBPROG.TSK, taking the fue name and adding the type .TSK that is standard for task image fues.

In this example, the COBOL source program is assumed to contain no CALL statements. In COBOL, the CALL statement is used to reference other user-written routines. If the program did contain a reference to a routine stored in the fue EXTMOD.OBJ, that fue would also have to be included in the input file sequence:

>LINK COBPROG.OBJ,EXTMOD.OBJ,[l,l]COBLIB/LIBRARY,[l,lJRMSLIBILIBRARY The files COB LIB and RMSLIB are required input ftle speciftcations when linking a COBOL pro-gram. These are library modules needed to support the COBOL linking. Notice the file qualifier appended to each file specification, indicating to the Linker that they are library modules.

The LINK command has many more optional features to meet various processing demands. In general, command qualifiers further define the action of the Linker and the conditions of the link operation.

Input flie qualifters tell the Linker that some kind of specialized processing is required on the associated input ftle. For example, /LIBRARY (abbreviated to /LIB in the example above) indicated that the input file contains library modules to be searched before the system library.

The Linker provides an overlay capability as a means of reducing the memory and virtual address space requirements of a task. A task can be divided into overlay segments that reside on disk until they are needed.

The Linker has many optional features and techniques, of which detailed description is beyond the scope of this manual. Part II of this manual describes the LINK command in some detail, defining all the qualifters. However, you should consult the TRAX Linker Reference Manual for an in-depth description of the Linker.

5.3.2 Using BASIC-PLUS-2

This section provides a general overview of BASIC-PLUS-2 usage; for detailed information regard-ing the BASIC-PLUS-2 language see the TRAX BASIC-PLUS-2 Language Reference Manual.

The technique of creating executable task images from BASIC source programs is substantially different from that used for COBOL. Before running a BASIC-PLUS-2 program, you must create a ftle that contains a source program in BASIC-PLUS-2Ianguage. Then you must invoke the BASIC facility to compile the program and prepare it for linking. The BASIC command does not itself compile the program and create the necessary input for the Linker (as COBOL and MACRO does). Rather, it places your terminal under control of the BASIC-PLUS-2 compiler and allows you to direct the compilation. using the command language of BASIC-PLUS-2.

5.3.2.1 Creating BASIC-PLUS-2 Source Files - As mentioned previously, you need not be under BASIC-PLUS-2 control to prepare BASIC source code. However, you may feel it advantageous to have the use of the BASIC-PLUS-2 control language and error detection facilities while prepar-ing BASIC-PLUS-2 source code.

5.3.2.2 Invoking BASIC-PLUS-2 - The following command invokes the BASIC-PLUS-2 compiler:

>BASIC

Program Development

The system then responds with an identification line followed by the prompt:

Bssic2

This prompt appears whenever the terminal is under BASIC-PLUS-2 control. It follows the invocation of BASIC, and also follows the completion of every BASIC-PLUS-2 control language command. Wherever this prompt occurs, the terminal is expecting BASIC-PLUS-2 input - either BASIC source code or a BASIC control command. It will not accept DCL commands.

5.3.2.3 Compiling and Linking a BASIC-PLUS-2 Source Program - Assume that you have a BASIC source program fue MYPROG.B2S in your directory. Before running this program, you must do the following:

I. Issue a BASIC command. After an identification line, the BASIC2 prompt appears, indicating that BASIC-PLUS-2 input is expected.

2. Identify and compile the fue you intend to process. For example:

OLD MYPROG

Ba!::.:i.c2

COMPIL.E Basic2

The COMPILE command translates the source ftIe MYPROG into an object module with default file type .OBJ.

3. Issue a BUILD command. This creates an indirect command fue (default filetype .CMD) and an overlay description file (default filetype .ODL). The program is now ready for linking.

4. Issue an EXIT command. The DCL command prompt now appears on the terminal.

S. Issue a LINK command to complete the building of the task. The LINK command

(described in more detail in the next section) must include the /BASIC qualifier, and must specify the name of the program specified in the BUILD.

>LINK/BASIC MYPROG

When the

>

prompt appears the TRAX linking process is completed. LINK generates an executable task with default filetype .TSK.

The entire display appears as follows:

>BASIC

V01-·53

Basic2

OLD MYPI~OG

Hasic2

COMPILE

Bas:i.c2

BUILD

B(~sic2

EXIT

>LINK/BASIC MYPROG

When this prompt appears, the linked task file MYPROG.TSK is in your directory and available for use as the parameter of a RUN command.

Dans le document TRAX Support Environment User's (Page 56-60)