📄 fdosedit.gml
字号:
.note (ii)
In the previous example of the "put" command, it was not
necessary to specify the file
.us extension
"&langsuff".
&cmpname will automatically supply this extension when the "." and
extension are omitted as follows:
.millust put myprog
Similarly, it is not necessary to specify the file extension
when using the "edit" command.
.note (iii)
The program has now been saved on a diskette using the "put"
command ("p" is an abbreviation) and you can use the "dir"
command to verify that
.mono "MYPROG.&langsuffup"
is there.
.note (iv)
Sometimes the "put" command may not succeed and a different message
appears in the message area.
For example, the message
.millust begin
Attempt to write on write-protected diskette
.millust end
.pc
could appear.
The diskette in the default drive may have a write-protect tab placed
over the notch which prevents you from modifying the diskette.
Check that you are using the correct diskette.
If the diskette contains the &cmpname software then you may wish to
remove it and insert another diskette that will accept new files.
.note (v)
There are other reasons why you may be unable to store the program on
a disk.
The message should explain what the problem is and permit you to take
corrective action.
.endnote
.*
.section Adding a Line to a Program
.*
.np
We may also want to add lines to an existing program or create a new
program.
The program you have just saved can be used to illustrate the addition
of lines to a program.
.np
.ix Tab 'setting TAB stops'
.ix 'Tab key'
.ix keys Tab
Before we do this, it might be appropriate to introduce you to two new
editor commands.
The PC keyboard contains a special key for moving the cursor to
certain places on the line called TAB stops.
By default, pressing the TAB key moves the cursor to one of columns 9,
17, 25, etc. (i.e., 1 + some multiple of 8).
Pressing both the SHIFT key and the TAB key causes the cursor to move
back to the previous TAB stop (Reverse TAB).
While this arrangement is adequate for the entry of text, it would be
nice if we could define a different set of TAB stops for the entry of
FORTRAN statements.
.ix 'XLINE option'
.ix 'options' 'XLINE'
FORTRAN requires that we enter statements between columns 7 and 72
inclusive (you can use the &cmpname "XLINE" option to extend the line
length to 132).
Let us define a set of TAB stops suitable for FORTRAN programs.
.ix 'editor commands' TABSET
Enter the command:
.millust tabset 1 7 11 15 19 23
This command will redefine the default TAB stops (but only while you
are using the editor).
When you return to the operating system shell, they will revert back
to the default.
Additional TAB stops or other ones can be defined according to
preference.
.np
.ix 'margin bell'
If any text is typed beyond column 72, it will be ignored by &cmpname
according to the rules of FORTRAN.
.ix 'editor commands' BELL
Since we don't want to enter FORTRAN statements that go past column
72, enter the following command:
.millust bell 72
This will cause the editor to issue an audible alarm (a beep) whenever
the cursor moves from column 72 into column 73.
This will indicate that the FORTRAN statement should be continued on a
new line (using the rules concerning continuation of FORTRAN
statements).
.np
Move the cursor to the text entry area using F4 and then position the
cursor on the line that contains the words "This is a".
.ix 'F5 key'
.ix keys F5
Press function key 5 (F5) to create a blank line following this line.
The cursor will automatically move to the beginning of the new line
and change height to indicate that you are now in text insertion mode.
Recall that the "Ins" key can be pressed to switch into and out of
text insertion mode.
You can now press the Tab key and type:
.millust begin
PRINT *, 'to illustrate the editor'
.millust end
.pc
The new line should be aligned with the line above.
After the line is completely typed (do not forget the apostrophes),
you can press F4 to return to the command entry area and then run the
program.
The screen should appear as follows:
:cmt. .cp 15
:cmt. .mbox begin
:cmt. .in -2
:cmt. .im ugprg7
:cmt. .in +2
:cmt. .mbox end
:picture file='UGPRG5' text='Adding Lines'.
.np
If you make an error in typing, you may get an error message which
indicates the program is not correct.
For example, if the last apostrophe was not included in the line just
added, the screen would appear as follows:
:cmt. .cp 15
:cmt. .mbox begin
:cmt. .in -2
:cmt. .im ugprg8
:cmt. .in +2
:cmt. .mbox end
:picture file='UGPRG6' text='Diagnosing Errors'.
.np
Return to the editor by pressing the "Enter" key.
You may now correct the program using the techniques we have
discussed above.
.*
.section Deleting a Line
.*
.np
Deleting a line from a program is quite simple.
Move the cursor to the text entry area by pressing function key F4
and then move the cursor to the line that was just added to the
program.
.ix editor 'F6 key'
Press function key F6 and the line on which the cursor is located will
disappear.
Note that pressing Shift together with function key F6 will cause the
line to reappear.
.*
.section Printing a Program
.*
.np
.ix editor 'printing a program'
The program in which we have just deleted a line can be printed on
a printer.
To print the program, move the cursor to the command entry area
using the F4 key.
Enter the command:
.millust put prn
After a short pause, a message will appear in the message area of
the screen.
.millust begin
prn - Lines transferred = 4
.millust end
.pc
This message will disappear the next time you press the "Enter" key.
.np
The program has now been printed on the printer using the "put"
command.
.begnote Notes:
.note (i)
Make sure your printer is on and the on-line switch has been pressed
before you start printing.
.note (ii)
If you are using a network then your program may not actually be
printed.
Instead your program file may be held in a print "queue" until you
issue a special network command to the operating system shell to
release the file for printing.
.endnote
.*
.section Returning to the Operating System Shell
.*
.np
To conclude, we will show how to exit from &cmpname and return to the
shell.
Enter the command
.ix 'editor commands' BYE
.millust bye
and one of two things will happen:
.begnote
.note (i)
the shell prompt will reappear on the screen, or
.note (ii)
the message
.millust File modified - use QUIT to quit anyway
will appear in the message area.
.endnote
.np
If the latter occurs then some change was made to the program and it
has not been "put" to disk since that change.
.ix 'editor commands' QUIT
If you are not interested in saving the modified program, simply enter
the command
.millust quit
and the shell prompt will reappear on the screen.
Otherwise, use the "put" command to save your program and then issue
the "bye" command.
.*
.section Summary
.*
.np
This brief discussion has shown you how to use the editor to
.begnote
.note (i)
get FORTRAN programs from disk using the "edit" command;
.note (ii)
run FORTRAN programs using the "run" command;
.note (iii)
put FORTRAN programs to disk using the "put" command;
.note (iv)
modify FORTRAN programs;
.note (v)
exit from the editor and &cmpname using the "bye" command.
.endnote
.np
Although you have enough information to use the &cmpname system and
editor, there are many different ways to perform the functions
described here.
To acquire further knowledge about the editor, you should read the
section of the book entitled "The WATCOM Editor".
.*
.section The "RUN" Command
.*
.np
.ix RUN
.ix 'editor commands' RUN
In the above examples, we showed you the simplest form of the
editor's "RUN" command.
It can also be used to pass options to the &cmpname compiler and
to compile other programs.
.ix 'invoking &cmpname'
.mbigbox begin
RUN[options] [[d:][path]filename[.ext] [prog_parms]] [options]
.mbigbox end
.synote
.note []
The square brackets denote items which are optional.
.note options
.ix 'options' 'specifying'
is a list of valid &cmpname options, each preceded by a slash.
The list of options may not contain any blank characters.
Options may be specified in any order.
.note d:
is an optional drive specification such as "A:", "B:", etc.
If not specified, the default drive is assumed.
.note path
is an optional path specification such as "\SRC\PROGRAMS\".
If not specified, the current directory is assumed.
.note filename
is the file name of the file to be compiled.
.note ext
is the file extension of the file to be compiled.
If omitted, a file extension of "for" is assumed.
If the period "." is specified but not the extension, the file is
assumed to have no file extension.
.note prog_parms
is an optional list of program parameters that may be accessed by
the executing program through use of the library function
.id FGETCMD
or the functions
.id IARGC
and
.id IGETARG.
See the chapter entitled "The &cmpname Subprogram Library" for
more information on these functions.
.endnote
.autonote Notes:
.note
If no options are specified then the currently configured defaults
are used.
The default options include any that were specified on the operating
system shell's command line.
.note
If no file is specified then the contents of the current workspace
are processed.
:cmt. .note
:cmt. If you wish to specify parameters to the executing program
:cmt. but do not want to type the current workspace name
:cmt. then you can specify an "*" to represent the current workspace.
:cmt. .exam begin
:cmt. run * arg1, arg2, arg3
:cmt. run/debug * arg1, arg2, arg3
:cmt. .exam end
.note
If a file name is specified and the specification matches the name of
a workspace then that workspace is processed.
.note
With the "RUN" command, you can request &cmpname to process:
.begpoint
.point (i)
the current workspace,
.point (ii)
another workspace, or
.point (iii)
a file on disk.
.endpoint
.note
.ix 'options' 'summary'
If you enter the command:
.millust RUN ?
then &cmpname will display its command line options summary.
.note
If you are not familiar with the concept of workspaces then you should
read the section of the book entitled "The WATCOM Editor".
.endnote
.*
.section Compiling FORTRAN Programs
.*
.np
Consider the following program which attempts to compute the square
root of a number and display the result.
:cmt. .cp 15
:cmt. .mbox begin
:cmt. .in -2
:cmt.
:cmt. <beginning of file>
:cmt. * Program to compute a square root
:cmt.
:cmt. NUMBER = -144
:cmt. SQROOT = SQRT( NUMBER )
:cmt. PRINT *, SQROOT
:cmt. END
:cmt. <end of file>
:cmt.
:cmt. .in +2
:cmt. .mbox end
:picture file='UGPRG7' text='Computing a Square Root'.
.np
.ix 'comment line'
.ix 'statement'
This program consists of a
.us comment line
and some FORTRAN
.us statements.
.np
If you want to change the workspace name, you can use the editor's
"NAME" command as follows:
.millust name root&cxt.
To compile and execute this program, enter the command:
.millust run/list
.ix 'LIST option'
.ix 'options' 'LIST'
This command requests &cmpname to process the current workspace and
ensures that a listing of the source program is produced on disk.
.np
.ix message interpretation
There are deliberate errors in the program so the message
.code begin
root&cxt.(4): *ERR* LI-12 column 15, INTEGER argument type is invalid
for this generic function
.code end
.pc
is displayed on the screen.
How should this message be interpreted?
.np
The message
.mono *ERR*
means that some violation of the rules of FORTRAN has been committed.
.ix message error
.ix error
.ix line
Specifically, on the fourth line of the source file
:FNAME.root&cxt.:eFNAME. near column 15 an error was detected.
The error says that the argument of the generic FORTRAN function that
was used (in this case
.id SQRT
.ct )
cannot be an
.kw INTEGER
argument.
The
.us error code
.ix 'error code'
.mono LI-12
is composed of an error category and number.
The error code may be used to look up the message in the
diagnostic summary in the appendix entitled "&cmpname Diagnostic
Messages" at the end of this guide.
This appendix provides an explanation of all diagnostic messages
issued by &cmpname..
.np
In addition to the message that is displayed on the screen, a
source program listing file,
:FNAME.root.lst:eFNAME., is created by the compiler.
.ix listing source
To examine the listing file, enter the command:
.millust edit root.lst
The contents of the screen will appear similar to the following.
:cmt. .cp 25
:cmt. .cbox begin
:cmt. .in -2
:cmt. <beginning of file>
:cmt. &product &ver &cdate
:cmt. .cpyrit 1984
:cmt. .trdmrk
:cmt.
:cmt. Options: list,disk,extensions,reference,warnings,terminal,run,xtype,check,
:cmt. arraycheck,statements=0,pages=0,time=0,codesize=524288,pagesize=66,fover
:cmt.
:cmt. * Program to compute a square root
:cmt.
:cmt. 1 NUMBER = -144
:cmt. 2 SQROOT = SQRT( NUMBER )
:cmt. $
:cmt. *ERR* LI-12 INTEGER argument type is invalid for this generic function
:cmt. 3 PRINT *, SQROOT
:cmt. 4 END
:cmt.
:cmt.
:cmt. Compile time (in seconds): 0 Execution time (in seconds): 0
:cmt. Size of object code: 0 Number of extensions: 0
:cmt. Size of local data area(s): 0 Number of warnings: 0
:cmt. Size of global data area: 0 Number of errors: 1
:cmt. Object bytes free: 0 Statements Executed: 0
:cmt. <end of file>
:cmt.
:cmt. .in +2
:cmt. .cbox end
:picture file='UGPRG8' text='The Square Root Listing File'.
.np
In the listing file, we find a copy of the original source program and
some additional lines which the compiler has added.
The line that was in error is followed by a line containing an error
indicator or marker (a dollar sign "$").
An error message, similar to the one that was displayed on the screen,
follows that line.
.np
Near the start of the program listing is a line indicating which
options were in effect at the time the compilation of the program
began.
These and other options are described in the chapter entitled
"Compiler Options".
.ix statistics compile-time
.ix statistics execution-time
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -