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.
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
@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.
C.2 Editing your FORTRAN program
You can remove the errors in your program by using the EDIT program.
C.2.1 Starting EDIT
You can start edit after you see the @ prompt:
- Type EDIT and press the ESC key.
- The system prints (FILE).
- Type the name of your file.
- 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 *
If you type the name of a file that does not exist, EDIT prints:
?FILE NOT FOUND, CREATING NEW FILE INPUT: name,type,generation 00100This allows you to create a new file. If you mistyped the filename or file type, you should end this EDIT session and start over:
- Press the ESC key and type EQ (for End and Quit).
- Press the RETURN key.
- The system prints the @.
- 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.
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:
- Type P.
- Type the number of the line that you want to print.
- 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:
- Type P.
- Type the number of the first line that you want to print.
- Type a colon.
- Type the number of the last line that you want to print.
- 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 *C.2.3 Inserting a Line
To insert a line into your file:
- Type I.
- Type the number that you want to give to your new line.
- Press the RETURN key.
- EDIT prints the line number.
- Type the line.
- 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> *C.2.4 Deleting a Line
To delete a line in your file:
- Type D.
- Type the number of the line that you want to delete.
- Press the RETURN key.
- 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:
- Type D.
- Type the number of the first line.
- Type a colon.
- Type the number of the last line.
- Press the RETURN key.
The command D1000:1200 deleted lines 1000 through 1200, inclusive.
*D1000:1200 3 LINES (01000/1:01200) deleted *
C.2.5 Replacing a Line
To replace a line:
- Type R.
- Type the number of the line that you want to replace.
- Press the RETURN key.
- EDIT prints the line number.
- Type the new line.
- Press the RETURN key.
- 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 *
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:
- Type S.
- Type the existing group of characters.
- Press the ESC key (EDIT prints a $).
- Type the new characters.
- Press the ESC key.
- Type the line number that contains the existing group of characters.
- Press the RETURN key.
- 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) *
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] @
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 @
C.3.1 Typing Out Your Program
To see a final copy of your FORTRAN program printed on your terminal
- Type TYPE.
- Press the ESC key.
- The system prints (FILE).
- Type the filename and file type of your file.
- 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 @