NB. This file is now out of date. There is a doc file called VEDPRIMER.
which is more systematic and comprehensive, and a still more comprehensive
DOC file called VEDMANUAL.


                VED PRIMER
                ----------
        (For computing beginners)

First make sure you are familiar with the procedure for logging in, calling
POP11, and logging out.

This document introduces a number of concepts which will be unfamiliar to
you, and may therefore be hard to take in at first. The easiest way to grasp
these concepts is to have practice playing at the terminal. Before you try
using VED read this document once quickly, ignoring bits that are unclear.
After you have used VED for a while, read this again.

VED was designed primarily for use with the VISUAL-200 terminal. (Other
terminals have different keyboad conventions. The POP11 library contains
conversions for VT100, Lyme4000, Lyme4004, Lyme5000, and Televideo (with VT52
emulation). The HELP VT100 file explains the layout of the VT100 keyboard.
HELP L4000 explains how to use the Lyme4000 or Lyme 4004, and HELP TVI
explains how to use the Televideo.


WHAT IS VED FOR?
---------------
VED can be used in a number of different ways. The TEACH program uses VED to
take you through files of "lessons" we have prepared to help you learn POP11.
The HELP program uses VED to enable you to read short explanations of various
features of POP11. The REF and DOC programs enable you to read files which
provide reference documentation on the POP11 system. However, most of these
reference files will only be relevant to advanced users. The SHOWLIB command
uses VED to display programs from the POP11 library.

VED can also be used directly to create and alter your own text or program
files. This document gives you a general overview of the main facilities in
VED. You can get more detailed instructions by logging in, running POP11,
waiting for the colon prompt (':') then typing one of:
        : TEACH TEACH;

followed by the RETURN button. Allow at least an hour for your first lesson.
It may take a few days to get fluent. Practice makes perfect.
(The version of TEACH at Sussex University assumes you are using a
VISUAL-200 VDU. There may be different versions elsewhere.)


If your terminal is a VT-100 (or equivalent, e.g. a VISUAL-100) then you
should type
        : TEACH VT100;
and press RETURN to find out how the keys work.

The VISUAL 200 KEYBOARD
-----------------------
On the keyboard you will find, besides the normal typewriter keys, several
others, in particular keys labelled F0 to F13 on the top, and keys labelled
with arrows and other symbols (e.g. 'BRK', 'RST', 'CP') on the top right.
Below them are the numbered keys in the 'numeric keypad', also with other
mysterious symbols. In general the symbols on the keys are irrelevant for our
purposes, although we make use of most of the keys. Notice especially the
RETURN key, the ENTER key (bottom right) and the CONVERT FUNCTION key. These
will be referred to below. There are three keys which do not in themselves
transmit signals to the computer, but are held down whilst pressing other
keys, to modify the signal the other key transmits. These 'modifier' keys are
marked,
        CTRL            SHIFT           CONVERT/FUNCTION


Using VED
---------

When you want to use VED to create a file of your own, e.g. a file called
POEM, you can type "VED", then the name of the file, then a semi colon, then
press RETURN; e.g.
        : VED POEM;

You don't type the colon ':' -- that is the 'prompt' symbol printed out by
POP11. Our examples here are printed in capitals but you should always type
in lower case, not capitals. If you want the file to contain POP11 programs,
then its name should end with '.P', e.g.
        : VED MYPROG.P;

Ved will clear the lower half of the screen, which will be used for the 'edit
window'. At the top of the editing area you will see a "command" line, with a
message reminding you of the file you are working on, and the line number the
'cursor' is on. The cursor is a white rectangle, and indicates where things
you type will alter the file.

If you are creating a new file, the editing "window" will be blank, except
for the white "cursor". If it's an old file, Ved will copy the file into a
new temporary file, and display the first few lines on the screen in the
"window".

There are several things you may wish to do with the file, including:

(1) Typing some additional text: this will be inserted where the cursor is.
You just type anything you want, using RETURN to insert new lines.

(2) Deleting portions of the text. You can press the DEL button to delete the
character to the LEFT of the cursor. (There are also buttons for deleting
larger chunks of text: F1 to F5 on the top row. TEACH VED; will show you how
to do this. Alternatively experiment and see what happens!)

(3) Moving the cursor to a different part of the screen so that you can make
some insertions or deletions. For big moves, to the top or bottom of the
window or left or right of a line use the four keys with arrows on the top
right of the keyboard. For small moves up or down, left or right, or
diagonally up or down, press one of the numbered keys on the keypad to the
right. The keys are in the format:


                        7 8 9
                        4 5 6
                        1 2 3

Key 5 moves the cursor to the middle of the text on the current line. The
others move the cursor in a direction similar to a line going from key 5 to
the key. E.g. key 3 moves the cursor diagonally down to the right.

(4) Moving a different portion of the file into the visible portion of the
screen. This is done by trying to make the cursor move off the top or bottom
of the screen using the buttons mentioned in (3) above. E.g. keep moving the
cursor DOWN to make the screen contents "scroll" UPWARDS and vice versa.
(This will only work if you have more text in the file than can be shown on
the screen.) Move the cursor to the RIGHT to make the screen scroll
LEFT. (This will only work if you have a very long line of text, jutting out
beyond the right edge of the screen. VED will let you do this only if it is
a program file, i.e. if the name of the file ends with '.P'. Other files are
assumed to be TEXT files, and VED will break lines to make sure they fit onto
the screen.)

(5) Telling ved to "write" the contents of the file into your disk area, or
to consolidate the file (make the temporary file permanently available).
It is wise to do this from time to time to make sure that your work is stored
safely in your disk area even if the processor breaks down while you are in
the middle of editing.

To do this, press the ENTER button (bottom right). Ved will then go into
"command" mode with the cursor on the "command" line. You then type:
                W
then RETURN. Ved prints a message to the right of your command to tell you
it's obeying the command. When it is done, the cursor returns to the text
"window" region. The W command makes VED write all the files you are editing,
if you happen to be editing more than one (see below). To make it write only
the current file, i.e. the one you are looking at, and not others which you
may have been editing earlier, press ENTER then
                W1

(6) Enlarging the visible window. To do this press the ESC button, then W. If
you do it again then the visible area will again shrink to half the screen.
You'll soon learn that starting with a small window is very useful when you
want to see what was previously printed out when you start editing a file.
Changing window size can be confusing for beginners, so do it only if you
find the small size very restrictive.

(7) Searching through the file for a specified string. Suppose you want to
move the cursor to a line containing the word "define". You can do this by
first going into command mode (press ENTER) then type a "slash" i.e. "/" on
the bottom row of keys (not the "backslash" "\" higher up the keyboard),
then type the "search string" then press RETURN, e.g. the command
        /define

will search for "define". If you want it not to find an EMBEDDED
occurrence of the word, you can specify this using the command
        "define

I.e. press ENTER, then '"define' then RETURN. It will not then find a line
containing 'enddefine'.


Notes: to be ignored on a first reading:

    You can also specify that the word must occur at the beginning of a
    line, by using the symbol "@a" thus:
        /@adefine

    or to search for "define" at the END of the line, use "@z",
    i.e. enter the command:
        /define@z

    To find a string containing "d" and "e" separated by any other character
    use the symbol "@?" to match an arbitrary character, e.g.
        /d@?e

    this will search for the first occurrence of any of "dae" "db", etc.

    Similarly
        /d@?@?@?ne will find "define" or "dryane" or "debone".

    To find a string containing "/", put "@/" into the search string. To find
    a string containing "@", put "@@" into the search string. E.g. to search
    for "@@" you'll have to type:
        /@@@@

    If you give an empty search string, e.g. press ENTER and type the
    command:
        /

    then Ved will simply use the same search string as in your last
    search command (or substitute command - see below).


If the search finds the wrong occurrence you can use the key with the "-"
next to the ENTER key, on the right of the keyboard. This is the "repeat last
command" key.

WARNING: If VED cannot find the string by searching to the end of the file it
goes to the top of the file and looks for the first occurrence it can find
from there. This 'wrap-around' feature is useful but can be confusing. The
line number of the cursor is always displayed on the command line to keep you
informed.

Searching backwards
-------------------
You can search backwards using the '\' symbol, thus: press enter, then type:
        \define

to search backwards for an occurrence of 'define'. At present backward search
does not 'wrap around' from the top to the bottom of the file. Neither can
you use fancy symbols like '@?' or '@n' to modify the search.


(8) Giving a combined "search and substitute" command.

Suppose you wish to replace an occurence of "deffine" with "define". You can
enter command mode, then type:
        s/deffine/define

and press RETURN.

Ved will search for an occurrence of "deffine" and wiggle the cursor to catch
your eye. You then have four options:


    (a) press "y" to do the substitution and stop.
    (b) press RETURN to do the substitution and go on to the next
    occurrence of the search string.
    (c) press DEL to leave this occurrence and then go on to the next one
    (d) press "n" to stop without doing the substitution.


Option (b) is specially useful, since it allows you to go through the file
changing lots of occurrences of a string.

If you want to ensure that it does not find an EMBEDDED
occurrence of "deffine" use '"' instead of '/', i.e. ENTER then
        s"deffine"define

then RETURN.

Notes to be ignored on a first reading:

    Instead of "/" in the S command, you can use another "string delimiter",
    e.g. "." or "," or ";"

    The search string in the substitute command can specify beginning or end
    of line with "@n", an arbitrary character with "@?"; the string delimiter
    by "@" followed by the symbol e.g. "@/". All these except "@?" can also
    be used in the replacement string.

    If you want to repeat the search string in the replacement string use
    "@&" to save retyping. E.g. to replace "rabbit" with "rabbits", type the
    command
            s/rabbit/@&s

    S can also be given an empty search string, meaning "use the previous
    search string, e.g.
            s//bunny

    The two slashes, without a space indicate an empty search string, and
    will cause the previous search string to be used.

    If you type S without a search or substitute string then it will use the
    last search string (whether used by S or by the search command) and also
    the last substitute string. E.g.
            s

    will again look for 'rabbit' and replace it with 'bunny'.


You can ask VED to do a GLOBAL substitution, i.e. to replace ALL occurrences
of a string in the file, without asking your permission for each one, if you
use the GS command, e.g. press ENTER then
        gs/rabbit/bunny

then RETURN, to replace all occurrences of 'rabbit' with 'bunny'. You'll be
told how many substitutions are being done. As with the ENTER-S command, you
can use the symbol '"' instead of '/' to mean don't replace an embedded
substring. E.g. to replace "the", with "that", but not inside "there" etc. do
        gs"the"that

If the GS command has nothing following it, then like S it uses the same
search string and substitute string as before. This is useful if you wish to
do the same global substitution on several files.


Using a 'marked range'
---------------------
You can restrict the global substitute to a specified 'range' of the file.
You mark a set of lines by using the keys F7 and F8 (mark-first and
mark-last). Put the cursor on the first line, of the desired range and press
the mark-first key, then put it on the last line and press the mark-last key.
You will see a vertical line appear on the left of the marked range. If you
then use not GS, but GSR (global substitute in a range) the substitutions
will be done only in the lines marked. Otherwise GSR works just like GS.

(9) Merging and breaking lines.
If you want to join two consecutive lines, put the cursor at the beginning of
the second line and press DEL. (Think of this as deleting a "newline"
character.) The resulting line may be too long to fit on the screen. If the
file name does not end in '.p', VED will assume it is a text file, and will
break the line in a suitable place so that everything remains visible. If
it does end in '.p', VED assumes it is a program file, and does not break
the line. The end of the line may then disappear off to the right. To pull it
into the visible portion, you can move the cursor to the right hand side of
the screen and keep on pressing the MOVE-RIGHT button (No 6 on the Keypad).
Everything on the screen will shift to the left, and the missing portion of
your long line will become visible. You can break the line when the cursor is
at a convenient point by pressing RETURN. However, if the name of the file
does not end with '.P' then VED assumes it is a text file, and will move as
much of the line back onto the previous line as it can without allowing it to
go off the edge of the screen. The rest of the line will be left where it
was, though shifted to the left margin.

To break a line in the middle, move the cursor to the desired position, then
press RETURN.

(You can also merge or break lines using the S or GS command with "@n"
either in the search string or in the replacement string.)

(10) Ask POP11 to compile and obey the commands in the Ved file.
ENTER command mode and type
                X

then press RETURN. This will cause the current file, to be 'written' as a
permanent file in your area of the disk, then if it is a program file, POP11
will compile (or load) the program. (Later you will learn how you can
have several files active. The X command writes and compiles all of them.)

Compilation (or loading) means that POP11 reads in the file as if you had
typed it directly. That is, POP11 commands in the file are obeyed. If the
file contains definitions of new procedures, then the procedures will be
constructed. If it contains commands to run procedures, then they will be
run. (Procedures are not automatically run when their definitions are
compiled.) Usually the first few times you try to compile a program file,
things will go wrong, and you'll have to do more editing to correct mistakes.

After writing (and if necessary loading) VED returns you to POP11. Error
messages and other printing will appear at the bottom of the screen, and the
previous VED window will move up. If there is an error, then VED will ask
you to press RETURN when you have read the error message. That will take
you back automatically to edit the file, and the cursor will show you how far
POP11 had got before it found a mistake. The actual source of the mistake
could be something left out, or wrongly typed further up the file.

If there are no mishaps, VED is temporarily suspended, and you can then give
commands to POP11, e.g. to test your program. When POP11 is ready for you to
type something, it prompts with a colon, as usual.

If you later type, to POP11:
        : VED;

i.e. call VED without specifiying a file name, you'll go back to editing the
same file as before.

If you want to write and compile just the file you are looking at, and none
of the other files currently in the editor, then inside
VED, use the command
        ENTER X1 RETURN

If you want your files to be compiled without being 'written' or consolidated
as permanent files on the disk, you can use the ENTER C command. If you use
ENTER C1, then only the current file will be compiled.

(11) Abandon the edit, without saving the new file in your disk area.
This is useful if you have been looking at a file to remind yourself of its
contents, or if you have made some editing mistakes and want to start again.
Give the command ENTER
        Q

(for Quit). (I.e. press ENTER then Q, then RETURN. If you've made some changes
to the file Ved will ask if this was a mistake. But you can FORCE a quit by
entering, the command
        RRQ

(for "really really quit").

After Q or RRQ ved returns you to POP11 and gets rid of the new file.
But it remembers the name, so you can start editing the same file again
by typing.
        : VED;

(Note for more advanced users. If you have several edit files active, then
the Q or RRQ command will not return you to POP11. Instead it will get
rid of the current file, and then restore the next file on its list to
the edit window.)

(12) Leaving VED temporarily to give POP11 some instructions. By ENTERing the
command
        POP

you return to the POP11 compiler. Your edit file(s) will not be deleted.
Neither will they be consolidated on the disk or compiled. If you later type
        : VED;

to POP11 you'll get back to editing the same file as before.

You can also type a POP11 instruction on the command line if you press ENTER
then type a colon, then type the instruction, then press RETURN. E.g.
        ENTER : 99 * 5  RETURN

will cause the result to be printed out on the command line, if it will fit
there, otherwise at the bottom of the screen. In the latter case, VED will
not restore the screen to its previous state until you press RETURN again.

(13) Tidying (Justifying) your file.

Programs are much more readable if they are "indented" properly.
You'll see what this means from examples during the course. When you've
written a POP11 program using VED and tested it with the X command to ensure
that it compiles without errors, you can ask VED to do the indentation for
you. Equally, you can ask ved to tidy up some text for you.

The easiest way to do this is a procedure or paragraph at a time. Put
the cursor inside a procedure, or in the paragraph you want 'justified'. The
press ENTER and type
        JP

and RETURN. Think of 'JP' as meaning 'justify paragraph' for a text file, or
'justify procedure' if it is a program file (ending with '.P'). VED will
alter the file as appropriate, and also in the case of a program file, will
leave the procedure MARKED on the left. (This is useful in case you want to
use the 'Load Marked Range' facility.)

You can also ask VED to 'justify' a portion of the file which you specify.
Return to VED and use the MARK RANGE keys (F7 and F8) to mark the
beginning and end of the range you'd like to have tidied. Then ENTER the
command
        J

If, for example you have typed in something like
        if weather =  rain then
        take (umbrella);
        travel (bus);
        else
        travel (bicycle)
        endif

then, assuming its a '.P' file, the J command will transform this to:
        if weather = rain then
            take (umbrella);
            travel (bus);
        else
            travel (bicycle)
        endif

showing the structure of your program more clearly. No lines are broken or
merged, and no mistakes are corrected. Only indentation changes.

You can also "tidy" a file which contains text instead of program.
For this you also use the "J" (for justify) command. Again use the MARK RANGE
buttons, F7 and F8 to mark the range you want justified. Then press ENTER,
give the command J, and press RETURN. VED will try joining lines to fill up
the width of the screen. However, if a line starts with spaces then it will
not be joined to the previous line, and the spaces will remain. Also, blank
lines will not be removed.

(14) 'Refreshing the VDU screen.'

Sometimes while you are in the middle of using VED something will happen to
make the screen go funny. E.g. a message may be 'broadcast' by the operators
in the Computing Centre, to be printed on every terminal. This will spoil
your edit window. You can always get the window 'repainted' by holding down
the button marked 'CONVERT FUNCTION' and,
while holding it down, also press the button marked 'CP' with the 'downarrow'
(at the top right of the keyboard). I.e. use the button which would normally
move the cursor to the bottom of the screen: the CONVERT button will make it
produce a different effect.

This screen 'refreshing' procedure should be tried whenever the edit process
appears to be producing strange results, for instance if instead of the
cursor moving when you press keys on the numeric keypad, the numbers appear
in the file. If that happens try the refresh procedure and your terminal will
be reset. You may also have to delete the spurious characters from the file
in the normal way. (Different terminals use different keys for refreshing.
For instance, with a VT100 terminal, press the 'GOLD' key twice.)

(15) Editing another file

While editing one file you may wish to look at another. E.g. while using VED
in TEACH mode, to read a teaching file, you may wish to start editing one of
your own files. You can tell VED to start a new file by pressing ENTER then
typing 'VED' then the name of the new file. No semi-colon is required, e.g.
        ENTER VED MYPROG.P

as usual end with the RETURN button. If your previous file was visible in the
lower half of the window, VED will now start a new file in the upper half, or
vice versa. You can then switch back and forth between the two files using
the sequence
        <ESC> X

I.e. press the button marked 'ESC' (top left) and then the 'X' (for
eXchange). You will see the cursor move from the window it is in to the other
window. Each window will show the last command you gave, whichever window it
was in, and also the file and line number corresponding to the window. When
you put the cursor in one of the windows, you can move up and down the file
in the normal way, and the other window will not be affected.

The <ESC> X sequence can also be used to get a file back onto the screen if
you have two files in the editor, and only one is visible. This would happen
if you temporarily left VED to give POP11 some commands, then used VED to get
back to the previous file. VED will then put that file on the screen. If you
want to see the second file also, then <ESC> X will bring it onto the screen.
This is often useful if you are using a TEACH file as well as one of your
own.

(16) Finding out what files you have.

You can get a reminder of the files you currently have in the EDITOR by
giving the command
        ENTER FILES

For each file you'll have its name printed out, and other information. You'll
need to press the RETURN key to get back to editing.

(17) Loading procedures without leaving VED.

If you are developing a program composed of several procedures in a file, you
may find it inconvenient to use ENTER X to load the procedures and go back to
POP11. Often your procedures will have syntactic errors, and you'll have to
correct them and then try again. Instead of doing this for the whole file
every time you can easily do it for one procedure at a time. Just put the
cursor in the procedure, then press ENTER and
        LCP

then RETURN. The 'Load Current Procedure' command will cause the procedure to
be read in by POP11 from the file, and compiled. If all goes will there will
be no complaints, and you can then carry on with the next procedure. If
however there is a mistake, you'll get a MISHAP message. This is actually
inserted into the file, and marked with a vertical line on the left. Because
it is marked, you can delete the whole message very easily (after reading it,
of course) by means of the ENTER#D command (which deletes the 'marked' range
from the file.)

Besides error messages, the LCP command may insert WARNING messages into your
file telling you where you have used variables without declaring them. Often
this is a reminder that you should declare the variable as local to the
procedure. Sometimes it should be declared outside the procedure, say at the
top of the file, for example if it is the name of a procedure which is to be
defined later in the file. If you leave the WARNING messages in the file,
they will do no harm since they start with three semi-colons ';;;', telling
POP11 to ignore the rest of the line. However, you can easily delete them
by putting the cursor on the relevant line and pressing the DELETE LINE
button (F2 on the Visual 200 terminal).

If you don't like to have the error messages and warning messages inserted
into your file, you can give the ENTER#ERRS command, which tells VED that
thereafter you want the LCP command to cause error and warning messages to be
printed at the bottom of the screen, and not in the file. If you give the
same command (ENTER#ERRS) again later, then the messages will thereafter go
into the file again. I.e. you switch it on or off with the ERRS command. It
tells you whether the messages are going in or not.

If you prefer to have the mishap messages in another file (called 'DOIT') you
can give the command
        CCP

I.e. 'Compile Current Procedure'. LCP and CCP are no different in how they
compile the procedure. They differ only in where they put error messages.


SUMMARY
-------

For writing programs in a file called, say test.p, you type
        : VED TEST.P;

(Always use ".p" as your file extension for program files. Otherwise ved will
not automatically compile them for you.) Then do your edits. Then ENTER the
VED command
        X

to Ved, and press RETURN. This will 'write' the file , eXit from ved and
compile (i.e. load) the file. Usually you will then want to type some test
commands to POP11, then continue editing the file. Typing
        VED;

to POP11 will enable you to continue. So X to VED returns you to POP and VED;
to POP return you to VED.

Alternatively, use the LCP command to get all your procedures loaded one at a
time. If you do that you should, after a lot of editing, use ENTER#W to write
the file, to make sure that there is a permanent copy on the disk.


CONCLUSION
----------

There are many features and commands available in Ved, e.g. commands for
editing several files at once, for moving or deleting or copying a marked
range, or writing it out into a separate file, or moving a range from one
file to another. There are also keys on the VISUAL 200 terminal which enable
you to remember your current position before you search for another location,
and to return to a previously saved position. There is a key to switch Ved
into "static" mode, which is useful for typing in tables or diagrams. There
is a command to change the name of the current file - useful for copying one
file to another, with changes. Further, because the programs for VED are
written in POP11 it is possible to extend VED to add your own desired
features (within limits).

However, most users can get by most of the time using the features described
above. The other features will be documented separately. After you have spent
some time playing with  VED, which will make all of this much clearer, you
should write a summary of the main points. Use VED to put your summary
in a file on disk. Include

        uses of VED.
        starting and finishing an edit
        consolidating the file on the disk
        compiling the file
        which keys do what?
        moving the cursor
        deleting text
        joining lines together
        searching
        the substitute command
        global substitutions
        the use of the "@" symbol (if you've understood that)
        going from POP11 to VED and vice versa
        ways of minimising typing
        'Justifying' text or indenting procedures
        Loading individual procedures


EXERCISES
---------

You can practice using VED by typing in a poem. Make some deliberate
mistakes, then correct them after writing the file to the disk.

Then practice writing little programs, in a file called test.p. Insert the
following procedure definition.
        define test (number) -> result;
                if      number > 500
                then    [very big] -> result
                elseif  number > 100
                then    [big] -> result
                else    [small] -> result
                endif
        enddefine;

When you've inserted this procedure (whose name is "test)" into the file
(which doesn't really have to have the same name), leave VED with the X
command, and type the following to POP11, ending each line with RETURN.
        test(3) =>
        test(333) =>
        test(666) =>

Then go back to ved and insert an error. E.g. change "elseif" to
"otherwise". Then leave VED again with X. POP11 will try to compile the file,
but compilation will  be interrupted by a "mishap" message. Go back to VED
and you'll find the cursor near the source of the trouble (actually on the
last line compiled). Then correct the definition. Then use X to write and
compile it, then run the procedure test again with a different set of numbers.
If you don't understand what is happening ask other students or your tutor.
When you are happy with ENTER X, try the CCP command with the cursor in the
procedure. When you are happy with that, type the following to VED
        TEACH CMR

This will show you how to use the more general 'compile marked range'
facility.

There are two files which summarise all the VED facilities. One can be read
with
        ENTER HELP VEDCOMMS

This summarises all the ENTER commands in VED.

The other file is
        ENTER HELP VEDWORDS

which gives more information useful to experts who want to use the basic VED
facilities to define their own extensions to the editor.
