TOPS-20 User's Guide

Chapter 9 Producing and running your own programs

This chapter describes:

  1. Producing a simple program
  2. Preparing a multi-module program
  3. Using the LOAD-class commands

top

9.1 Producing a simple program

To produce a simple program:

If you find errors after executing the program, change the source program to eliminate the errors, and re-execute the program.

top

9.1.1 The Source Program

A source program is the program you input, in a programming language, to the system. The file containing your program has a file type indicating the language in which the program is written. After the system translates your program, it creates a new file containing the translation. The new file has the same file name as the source file, but it has a file type of .REL (which stands for relocatable binary). This translated program is called an object program.

To write the source program, choose one of the programming languages: ALGOL, BLISS, COBOL, FORTRAN, MACRO, or PASCAL. The languages BASIC, APL and CPL do not produce object programs (.REL files). To write a program in one of these languages, follow the procedures described in the appropriate language manual. (Refer to Appendix D, USING BASIC for an explanation of how to enter and run a BASIC program.)

The following example shows a FORTRAN program that requires you to type a number; the program then prints two times that number. Enter this program into a file.

        C      THIS IS A SMALL FORTRAN PROGRAM
               TYPE 101
        101    FORMAT (' TYPE A NUMBER:  '$)
               ACCEPT 102,X
        102    FORMAT (F)
               Y=2*X
               TYPE 103,X,Y
        103    FORMAT (' TWO TIMES ',F,' IS ',F)
               STOP
               END

top

9.1.2 Executing the Program

Once you enter the source program into a file, do the following:

The language compiler or assembler translates the source program, producing an object program. The LINK program places the object program in memory, and the START command starts the program. You do not have to give all these commands to perform the individual functions. Instead, you can give the EXECUTE command, which performs the functions collectively. The COMPILE, LOAD, DEBUG, and EXECUTE commands are referred to as LOAD-class commands.

        @EXECUTE (FROM) SMALL.FOR
        FORTRAN: SMALL
        MAIN.
        LINK:   Loading
        [LNKXCT SMALL Execution]

        TYPE A NUMBER: 5
        TWO TIMES      5.0000000  IS      10.0000000
        STOP

        END OF EXECUTION
        CPU TIME: 0.07  ELAPSED TIME: 3.00
        EXIT

top

9.1.3 Debugging the Program

If your program does not run correctly the first time, check for:

To eliminate syntax errors, examine the line or lines for which the compiler or assembler prints errors. Edit the source program to correct the errors and re-execute it. Continue until your program is successfully translated.

If your program does not give the correct answer after it executes, check for a logic error in the program. To do this, you can carefully review the source program for any errors or you can use one of the system debugging programs: COBDDT for COBOL programs; FORDDT for FORTRAN programs and DDT for most other programs. These debugging programs allow you to stop at certain points in your program, examine the contents of the program, make changes, and then continue the program. (For more information refer to the appropriate TOPS-20 language manual.)

To get a listing of your compiled program, give the COMPILE command with the /LIST switch; the listing file has the same name as your last source file and is output directly to the line printer. When you give the COMPILE command, the system scans the list of files to be compiled. Only those files that are current (a source program not changed since the last compilation) are not recompiled. If you have a current object program, you must include the /COMPILE switch to force the compiler to recompile your source file. The following example shows how to recompile the program SMALL and get a listing:

        @COMPILE (FROM) SMALL/LIST/COMPILE
        FORTRAN: SMALL
        MAIN.
        @

To see the location of your program in the line printer output queue, give the INFORMATION OUTPUT-REQUESTS command.

        @INFORMATION (ABOUT) OUTPUT-REQUESTS

        Printer Queue:
        Job Name  Req#   Limit              User
        --------  ----   -----    --------------------------
        * SMALL   3891      52    SARTINI                     /Unit:1
           Started at 11:02:34, Printed 0 of 52 Pages
        There is 1 Job in the Queue (1 in Progress)

The SMALL program is the only job listed and the only job being printed.

top

9.1.4 Saving the Program for Future Use

Once you debug the program, load it into memory (using the LOAD command) and save the loaded program in an .EXE file (using the SAVE command). Refer to the following example. The .EXE file is an executable memory image file.

        @LOAD (FROM) SMALL
        LINK:   Loading
        @SAVE (ON FILE)
         SMALL.EXE.1 Saved

To run the program, give a RUN command.

        @RUN SMALL

        TYPE A NUMBER: 25

        TWO TIMES       25.0000000 IS    50.0000000
        THREE TIMES       25.0000000 IS    75.0000000
        STOP

        END OF EXECUTION
        CPU TIME: 0.08 ELAPSED TIME: 6.42
        EXIT

Using the .EXE file and a RUN command saves the system from checking to see that the object file is current and loading it into memory. Make an .EXE file only when your program is running correctly. RUN is not a LOAD-class command. Therefore, if the source program for SMALL changes, giving the command RUN SMALL will not compile the program SMALL.

top

9.2 Preparing a multi-module program

To produce a program consisting of a number of modules, do the following:

Sections 9.2.1 through 9.2.7 describe some helpful functions:

top

9.2.1 Writing and Entering Modules into Files

Design the program and write the modules in a programming language. Using separate files for the modules gives you flexibility in debugging the program. If there is an error in one module, you do not have to recompile the other modules. If you do not enter each module into a separate file and an error occurs in one of the modules, you must recompile all modules in that file.

The following example illustrates entering each module into a separate file:

        File COMP.FOR

                      TYPE 101
                101   FORMAT (' TYPE TWO NUMBERS: '$)
                      ACCEPT 102,A,B
                102   FORMAT (2F)
                      CALL ADDEM(A,B)
                      CALL DIFFER(A,B)
                      STOP
                      END

        File ADDEM.FOR

                      SUBROUTINE ADDEM(A,B)
                      C = A + B
                      TYPE 101,C
                101   FORMAT (' THE SUM IS: ',F)
                      RETURN
                      END

        File DIFFER.FOR

                      SUBROUTINE DIFFER(A,B)
                      C = ABS(A - B)
                      TYPE 101,C
                101   FORMAT (' THE DIFFERENCE IS: ',F)
                      RETURN
                      END

top

9.2.2 Executing the Program

You can run the program by giving the EXECUTE command. The FORTRAN compiler processes all three source modules and produces the three object programs; then the LINK program loads them into memory and starts them.

        @EXECUTE (FROM) COMP,ADDEM,DIFFER
        FORTRAN: COMP
        MAIN.
        FORTRAN: ADDEM
             .
             .
             .
        END OF EXECUTION
        CPU TIME: 0.16 ELAPSED TIME: 2.00
        EXIT

top

9.2.3 Producing a Cross-Reference Listing

Many programs contain numerous modules that are significantly larger than those shown in the previous examples. If you want to find the place where a variable is defined or used, you must search each module line by line. However, the system can help you by creating a cross-reference listing that you can print on the line printer. The cross-reference listing shows where each variable is defined and used.

The CREF (for Cross-REFerence) program produces the listing. To use the CREF program, give the /CREF switch, along with a LOAD-class command that compiles your source program. After the program is compiled, your directory will contain a .CRF file in addition to your .REL file. Thus, if you have the file TEST.FOR and give the command:

        @COMPILE (FROM) /CREF TEST
your directory will contain the files TEST.FOR, TEST.REL and TEST.CRF.

The .CRF file contains information for the CREF program. When you are ready to produce the listing, give the CREF command. This command produces listings for all the .CRF files in your connected directory that were created since you logged in. The program sends the listings to the printer. The following example produces a cross reference listing for the COMP, ADDEM, and DIFFER programs.

        @EXECUTE (FROM) /CREF COMP,ADDEM,DIFFER  !Include /CREF
        FORTRAN: COMP
        MAIN.
        FORTRAN: ADDEM
             .
             .
             .
        END OF EXECUTION
        CPU TIME: 0.15 ELAPSED TIME: 1.52
        EXIT
        @CREF                                   !Then run CREF
        CREF:   COMP
        CREF:   ADDEM
        CREF:   DIFFER

If you already have object files for the programs, give the COMPILE command with the /CREF, /NOBINARY, and /COMPILE switches. The system produces just the .CRF file, without producing an object file.

The following example shows how to produce only cross-reference listings:

        @COMPILE (FROM) /CREF /NOBINARY /COMPILE COMP,ADDEM,DIFFER
        FORTRAN: COMP
        MAIN.
        FORTRAN: ADDEM
        ADDEM
        FORTRAN: DIFFER
        DIFFER
        @CREF
        CREF:   COMP
        CREF:   ADDEM
        CREF:   DIFFER

If you have a COBOL program, the /CREF switch puts the cross references in the listing file that it normally produces; you do not need to run the CREF program.

Refer to the TOPS-20 User Utilities Guide for a complete description of CREF.

top

9.2.4 Using Subroutine Libraries

If you have a set of frequently used subroutines, you can group them in a single object file called a library file, rather than keep the object files separate. Then when you give a LOAD-class command, all you need type is the one library file specification instead of a list of subroutine file specifications. In addition, it is easier to keep track of one file, especially if a group of users is sharing the subroutines.

For example, if you have the subroutines OPREAD, OPWRIT, CLREAD, and CLWRIT, which may be called by the main program WRITER, your LOAD-class command is:

        @LOAD (FROM) WRITER,OPREAD,OPWRIT,CLREAD,CLWRIT

If you place the four subroutines in a library, DOFILE, your command is shortened to:

        @LOAD (FROM) WRITER,DOFILE/LIBRARY

The /LIBRARY switch causes the system to load only those subroutines that are actually called. If you use the library file and the /LIBRARY switch, after writing a main program that calls the subroutines, you do not have to remember which subroutines the program calls to include the proper file specifications in the LOAD-class command.

A library file is produced by compiling the subroutines separately and then running the MAKLIB program to construct the library file. MAKLIB is a program that manipulates .REL files. If you need to modify any one of the library files, edit the source file, recompile, and use MAKLIB to replace the subroutine in the library file.

Sections 9.2.4.1 through 9.2.4.5 show how to create a library containing four subroutines, use the library, change a subroutine, then replace the old subroutine in the library with the new one. Four subroutines: OPREAD, OPWRIT, CLREAD, and CLWRIT are entered into files, compiled, then stored in the library, DOFILE.

Refer to the TOPS-20 User Utilities Guide for a complete description of MAKLIB.

9.2.4.1 Entering the Subroutines into Files - Enter the subroutines into separate files.

        File OPREAD.FOR

             SUBROUTINE OPREAD(NAME)
             OPREAD - OPENS A FILE FOR READING
             DOUBLE PRECISION NAME
             OPEN(UNIT=21,ACCESS='SEQIN',FILE=NAME)
             RETURN
             END

        File OPWRIT.FOR

             SUBROUTINE OPWRIT(NAME)
             OPWRIT - OPENS A FILE FOR WRITING
             DOUBLE PRECISION NAME
             OPEN(UNIT=21,ACCESS='SEQOUT',FILE=NAME)
             RETURN
             END

        File CLREAD.FOR

             SUBROUTINE CLREAD(NAME)
             CLREAD - CLOSES A FILE OPENED FOR READING
             DOUBLE PRECISION NAME
             CLOSE(UNIT=21,FILE=NAME)
             RETURN
             END

        File CLWRIT.FOR

             SUBROUTINE CLWRIT(NAME)
             CLWRIT - CLOSES A FILE OPENED FOR WRITING
             DOUBLE PRECISION NAME
             CLOSE(UNIT=21,FILE=NAME)
             RETURN
             END

9.2.4.2 Compiling the Subroutines - After entering the subroutines into files, compile them to produce four separate object files.

        @COMPILE (FROM) OPREAD,OPWRIT,CLREAD,CLWRIT
        FORTRAN: OPREAD
        OPREAD
        FORTRAN: OPWRIT
        OPWRIT
        FORTRAN: CLREAD
        CLREAD
        FORTRAN: CLWRIT
        CLWRIT

9.2.4.3 Creating the Library File - Create the library file by running the MAKLIB program. After starting MAKLIB, type the name of the library file, followed by an equal sign. Then type the name of each object file, followed by the /APPEND switch.

        @MAKLIB
        *DOFILE=OPREAD/APPEND,OPWRIT/APPEND,CLREAD/APPEND,CLWRIT/APPEND

If you want some switches to be in effect every time you run the MAKLIB program, you can create a SWITCH.INI file and include the switches. When you issue a MAKLIB command line, MAKLIB reads the SWITCH.INI file in your connected directory and uses the switches specified in that file. (Note that the EDIT program, on the other hand, reads the SWITCH.INI file in your logged-in directory.)

The format of the line in the SWITCH.INI file is:

        MAKLIB/switch(es)

Thus, if you always want to give the /LIST switch (which lists the names of the modules that are contained in the master library) with MAKLIB, insert in the SWITCH.INI file the line

        MAKLIB/LIST

Now, instead of typing the command

        @MAKLIB
        *MASTER=NEW/LIST
you can type the following command, and the /LIST switch is automatically included in the command:
        @MAKLIB
        *MASTER=NEW

If the switches occupy more than one line, use a hyphen at the end of the first line and continue on the next line.

Once you create the library file, you can list its contents on your terminal by giving a MAKLIB command with the /LIST switch in the command below. The first number following the subroutine name is the highest relocatable address it occupies, and the second number indicates its length; both numbers are octal.

        *TTY:=DOFILE/LIST
                Listing of Modules
        Produced by MAKLIB Version 2.2(104) on 26-Mar-88 at 15:00:48

                **************************
        DSK:DOFILE.REL[4,164] Created on 26-Mar-88 at 15:00:00

        OPREAD  400016  000007
        OPWRIT  400016  000010
        CLREAD  400016  000007
        CLWRIT  400016  000010

To end MAKLIB, type a CTRL/C.

9.2.4.4 Using the Library File - To use the library file, first create a main program that uses the subroutines. LOAD this main program and the library file into memory. Notice that the WRITER program in the example below does not use all the subroutines. When you give the LOAD command with the /LIBRARY switch, the system loads only the subroutines, OPWRIT and CLWRIT.

        File WRITER.FOR

                      DOUBLE PRECISION NAME,DAY
                      CALL DATE(DAY)
                      CALL OPWRIT('DATE.FIL')
                      TYPE 101,DAY
                101   FORMAT (' UPDATING AS OF: ',A10)
                      WRITE (21,102) DAY
                102   FORMAT (' => UPDATED ON: ', A10)
                      CALL CLWRIT('DATE.FIL')
                      STOP
                      END

After entering the main program, load it with the library file and start it. Remember to include the /LIBRARY switch.

        @LOAD (FROM) WRITER,DOFILE/LIBRARY
        FORTRAN: WRITER
        MAIN.
        LINK:   Loading

        EXIT
        @START
        UPDATING AS OF:  26-Mar-88
        STOP

        END OF EXECUTION
        CPU TIME: 0.41 ELAPSED TIME: 1.33
        EXIT

9.2.4.5 Changing a Subroutine in the Library - To change a subroutine in the library, edit the source file, recompile the subroutine and use MAKLIB to update the library file. After editing the file, compile a new object file.

        @COMPILE (FROM) OPWRIT.FOR
        FORTRAN: OPWRIT
        OPWRIT

Now, run the MAKLIB program. First, check the contents of the library file to be sure you are updating the proper file.

        @MAKLIB
        *TTY:=DOFILE/LIST
                Listing of Modules
        Produced by MAKLIB Version 2A(67) on 26-Sep-88 at 15:05:06

                **************************

        DSK:DOFILE.REL[4,164] Created on 26-Sep-88 at 15:00:00

        OPREAD  400016  000007
        OPWRIT  400016  000010
        CLREAD  400016  000007
        CLWRIT  400016  000010

Second, update the library file. Type the name of the new library file followed by an equal sign. Type the name of the library file you want to update and the /MASTER: switch. After /MASTER: type the name of the subroutine you are replacing and a comma. Last, type the name of the file containing the new subroutine followed by the /REPLACE switch. Press RETURN. When the system completes the update, it prints an asterisk.

        *DOFILE=DOFILE/MASTER:OPWRIT,OPWRIT/REPLACE

You can now check the new library to be sure that the new subroutine is included. As you can see, the length of the OPWRIT subroutine has changed to include the additional statements.

        *TTY:=DOFILE/LIST
                Listing of Modules
        Produced by MAKLIB Version 2A(67) on 26-Sep-88 at 15:10:10

                ***************************

        DSK:DOFILE.REL[4,164] Created on 26-sep-88 at 15:09:00

        OPREAD  400020  000007
        OPWRIT  400035  000015
        CLREAD  400020  000007
        CLWRIT  400020  000010
        *^C

Load the main program with the new library. You do not have to recompile the main program or any of the other subroutines to change OPWRIT. After loading the program, save it for future use, then start the program.

        @LOAD (FROM) WRITER,DOFILE/LIBRARY
        LINK:  Loading
        @SAVE
         WRITER.EXE.1 Saved
        @START
        [DATE.FIL    OPENED]
        UPDATING AS OF:   26-Sep-88
        STOP

        END OF EXECUTION
        CPU TIME: 0.18 ELAPSED TIME: 0.86
        EXIT

Refer to the TOPS-20 User Utilities Guide for more information on the MAKLIB program.

top

9.2.5 Loading and Saving the Program for Future Use

The example below shows how to load the main program and the library file. Instead of loading all four subroutines in DOFILE, the system loads only the two that the program actually uses (OPWRIT and CLWRIT).

        @LOAD (FROM) WRITER,DOFILE/LIBRARY
        LINK:   Loading

        EXIT

Give the SAVE command to save the program. To run the program later, give the RUN command. Note that if you specified a name in your program by using the PROGRAM statement, the name of the saved file will reflect that name.

        @RUN (PROGRAM) WRITER

Never save a program after you have started it; some storage areas may not get properly cleared during restarting.

top

9.2.6 Saving Arguments in Indirect Files

If the arguments for a LOAD-class command are complex, you can store them in a file called an indirect file. Later, when you give the LOAD-class command, specify the file where the arguments are stored, rather than typing the entire line. Instead of receiving the arguments directly from your terminal, the system receives them indirectly from the file. In this case precede the indirect filename with an @ sign.

If you give the indirect command file a file type of .CMD, you do not have to include a file type when giving its file specification. This example shows the line in a command file that will compile the four subroutines:

        OPREAD,OPWRIT,CLREAD,CLWRIT

To use the file in a LOAD-class command, precede it with an @. You can use recognition in typing the file specification. If you do not give a file type, the system uses file type .CMD.

        @COMPILE (FROM) @D
        FORTRAN: OPREAD
        OPREAD
        FORTRAN: OPWRIT
        OPWRIT
        FORTRAN: CLREAD
        CLREAD
        FORTRAN: CLWRIT
        CLWRIT

This example shows an indirect file you can use to create the program WRITER and to search the library:

        WRITER.FOR,DOFILE.REL/LIBRARY

top

9.2.7 Comparing Changes in Files

To run the FILCOM program, type FILCOM and press RETURN; the system prints an asterisk. Type a command to FILCOM in the form:

       destination-filespec = source-filespec, source-filespec2,/switches

The destination file is the file that contains the differences. It can be printed in a file or on your terminal (TTY:). The first file is the one that will be listed first in the list of differences, and the second file is the one that will be listed second. The list of switches specifies any special parameters for properly performing the comparison.

First, change one line in the file WRITER.FOR and save the new file in UPDATE.FOR. This example uses the EDIT editor.

        @EDIT (FILE) WRITER.FOR.1 (OUTPUT AS) UPDATE.FOR
        Edit: WRITER.FOR.1
        *F=>$
        00700   102   FORMAT (' => UPDATED ON: ', A10)
        *SUPDATED$ADDED NEW DATA$.
        00700   102   FORMAT (' => ADDED NEW DATA ON: ', A10)
        *E

        [UPDATE.FOR.1]

There are now two files: WRITER.FOR, which contains the original line, and UPDATE.FOR, which contains the modified line. The example below shows how to compare the two files and output the differences to your terminal. Type a CTRL/C to end FILCOM.

        @FILCOM                            !Start FILCOM

        *TTY:=WRITER.FOR,UPDATE.FOR        !Type the command
        FILE 1) DSK:WRITER.FOR  CREATED: 1554 2-MAR-88
        FILE 2) DSK:UPDATE.FOR  CREATED: 1556 24-MAR-88

        1)1     00700   102   FORMAT (' => UPDATED ON: ', A10)
        1)      00800         CALL CLWRIT('DATE.FIL')
        ****
        2)1     00700   102   FORMAT (' => ADDED NEW DATA ON: ', A10)
        2)      00800         CALL CLWRIT('DATE.FIL')
        **************

        %files are different

        *^C                                !Type a CTRL/C to
                                           !end FILCOM

For more information on the FILCOM program, see the TOPS-20 User Utilities Guide.

top

9.3 Using the load-class commands

The LOAD-class (COMPILE, LOAD, EXECUTE, DEBUG) commands help you produce programs easily and correctly. The four commands perform all the functions you need to compile (or assemble) and debug a program:

   COMPILE        The COMPILE command  causes  the  appropriate  language
                  processor   to  produce  object  programs  from  source
                  programs.

   LOAD           The  LOAD  command  causes  the  appropriate   language
                  processor to produce an object program and then load it
                  into memory.

   EXECUTE        The EXECUTE command  causes  the  appropriate  language
                  processor  and  LINK to produce an object program, load
                  it into memory, and then start its execution.
   DEBUG          The  DEBUG  command  causes  the  appropriate  language
                  processor  and  LINK to produce an object program, load
                  it and the appropriate debugging program  into  memory,
                  then start execution of the debugging program.

In addition to the functions listed above, the LOAD-class commands perform some helpful and timesaving functions by:

  1. Recognizing the programming language in which you write your program(s) if you use the standard file types
  2. Recompiling only out-of-date source programs
  3. Remembering arguments of the last LOAD-class command when you omit the arguments to a current command
  4. Taking arguments from an indirect file
  5. Concatenating files to produce one source program
  6. Passing switches to the LINK program
  7. Specifying special actions with switches

Sections 9.3.1 through 9.3.6 describe some useful ways you can use these features.

Section 9.3.1 describes object programs and their uses. You may skip this section, but the information is valuable in understanding the flexibility that relocatable programs provide.

top

9.3.1 Object (Relocatable) and Executable Programs

The main function of any LOAD-class command is to produce an object program. (Refer to Figure 9-1.) The source program is stored in a source file with a file type that indicates the programming language. (Table 9-1 contains a list of the standard file types.) By compiling the source program with a LOAD-class command, you produce the object program stored in a file having a filename the same as the source filename. The object program is relocatable, which means you can load it into memory with subroutines, or as a subroutine, without recompiling. Hence, the object file has a file type of .REL (for relocatable) and is often called a .REL file. To run the program, you must load the object program into memory. At that time, the various subroutines and main programs are linked. The loaded program is now executable; it may be saved in a disk file with the same name as the main source program and the file type .EXE (for executable).

                           Source file= name.typ
                             |----------------|
                             |                |
                             | Source program |
                             |                |
                             |----------------|
                                     |
                                     |
                                     |  Compiling (or assembling)
                                     v
                           Object file= name.REL
                             |----------------|
                             |                |
                             | Object program |
                             |                |
                             |----------------|
                                     |
                                     |
                                     |  Loading
                                     v
                                   Memory
                           |--------------------|
                           |                    |
                           | Executable program |
                           |                    |
                           |--------------------|
                                     |
                                     |
                                     |  Saving
                                     v
                         Executable file= name.EXE
                           |--------------------|
                           |                    |
                           | Executable program |
                           |                    |
                           |--------------------|

   Figure 9-1:  Source, Object, and Executable Programs

Any program you run must be in executable form. To form an executable program, you must compile the source program, then load the object program into memory. After you have the executable program in memory, you can save it for future use or start its execution.

In creating an executable program, you must go through the process of compiling and loading. Should you use the same subroutine in more than one program, you can reuse the object program when loading the modules into memory. By eliminating the needless compilation, you save both time and computer charges.

9.3.1.1 Using Relocatable Object Programs - Once you compile a source program into an object program, you can load that object program into memory with any combination of cooperating programs and produce an executable program. (The word program, as it is used here, refers to both main programs and subroutines.)

The examples below show how to use the FILLER subroutine in three different programs, without having to recompile it each time.

In the first example, FILLER is used with the main program, TESTER. To run TESTER, give the command:

        @EXECUTE (FROM) TESTER,FILLER

The system compiles TESTER and FILLER, loads them into memory, and then starts the execution of TESTER.

The second program, LAYOUT also has another subroutine, TTYOUT, that you must include in the EXECUTE command.

        @EXECUTE (FROM) LAYOUT,FILLER,TTYOUT

The system compiles LAYOUT and TTYOUT, loads them into memory with FILLER and executes LAYOUT.

The third program, GAMMA, has a POLAR subroutine that is included in the EXECUTE command.

        @EXECUTE (FROM) GAMMA,POLAR,FILLER

When typing the file specifications, you do not have to place them in any specific order.

top

9.3.2 Selecting a File and Recognizing the Programming Language

When you give a filename as an argument to a LOAD-class command, you do not have to include the file type. For example, you can give the command:

        @COMPILE (FROM) SMALL
        FORTRAN:  SMALL
        MAIN.

The system found the file SMALL.FOR and compiled it using FORTRAN. The file type .FOR identifies to the system that the file contains FORTRAN source code and should be compiled using FORTRAN.

When you do not include a file type in a LOAD-class command, the system searches for a file name with a file type that matches a file type in Table 9-1. The order in Table 9-1, is the order in which the system searches for a matching file.

Upon finding a matching file, the system (if necessary) compiles it using the language compiler specified by the file type. For example, if the file type is .CBL, the system uses the COBOL compiler. If there is no file type, or if the file type is not one of the file types in Table 9-1, the system defaults to the FORTRAN compiler. Note that your installation may modify this list to include other language processors.

   Table 9-1:  LOAD-Class Command Standard File Types

   __________________________________________________________________

     File Type        Language Compiler
   __________________________________________________________________

     MAC              MACRO
     CBL              COBOL-68 or COBOL-74
     C74              COBOL-74
     C68              COBOL-68
     74C              COBOL-74
     68C              COBOL-68
     ALG              ALGOL
     B10              BLISS-10
     BLI              BLISS-10
     B36              BLISS-36
     SIM              SIMULA
     PAS              PASCAL
     SNO              SNOBOL
     FAI              FAIL
     SAI              SAIL
     FOR              FORTRAN
     REL              Object Program, do not compile
   __________________________________________________________________

For example, if you type the file name PAYROL, the system looks for PAYROL., PAYROL.MAC, PAYROL.CBL, PAYROL.C74, PAYROL.C68, and so on. If none of those files exists, the system prints the message: %Source file missing - PAYROL. If PAYROL.CBL exists; the system would compile PAYROL.CBL using COBOL.

If you have the files PAYROL.CBL and PAYROL.MAC and give a LOAD-class command listing the name PAYROL, the system uses the file PAYROL.MAC. If you also have the file PAYROL..1, the system uses it instead of using PAYROL.MAC. If PAYROL..1 needed compiling, the system would use the FORTRAN compiler.

9.3.2.1 Using Nonstandard File Types - If you include a file type in your file specification, the system examines the file type to select the proper translator. If the file type is not one of the standard file types shown in Table 9-1, the system uses the FORTRAN compiler.

        @COMPILE (FROM) TEST.REF
        FORTRAN: TEST
        MAIN.

If you want to use a nonstandard file type on a non-FORTRAN program, include one of the compiler switches after the file specification.

        @COMPILE (FROM) ENABLE.MON/MACRO
        MACRO: ENABLE

9.3.2.2 Setting a Default Compiler - You can set a default compiler with the SET DEFAULT COMPILER-SWITCHES command. For example, this command tells the system to use the PASCAL compiler whenever you give a filename without a file type:

        @SET DEFAULT COMPILER-SWITCHES /PASCAL

You can also define a file type to mean another compiler. For example, this command tells the system that a file with the type .C68 should compile with the COBOL-74 compiler instead of COBOL-68.

        @SET DEFAULT COMPILER-SWITCHES C68 /COBOL-74

To display your default settings, give the INFORMATION DEFAULT COMPILER-SWITCHES command. It is recommended that you put SET DEFAULT commands in your COMAND.CMD file.

9.3.2.3 Using the File Type .REL - If you want to use a particular object file, type the filename and the file type .REL. The system does not attempt to compile this file; it simply loads it into memory.

        @LOAD (FROM) START.REL
        LINK:   Loading

        EXIT

If you have an object program stored in a file with a file type other than .REL (this is highly discouraged), include the /RELOCATABLE switch after the file specification. Otherwise, the system attempts to compile the object program as a source program.

        @LOAD (FROM) MIDDLE.OBJ/RELOCATABLE
        LINK:   Loading

        EXIT

9.3.2.4 Examples - If you have the file TRYIT.FOR.1 and you give the following command:

        @EXECUTE (FROM) TRYIT
the system uses the file TRYIT.FOR.1. If you have the files NXTONE.MAC and NXTONE.CBL, and give the following command:
        @EXECUTE (FROM) NXTONE
the system searches Table 9-1 and finds .MAC before .CBL. Therefore, the system uses the file NXTONE.MAC.

If you have the files TABLE and TABLE.FOR, and give the command:

        @EXECUTE (FROM) TABLE
the system uses the file TABLE as the source program and compiles it with FORTRAN (as the default).

top

9.3.3 Compiling Only Out-of-Date Object Programs

Whenever you give a LOAD-class command that requires a .REL file, the system compiles an object program only if one or more of the following occurs:

  1. There is no existing .REL file with the same filename.
  2. The .REL file is out of date (which means that the .REL file is older than the corresponding source file).
  3. You give a /COMPILE switch to the LOAD-class command.

top

9.3.4 Remembering Arguments to LOAD-Class Commands

If you omit the arguments to a LOAD-class command, the system supplies the arguments you specified in the last LOAD-class command containing a file specification or LINK switch. For example, if you give the following sequence of commands:

        @COMPILE (FROM) TEST.FOR,SUB1.FOR
        @EXECUTE (FROM)
the COMPILE command stores its arguments; then, when you omit the arguments to the EXECUTE command, the system uses the arguments you gave to the COMPILE command.

Whenever you give a LOAD-class command, the system saves its arguments only if it contains a source or object file specification or a LINK switch. Otherwise, the system appends the saved arguments from a previous command to your current command. The system does not change the saved arguments to include the contents of your current command. Suppose you give the command:

        @COMPILE (FROM) /CREF/COBOL MANCOB,TTYIN,TTYOUT,LPOUT
then the command:
        @LOAD (FROM) /MAP

The arguments from the COMPILE command are appended to the single switch you gave in the LOAD command. The system really executes the command:

        @LOAD (FROM) /MAP/CREF/COBOL MANCOB,TTYIN,TTYOUT,LPOUT

If your next command is:

        @COMPILE (FROM) /COMPILE
the system executes the command:
        @COMPILE (FROM) /COMPILE/CREF/COBOL MANCOB,TTYIN,TTYOUT,LPOUT

Notice this command does not include the /MAP switch. The command:

        @EXECUTE (FROM) LINER.MAC
would change the saved arguments to just the file specification LINER.MAC. If you give a command without a source file specification and there are no saved arguments to LOAD-class commands, the system prints "?No saved arguments" and cancels the command.
        @EXECUTE
        ?No saved arguments

top

9.3.5 Concatenating Files to Produce One Source Program

Frequently it is useful to combine a parameter definition file or a small subroutine library with a main program. The + sign appends the file following it to the file before it to produce one source program. The example below shows how you might use a + to produce a MACRO program. The DEFS file contains parameter and storage definitions and the PROMPT file contains the main logic of the program.

        File DEFS.MAC

                        SEARCH MONSYM,MACSYM
               PRMTXT:  ASCIZ/NEXT COMMAND>/
                        T1==1
                        T2==2

        File PROMPT.MAC 
                        TITLE PROMPT
               PROMPT:  HRROI T1,PRMTXT    !Get address of string
                        PSOUT              !Print it
                        HALTF              !Stop
                        END PROMPT

        @COMPILE (FROM) DEFS+PROMPT
        MACRO:  PROMPT

top

9.3.6 Specifying Special Actions with Switches

You can supply various switches with the LOAD-class commands. Refer to the TOPS-20 Commands Reference Manual for a complete description of the LOAD-class commands.

Many switches have a global effect if you type them before any file specifications. For instance, the command:

        @COMPILE (FROM) /CREF TAB,SIFT,WOB
produces a cross-reference listing for each file and requires significantly less typing than if you had to type:
        @COMPILE (FROM) TAB/CREF,SIFT/CREF,WOB/CREF

It may be easier to set some global switches and turn them off for a particular file. If you have a list of source files with nonstandard file types that you want to compile with FORTRAN, you might use the command:

        @COMPILE (FROM) /FORTRAN SCHED.R1,ENA.R1,DIS.R1

Now suppose you add the routine MONINT.R1, which is a COBOL file; you could modify your command as follows:

        @LOAD (FROM) /FORTRAN SCHED.R1,ENA.R1,MONINT.R1/COBOL,DIS.R1

As a result of this command, all the files are compiled with FORTRAN except MONINT.R1, which is compiled with COBOL. The /COBOL switch located after the file affects only the file it follows.

However, if you add two COBOL programs, MON1 and MON2, your command is:

        @LOAD /FORTRAN SCHED.R1,ENA.R1,DIS.R1,/COBOL MON1.R1,MON2.R1

In that case, you have changed the global /FORTRAN switch to /COBOL, and each succeeding file is compiled using COBOL.

top