TOPS-20 User's Guide

Appendix C Changing your program using edit

This appendix shows you how to enter, run, edit, rerun and print a FORTRAN program.

  1. Entering your FORTRAN program
  2. Editing your FORTRAN program
  3. Rerunning a FORTRAN program

top

C.1 Entering your FORTRAN program

Type the FORTRAN program show below into a file called ADDTWO.FOR. (See Chapter 5, Section 5.1.1, EDIT.) This program contains errors that you will learn to correct in sections C.2.2 through C.2.6 of this appendix.

        @CREATE (FILE) ADDTWO.FOR
        Input: ADDTWO.FOR.1
        00100        C  THIS PROGRAM ADDS TWO NUMBERS.
        00200        <TAB>   TYPE 191
        00300        101<TAB>FORMAT  ('TYPE TWO NUMBERS.')
        00400        <TAB>   ACCEPT 102,X,Y
        00500        <TAB>   Z=C+Y
        00600        <TAB>   Z=X+Y
        00700        <TAB>   TYPE 103,X,Y,Z
        00800        103<TAB>FIRMAT  (' ADDING  ',F,' TO ',F,' GIVES ',F)
        00900        <TAB>   END
        00100        <ESC>
        *E

        [ADDTWO.FOR.1]
        @

Now that your program is in the file, run it to find any errors.

  1. Type EXECUTE, and press the ESC key.
  2. The system prints (FROM).
  3. Type the filename and file type of your program.
  4. Press the RETURN key.

The file type .FOR causes the FORTRAN compiler to translate your program.

        @EXECUTE (FROM) ADDTWO.FOR
        FORTRAN: ADDTWO
        00800   103     FIRMAT  (' ADDING ',F,' TO ',F,' GIVES ',F)
        ?FTNNRC Line:00800 Statement not recognized

        Underlined labels

          103      102      191

        ?FTNFTL    MAIN.        4 fatal errors and no warnings
        LINK:    ?LNKSUP Loading suppressed

        EXIT
        @

The program contained the following errors:

  1. In line 200, 191 should be 101.
  2. In line 800, the word FORMAT is misspelled as FIRMAT.
  3. Between lines 400 and 500, there should be FORMAT statement 102.
  4. Line 500 should be deleted.

top

C.2 Editing your FORTRAN program

You can remove the errors in your program by using the EDIT program.

top

C.2.1 Starting EDIT

You can start edit after you see the @ prompt:

  1. Type EDIT and press the ESC key.
  2. The system prints (FILE).
  3. Type the name of your file.
  4. Press the RETURN key.

EDIT prints the word "Edit:"; repeats the name of your file, and then prints an asterisk.

        @EDIT (FILE) ADDTWO.FOR
        Edit: ADDTWO.FOR.1
        *
NOTE

If you type the name of a file that does not exist, EDIT prints:

           ?FILE   NOT   FOUND,   CREATING   NEW   FILE    INPUT:
           name,type,generation 00100

This allows you to create a new file. If you mistyped the filename or file type, you should end this EDIT session and start over:

  1. Press the ESC key and type EQ (for End and Quit).
  2. Press the RETURN key.
  3. The system prints the @.
  4. Type a new EDIT command with an existing filename.

After you see the asterisk, you can use any of the commands described in this chapter to change your file.


top

C.2.2 Printing a Line

The first error in ADDTWO.FOR occurs in line 200. To view the error, print line 200 on your terminal.

To print a line:

  1. Type P.
  2. Type the number of the line that you want to print.
  3. Press the RETURN key.

The command P200 prints line 200.

        *P200
        00200        TYPE 191
        *

To check the other errors, you can print a group of lines:

  1. Type P.
  2. Type the number of the first line that you want to print.
  3. Type a colon.
  4. Type the number of the last line that you want to print.
  5. Press the RETURN key.

The command P300:900 prints lines 300 through 900, inclusive.

        *P300:900
        00300  101  FORMAT (' TYPE TWO NUMBERS.')
        00400       ACCEPT 102,X,Y
        00500       Z=C+Y
        00600       Z=X+Y
        00700       TYPE 103,X,Y,Z
        00800  103  FIRMAT ('ADDING ',F,' TO ',F,' GIVES ',F)
        00900       END
        *

top

C.2.3 Inserting a Line

To insert a line into your file:

  1. Type I.
  2. Type the number that you want to give to your new line.
  3. Press the RETURN key.
  4. EDIT prints the line number.
  5. Type the line.
  6. Press the RETURN key again.

The command I450 inserts the new line number 450 into you program.

        *I450
        00450  102<TAB> FORMAT (2F)
        *

After you press the RETURN key at the end of the inserted line, EDIT may print another line number. You can then type another line. If you don't want to type another, press the ESC key. EDIT prints an asterisk; you can now give any EDIT command.

        *I1000
        01000  C THIS IS A COMMENT AT THE END OF A PROGRAM -
        01100  C WHEN EDIT PRINTS THE NEXT NUMBER, YOU CAN TYPE A LINE.
        01200  C TO STOP INSERTING, PRESS THE ESC KEY.
        01300<ESC>
        *

top

C.2.4 Deleting a Line

To delete a line in your file:

  1. Type D.
  2. Type the number of the line that you want to delete.
  3. Press the RETURN key.
  4. EDIT confirms that it deleted the line.

Line 500 of ADDTWO.FOR should be deleted; the variable C should be an X. Line 600 contains the correction. The command D500 deletes line 500 on page 1 of the file.

        *D500
        1 LINES (00500/1)  deleted
        *

To delete more than one line:

  1. Type D.
  2. Type the number of the first line.
  3. Type a colon.
  4. Type the number of the last line.
  5. Press the RETURN key.

The command D1000:1200 deleted lines 1000 through 1200, inclusive.

        *D1000:1200
        3 LINES (01000/1:01200)  deleted
        *

top

C.2.5 Replacing a Line

To replace a line:

  1. Type R.
  2. Type the number of the line that you want to replace.
  3. Press the RETURN key.
  4. EDIT prints the line number.
  5. Type the new line.
  6. Press the RETURN key.
  7. EDIT prints a message giving the line numbers of any deleted lines.

The error in line 200 of ADDTWO.FOR occurs because 191 should be 101. The command R200 replaces line 200.

        *R200
        00200      <TAB>      TYPE 101
        1 LINES (00200/1)  deleted
        *

top

C.2.6 Changing a Line Without Completely Retyping It

To replace an existing group of characters on a line with a new group of characters:

  1. Type S.
  2. Type the existing group of characters.
  3. Press the ESC key (EDIT prints a $).
  4. Type the new characters.
  5. Press the ESC key.
  6. Type the line number that contains the existing group of characters.
  7. Press the RETURN key.
  8. EDIT prints the revised line on your terminal.

In line 800 of ADDTWO.FOR, the word FIRMAT should be corrected to FORMAT. The command SFIRMANT<$>FORMAT<>800 replaces the word FIRMAT with FORMAT.

        *SFIRMAT<ESC>FORMAT<ESC>800<RET>
        00800  103     FORMAT   (' ADDING ',F,' TO ',F,' GIVES ',F)
        *

top

C.2.7 Saving a File

To finish your EDIT session and save the edited file, type E and press the RETURN key. EDIT prints the name of your file and returns you to TOPS-20 command levels.

        *E

        [ADDTWO.FOR.2]
        @

top

C.3 Rerunning a FORTRAN program

After editing your program, run it again to find out if it works.

To reexecute a FORTRAN program, type EXECUTE and press the RETURN key. You do not have to give the name of the file. If you omit the filename, TOPS-20 executes the file that you named in your last EXECUTE command. In this case, TOPS-20 executes ADDTWO.FOR.

        @EXECUTE
        FORTRAN: ADDTWO
        MAIN.
        LINK:   Loading
        (LNKXCT ADDTWO execution)
        TYPE TWO NUMBERS.
        34,78
        ADDING      34.0000000 TO     78,0000000 GIVES    112,0000000
        CPU time 0.25   Elapsed time 10.03
        @

top

C.3.1 Typing Out Your Program

To see a final copy of your FORTRAN program printed on your terminal

  1. Type TYPE.
  2. Press the ESC key.
  3. The system prints (FILE).
  4. Type the filename and file type of your file.
  5. Press the RETURN key.
            @TYPE (FILE) ADDTWO.FOR
            00100    C THIS PROGRAM ADDS TWO NUMBERS.
            00200            TYPE 101
            00300    101     FORMAT (' TYPE TWO NUMBERS.')
            00400            ACCEPT 102,X,Y
            00450    102     FORMAT  (2F)
            00600            Z=X+Y
            00700            TYPE 103,X,Y,Z
            00800    103     FORMAT (' ADDING ',F,' TO ',F,' GIVES ',F)
            09000            END
            @

top