📄 fdosedit.gml
字号:
.chap Using the &product Editor
.*
.remark
The editor interface is only available when running &cmpname on a
DOS-hosted system.
.eremark
.*
.section Selecting the &cmpname Editor Interface
.*
.np
.ix editor integration
As we mentioned in the first chapter, a second way of using &cmpname
is with an integrated editor.
.ix editor '&cmpname Editor'
When invoked through &cmpname, the &cmpname Editor can be used to
create, modify, and run FORTRAN programs.
In this mode, the editor and compiler are completely memory
resident.
A program can be modified and then tested without needing to
store the source code on disk each time you wish to compile and
execute it.
While this mode of operation uses additional memory, it provides
a complete program development environment.
.np
To use the editor interface, you must place a copy of the program
"WEDITF.EXE" in the current directory or one of the directories
listed in the "PATH" environment string.
If the software has been installed on your system by someone else
then this may already have been done.
In any case, it will become readily apparent if this procedure
has not been done when you first try to use &cmpname with the
editor.
.remark
The &cmpname Editor, "WEDITF.EXE", may be used stand-alone as a
general purpose text editor.
When used in this manner, the "RUN" command described in the following
sections is disabled.
.eremark
.*
.section Invoking &cmpname and the Editor
.*
.np
.ix &cmpname starting
From the command line, &cmpname and the editor are invoked as follows:
.ix 'invoking &cmpname'
.ix 'invoking editor'
.mbigbox begin
&cmpcmdup./EDIT[[options] [d:][path]filename[.ext]]
or
&cmp2cmdup./EDIT[[options] [d:][path]filename[.ext]]
.mbigbox end
.synote
.note []
The square brackets denote items which are optional.
.ix &cmpcmdup.
.note &cmpcmdup.
is the version of &cmpname which does not require the 80x87 numeric
data processor.
.ix &cmp2cmdup.
.note &cmp2cmdup.
is the version of &cmpname which requires the 80x87 numeric data
processor.
.note EDIT
is the option that selects the editor interface.
.note options
.ix options specifying
is a list of other &cmpname options, each preceded by a slash.
The list of options may not contain any blank characters.
Options may be specified in any order.
These options are used as defaults each time a program is compiled
and executed from the editor.
.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.
.endnote
.np
The following tutorial will illustrate the use of &cmpname with the
integrated editor.
Afterwards, you may wish to consult the section of the book
entitled "The WATCOM Editor" for a more in-depth introduction to the
editor.
.np
.ix &cmpcmdup
In the following sections, we will use &cmpcmdup. to illustrate how to
use &cmpname and the Editor on the PC.
.ix &cmp2cmdup.
The name &cmp2cmdup. may be used in an equivalent manner when
the math coprocessor is present.
.np
Let us assume that the default drive is "A" and that
the compiler and editor reside on this diskette.
.ix &cmpcmdup
Type the command
.millust &cmpcmdup /EDIT
and press the "Enter" key.
.exam begin
C>&cmpcmd /edit
.exam end
.pc
.ix 'EDIT option'
.ix 'options' 'EDIT'
The "EDIT" option indicates that we wish to select the integrated
editor interface to &cmpname..
If any other options are specified on the command line, these will be
default options while you are using the editor.
.np
Once &cmpname is loaded into memory, the screen will clear and the
following lines will appear approximately in the centre, and to the
left side, of the screen.
:picture file='UGPRG0' text='WATFOR-77 Editor'.
:cmt. .cp 20
:cmt. .cbox begin
:cmt. .in -2
:cmt. &cmpname Editor 4.0 PC/DOS Copyright by WATCOM Systems Inc. 1981,1988
:cmt. ==|no_name&cxt.|=======================================================
:cmt.
:cmt.
:cmt.
:cmt.
:cmt. <beginning of file>
:cmt. <end of file>
:cmt.
:cmt.
:cmt.
:cmt.
:cmt.
:cmt. ======================================================================
:cmt. _
:cmt. F1: ...
:cmt. .in +2
:cmt. .cbox end
.np
This indicates that the &cmpname Editor is now ready for use.
If the message "Unable to start editor" appears then &cmpname could
not invoke "WEDITF.EXE".
Check that this file has been placed in the current directory or one
of the directories listed in the "PATH" environment string.
.np
.ix editor 'cursor'
A small bar called the
.us cursor
is at the left near the bottom of the screen.
.ix editor 'command entry area'
This line is known as the editor
.us command entry area.
.ix editor 'message area'
The line above the command line is called the editor's
.us message area.
The command entry area is used by you to give commands to the editor,
whereas the message area is used by the editor to communicate various
items of information to the user.
.np
The line below the command line displays a terse summary of
what some of the program function keys will do.
.*
.section Entering Commands
.*
.np
.ix editor 'entering commands'
.ix shell
.ix 'command shell'
When entering a command to the PC command processor or "shell", you
must press the "Enter" key as a signal to the shell to process what
you have typed.
The same is true of the editor.
To cause the editor to process a command, you must type in the command
and then press the "Enter" key.
In the following tutorial, we will dispense with the instruction to
"press the Enter key" when a command is to be entered.
.np
The editor can be used to create a new program or examine an existing
program.
We will use the editor to examine, run and modify an existing program.
We will also show you how to save the program on a disk and how to
print it.
.*
.section Examining the Directory
.*
.np
.ix editor 'examining directories'
To examine the names of files on disk from the editor, you can use the
editor's "directory" command.
Some examples follow:
.ix 'editor commands' DIRECTORY
.exam begin
directory
dir c:
di c:\watcom\src\fortran
.exam end
.np
The commands "dir" and "di" are short forms of the "directory" command.
This command functions in a manner similar to the shell's "DIR" command.
A list of programs and files will appear on the screen and either
the word <more> or the word <hold> will appear in the lower right-hand
corner.
If the word <more> is on the screen then pressing the "Enter" key
causes more of the list to appear.
If the word <hold> appears on the screen, pressing the "Enter" key
causes the list to disappear.
.*
.section Loading a Program
.*
.np
One of the programs included with the &cmpname software can now be
loaded into the computer and examined.
Enter a command similar to the following:
.ix 'editor commands' EDIT
.exam begin
edit c:\watcom\src\fortran\sample.&langsuff
.exam end
.pc
where "c:\watcom\src\fortran\" is one of several possible designations
for the path (i.e., drive and directory) containing the &cmpname
software.
Use the path that corresponds to the place where you installed the
&cmpname software.
After a short pause, the program will be loaded into the computer's
memory.
.np
The program will appear on the screen in the following format:
:cmt. .cp 15
:cmt. .mbox begin
:cmt. .in -2
:cmt. .im ugprg1
:cmt. .in +2
:cmt. .mbox end
:picture file='UGPRG1' text='A Sample Program'.
.np
This program is quite simple; when it is run, it will display the
line:
.millust This is my first &langabrv program
We will be working with this program throughout this introductory
tutorial.
.*
.section Running the Program
.*
.np
The program can now be run on the computer.
Enter the command:
.ix 'editor commands' RUN
.millust run
The screen will appear as follows:
:cmt. .cp 15
:cmt. .mbox begin
:cmt. .in -2
:cmt. .im ugprg2
:cmt. .in +2
:cmt. .mbox end
:picture file='UGPRG2' text='Running the Sample Program'.
.np
The output from the program is displayed on the screen.
Note that the compiler reads the program source from the
editor's workspace.
We do not have to store the program on disk first although
we will eventually want to do this so that we have a permanent
copy of the program.
Pressing the "Enter" key will cause the output to disappear.
We can now use the editor again.
.*
.section Using the Editor
.*
.np
In the next several sections, we will modify the &lang program
"SAMPLE.&langsuffup" in different ways to illustrate the basic
capabilities of the editor.
The editor has many commands and is very useful in constructing and
examining programs.
.*
.section Moving the Cursor
.*
.np
There are two important features or markers on the screen:
.begpoint
.point (i)
There is the cursor which at this moment is at the left near the
bottom of the screen.
.point (ii)
One line of the display is highlighted; it has an intensity which is
different from the other lines on the screen.
.ix editor 'current line'
This line is referred to as the
.us current line.
If you are using a monochrome display and no line on the screen
appears highlighted then you should adjust the display using the
"contrast" knob on the monitor.
.endpoint
.np
.ix editor 'cursor keys'
There are four cursor keys on the keyboard which control these
two features.
Each of these four keys has an arrow which indicates a
direction.
The cursor keys are grouped on the right side of the keyboard.
Pressing any of the cursor keys may cause a number to appear
at the cursor.
.ix 'Num Lock key'
.ix keys 'Num Lock'
.ix 'numeric lock'
If this happens then the keypad is in "numeric lock" mode.
.np
To cancel "numeric lock", press the "Num Lock" key.
Numeric lock converts the keypad on the right side of the keyboard
to a numeric role until it is depressed again.
.np
We can now use the four cursor keys to control the cursor and the
highlighted line.
Pressing the "cursor right" key (the one which points to the right)
will move the cursor to the right;
pressing the "cursor left" key will move the cursor to the left.
A different line can be highlighted by pressing the cursor "up"
and "down" keys respectively.
Now that we see how the two markers on the screen can be controlled
we shall try some other techniques.
.np
.ix editor 'function keys'
An area of the keyboard contains a number of special function keys.
These keys may be labelled F1, F2, etc. or perhaps PF1, PF2, etc.
.np
.ix editor 'F4 key'
Press function key 4 (F4 or PF4); the cursor will move to the beginning
of the highlighted line and the highlighting will disappear.
For the remainder of these exercises, we will refer to function
keys using the short form "Fx" where the "x" is one of the
numbers from 1 to 10.
The cursor can now be moved from line to line and along a line by using
the cursor control keys.
.ix editor 'text entry'
The cursor is in an area of the screen called the
.us text entry area.
.*
.section Changing a Program
.*
.np
We will now change our &langabrv program so that it displays a
slightly different message.
At this point the cursor should be in the text entry area of the
screen.
If it is not, simply press F4.
Now use the four cursor keys to move the cursor to the letter "f"
in the word "first" on the line that contains the words:
.millust This is my first
Type the word "other" over the word "first".
Now press F4 and the cursor will return to the command entry area of
the screen.
.np
We can enter the "run" command to run the program.
The screen should now appear as follows:
:cmt. .cp 15
:cmt. .mbox begin
:cmt. .in -2
:cmt. .im ugprg3
:cmt. .in +2
:cmt. .mbox end
:picture file='UGPRG3' text='Running Modified Sample Program'.
.np
Pressing the "Enter" key will cause the output to disappear.
.np
Let us now change the third line in the workspace to read
.millust begin
PRINT *, 'This is a FORTRAN program which I changed'
.millust end
.pc
This requires deleting the words "my other" and replacing them
with the letter "a" and inserting the words "which I changed" at
the end of the line.
To begin making these changes press F4 to move the cursor to the
text entry area.
Move the cursor to the letter "m" in "my" and type the letter "a".
The cursor will now move to the "y".
.ix 'Del key'
.ix keys Del
The characters "y other" can be deleted by depressing the delete
key (marked "Del") once for each letter or space to be deleted.
To enter the extra characters after the word "program",
move the cursor to the apostrophe (') after the letter "m".
.ix 'Ins key'
.ix keys Ins
Press the insert key (marked "Ins") and type " which I changed".
Note that the cursor appears larger when "insert mode" is active.
.begnote Notes:
.note (i)
To cancel "insert mode", simply press the "Ins" key again.
The cursor will return to normal size.
.note (ii)
If you make an error in typing, you can use the cursor keys and
the "Ins" and "Del" keys to correct your error.
.endnote
.np
This program can now be run by pressing F4 to return to the command
entry area and entering the "run" command.
The screen should now appear as follows:
:cmt. .cp 15
:cmt. .mbox begin
:cmt. .in -2
:cmt. .im ugprg5
:cmt. .in +2
:cmt. .mbox end
:picture file='UGPRG4' text='Another Run'.
.np
Pressing the "Enter" key will cause the output to disappear.
.*
.section Saving a Program
.*
.np
.ix editor 'saving a program'
The program which we have just changed can be saved on a diskette.
First ensure that the cursor is in the command entry area.
Recall that function key F4 can be used to do this.
Enter the command:
.ix 'editor commands' PUT
.millust put myprog.&langsuff
After a short pause, a message will appear in the message area of
the screen.
.millust begin
myprog.&langsuff - Lines transferred = 4
.millust end
.pc
The message area is just above the command line.
The message will disappear the next time you press the "Enter"
key.
.begnote Notes:
.note (i)
The message area is important since it is used to display
the status of an editor command.
If the editor cannot perform the requested command, it will
display a message reflecting this situation.
Thus you should always check the message area after entering
an editor command.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -