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.
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.1 Entering your FORTRAN program
@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.
- Type EXECUTE, and press the ESC key.
- The system prints (FROM).
- Type the filename and file type of your program.
- 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:
- In line 200, 191 should be 101.
- In line 800, the word FORMAT is misspelled as FIRMAT.
- Between lines 400 and 500, there should be FORMAT statement 102.
- Line 500 should be deleted.
You can remove the errors in your program by using the
EDIT program.
You can start edit after you see the @ prompt:
EDIT prints the word "Edit:"; repeats the name of your
file, and then prints an asterisk.
If you type the name of a file that does not exist, EDIT
prints:
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:
After you see the asterisk, you can use any of the
commands described in this chapter to change your file.
The first error in ADDTWO.FOR occurs in line 200. To
view the error, print line 200 on your terminal.
To print a line:
The command P200 prints line 200.
To check the other errors, you can print a group of
lines:
The command P300:900 prints lines 300 through 900,
inclusive.
The command D1000:1200 deleted lines 1000 through 1200,
inclusive.
To replace a line:
The error in line 200 of ADDTWO.FOR occurs because 191
should be 101. The command R200 replaces line 200.
To replace an existing group of characters on a line with
a new group of characters:
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.
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.
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.
C.2 Editing your FORTRAN program
C.2.1 Starting EDIT
@EDIT (FILE) ADDTWO.FOR
Edit: ADDTWO.FOR.1
*
?FILE NOT FOUND, CREATING NEW FILE INPUT:
name,type,generation 00100
C.2.2 Printing a Line
*P200
00200 TYPE 191
*
*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
*
*D1000:1200
3 LINES (01000/1:01200) deleted
*
C.2.5 Replacing a Line
*R200
00200 <TAB> TYPE 101
1 LINES (00200/1) deleted
*
C.2.6 Changing a Line Without Completely Retyping It
*SFIRMAT<ESC>FORMAT<ESC>800<RET>
00800 103 FORMAT (' ADDING ',F,' TO ',F,' GIVES ',F)
*
C.2.7 Saving a File
*E
[ADDTWO.FOR.2]
@
C.3 Rerunning a FORTRAN program
@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
@