Editing with ED (becouse sometimes you need it! :) )

1. The ED editor
The ED editor is a general means of allowing the technical user to create and/or changeand/or delete any record on any file. It will normally be used for:
Creating and maintaining Basic source code. Creating and maintaining Procs, sentences and paragraphs. Creating and maintaining dictionary records. Creating test data records, and Emergency modification of live data records.
It is obviously a very powerful tool, and one which should be treated with the greatest respect. It should never be made available to the general user.

1.1 Using the Editor

The ED – not EDIT – line-editor is invoked by commands of the form:

ED file.name record.list
ED file.name *
ED file.name
ED

The action of the editing is then controlled by a series of one-line commands which move – line by line – through the record, inserting / changing / deleting text as you proceed.

Unlike the generic Pick line-editor, the ED editor does not require you to issue a command – such as the F command – to implement any changes which you make to the record. Whenever you look at the contents of the record, what you see is what there is.

1.2 ED commands

The following commands are amongst those which are available:
n
(where n is a number), move to line number n. POn is equivalent

+n
advance the pointer by n lines
-n
move the pointer back n lines

A
A
repeat the last A command
A xxxxx
append text xxxxx to a line

B
B
move to the bottom (end) of the record
B xxxxx
break the current line at the string xxxxx
BLOCK
enable/disable block operation verification

C
C
repeat the last C command
C/aaa/bbb/
change the first occurrence of aaa to bbb in the current line
C/aaa/bbb/n change the first occurrence of aaa to bbb in the next n lines
C/aaa/bbb/G
change all occurrences of aaa to bbb in the current line
C/aaa/bbb/Gn
C/aaa/bbb/nG
change all occurrences of aaa to bbb in the next n lines.

If you add B to the end of these commands, they will process all the lines in the current marked block:

C/aaa/bbb/B
C/aaa/bbb/GB

CAT {xxxxx}
join this line, the optional string xxxxx, and the following line into one
COL
display the column position mask
COPY
copy all the lines in the current block to the current position

D
DE
delete the current line
Dn
DEn
delete n lines starting at the current line
DE
is equivalent to D
FD
DELETE
delete the record from the file
DROP
delete all lines in the current block
DUP
duplicate the current line
DUPn
duplicate the current line n times

E
EX
leave the Editor. QUIT is equivalent

F
F
repeat the last F command
F xxxxx
find the next line which starts with the string xxxxx
Fn xxxxx
find the next line which contains the string xxxxx starting in column n
FANCY.FORMAT
indents the lines as a Basic program. Similar to FORMAT
FD
DELETE
delete the record
FI
FILE
file the record
FILE rrrrr
file the record with name rrrrr on this file and leave the Editor
FILE fffff rrrrr
file the record with name rrrrr on file fffff and leave the Editor
FORMAT
indent the lines as a Basic program. Similar to FANCY.FORMAT

G
Gn
go to line number n
G<
go to the start of the current block
G>
go to the end of the current block

H
HELP
display help information about the stack processor and the Editor
HELP xxxxx
display help information about command xxxxx

I
I
insert new lines after the current line
IB
insert new lines before the current line
I xxxxx
insert the line xxxxx after the current line
IB xxxxx
insert the line xxxxx before the current line

L
L
repeat the last L command
L xxxxx
locate the next line which contains the string xxxxx
Ln
list the next n lines
LOAD
insert / load the text of another record into the present text
LOAD rrrrr
load record rrrrr into the current record
LOAD fffff rrrrr
load record rrrrr from file fffff into the current record

M
M
repeat the last M command
M ppppp
search for a line which matches the pattern ppppp
MOVE
move (that is, copy and the delete) all the lines in the current block to the current position

N N
skip this record and pass to the next; this is used when editing a number of records, one after another

O
OOPS
undo the last change

P
P
repeat the last Pn command
Pn
print the next n lines, starting with the current line
PB
print all the lines in the current block
PERFORM
execute a TCL command from within the Editor
PLn
print the next n lines but do not move the line pointer
PL-n
print the previous n lines but do not move the line pointer
POn
go to line number n. Just n is equivalent
PPn
print a window n lines wide around the current line

EX
Q
QUIT
leave the Editor

R
R
is an alternative to C to change the text
R xxxxx
replace the current line with xxxxx
RELEASE
release the update lock on the file

S
SAVE
save the record and remain within the Editor
SAVE rrrrr
save the record with the name rrrrr on this file and remain within the Editor
SAVE fffff rrrrr
save the record with the name rrrrr on file fffff and remain within the Editor
SEQ/aaa/bbb/ccc/ddd
replace aaa in the next ccc lines by sequential numbers starting at bbb and incrementing in steps of ddd (default is 1)
SEQ/aaa/bbb/B/ddd
replace aaa in the lines of the current block by sequential numbers starting at bbb and incrementing in steps of ddd (default is 1)
SIZE
display the size of the record
SPOOL
print the record
SPOOLn
print n lines
SPOOLHELP
print the help messages
STAMP
insert a marker into the record. This is in the form:
* account login date time

T
T
go to the top of the record

U
UNLOAD rrrrr
save a section of the record with name rrrrr on this file. You will be asked to specify the lines to be saved
UNLOAD fffff rrrrr
save a section of the record with name rrrrr on file fffff

X
X
leave the Editor and abandon any further records being edited
XEQ
execute a TCL command and then return to the Editor

1.3

Block-handling
A valuable feature is a block-handling facility which allows you to define a block of lines within a record, and such a block can then be manipulated using the:
COPY
C
DROP
MOVE
PB
and other commands, as mentioned above. The start of the block is declared by the command:
<
and the end of the block by the command:
>

1.4
Prestored commands
Sequences of prestore commands may be created as separate records and held on the:
&ED&
file, and then recalled for your more-frequently required editing tasks. We call illustrate this by looking at a sequence which will:
Go to line 20 of the record
Replace the word STREET by ROAD, and then
File the amended record, and then repeat this for all the records on the data file
We first create a record called, say, ST-ROAD on the &ED& file which would look like this:
E
G20
C/STREET/ROAD/
FI
LOOP 2 99999
The first line identifies this as an Editor sequence, then follow the Editor commands, exactly as they would be typed in, and finally we have the special LOOP command which instructs the Editor to repeat the sequence from line 2 for 99999 repetitions – once for each record which we edit.
To use this prestored sequence to update the true data file, we should invoke the Editor in the normal manner to process the file and then invoke the sequence by means of the command:
.X ST-ROAD
There are several commands prefixed by a full-stop which are provided to handle prestored commands, and other commands, such as LOOP and PAUSE which are provided to control a prestored sequence, as we saw above.