ICL 1900 Series George 3 Operating System

George 3 Editor

Any basic peripheral file may be amended by use of the George editor. Editing a GRAPHIC mode file is straight forward but problems may arise if an attempt is made to edit a file in NORMAL or ALLCHAR modes.

The editing process copies the file to be edited (the old file) into a new file making changes as directed by editing instructions. The editing instructions are normally read from the job source (i.e. job description file or on-line console), but may be contained in an editfile.

The general form of the command is:
    EDIT oldfile,newfile,editfile

Thus,
    ED MYFILE(1)
would produce a new file MYFILE(2) from MYFILE(1) using editing instructions from the job source.

Similarly,
    EDIT MYFILE,YOURFILE
would produce a new file YOURFILE from MYFILE using editing instructions from the job source.

The Pointer

A serial file is regarded as a series of records, which, for all practical purposes, correspond to a unit on some physical medium, i.e. a card, a block of paper tape, or a line of print. Each record consists of a series of characters. Editing is done in terms of a conceptual pointer which indexes a particular character within a particular record of the old file. The pointer is initially at the first character of the file, that is, character 0 of record 0.

Editing instructions are used to move the conceptual pointer from the beginning to the end of the old file creating the new file by transcribing text from the old file and by deleting, inserting and replacing characters and records as specified by the editing instructions.

Off-line and on-line editing

Any editing operation may be performed either off-line or from an on-line console. Editing is ideally suited to on-line access since progress is visible and errors can be corrected immediately, e.g. by F(forget) command. Some editor facilities can only really useful on-line, e.g. W(window).

Off-line editing

The editor is entered using the EDIT command from within the job description. The editing instructions follow immediately on the next lines or cards of the job description (or may be contained in an editfile). Each instruction is terminated by a comma or newline.

On-line editing

The editor is entered by typing the EDIT command from an on-line console after logging-in. The system replies

    EDITOR IS READY
    0.0_

0.0 is the initial position of the pointer (record 0 character 0). A line of editing instructions may now be typed followed by pressing the Accept key. When the editor is ready to accept more editing instructions the system outputs

    m.n_

where m.n is the new position of the pointer (record m character n).

Editing instructions

Instructions to the editor are all one character mnemonics usually followed by associated parameters. Each record of input to the editor may contain several editing instructions separated by commas. All editing instructions except the I instruction must be complete in one record.

Records input to the editor are listed to the monitoring file in the COMMANDS category.

Several editing instructions require as a parameter a character string and several an endpoint. It is convenient to describe these before the various editing instructions.

Character string

A character string consists of any number of characters enclosed within a pair of identical string delimiters. These are taken from the character set:

    : ; < = > ? ! " $ % & + /

The chosen string delimiter may not occur within the character string which is why a choice of delimiters is available. Thus to specify

    x:= x+2

as a character string

    /x:= x+2/

would be suitable where / is the string delimiter. But to specify

    x:= x/2

it would not be correct to use

    /x:= x/2/

since the delimiter / now occurs within the text. However

    ?x:= x/2?

would be suitable.

Note that

    /GOTO/

and

    /GO TO/

are different character strings, i.e. spaces are significant.

Endpoint

Many editing instructions specify that a particular operation is to be carried out up to a certain place in the old file. This place is known as the endpoint and can be specified in several ways. The general format of an endpoint specification is

    <record>.<character>

<record> specifies the record of the oldfile which is to be the endpoint. It may be omitted in which case the current record is assumed but the . must be present.

.<character> specifies the character position of the endpoint within the record. It may be omitted in which case the start of the specified record is assumed.

In what follows n signifies an integer and string signifies a character string as previously defined. The following forms may be used and have the effect stated.

Specifying a record

#n record number n of the oldfile, the first record being record 0.
n n records from the beginning of the current record.
string The next record beginning with the specified string of characters. Note that spaces are significant.
S string The next record which Starts with the string specified, ignoring leading spaces.
C string The next record which Contains the specified character string.
E The End of the file, i.e. the record which is an imaginary record after the last actual record.

Specifying a character position

.#n Character number n in the current record, the first character being 0.
.n If used with a record specification then n characters from the start of the record. If the record specification is omitted or is zero then n characters from the current position.
.string The first character of the next occurrence of the string within the current record.
.E The End of the record.
.S The next non-space character.

Transcription and deletion of records and characters

T<endpoint> transcribes (or copies) characters from the old file to the new file starting at the current position and continuing to the endpoint specified.

P<endpoint> positions the pointer at the endpoint specified. No text is copied over from the old to the new file so that this in effect deletes text. Note that with this instruction only the pointer may be moved backwards by specifying the endpoint in the form -n or #n only. This facility enables the contents of a file to be re-ordered.

E transcribes the rest of the old file to the new file and terminates the edit.

Consider the file

    THE QUICK BBROWN FOX
    JUMPED OVER THE LAZY
    LAZY DOG

The pointer is initially at 0.0

T.10 would copy THE QUICK to the new file leaving the pointer before the first B of BBROWN,
P.1 would move the pointer past the first B of BBROWN (effectively omitting this B),
T1./LAZY/ would copy the rest of the first record (record 0) and all of the 2nd record up to LAZY,
P.E would move the pointer to the end of the 2nd record, effectively erasing LAZY, and
E would copy the rest of the oldfile and terminate the edit.

Thus, the sequence

    T.10,P.1,T1./LAZY/,P.E,E

would produce the file

    THE QUICK BROWN FOX
    JUMPED OVER THE
    LAZY DOG

Note the separation of editing instructions by commas.

There are clearly a large number of ways of achieving the same effect, e.g.

    T./BB/,P.1,T1.16,P.4,E

is equivalent to the sequence above.

Note that if a transcribe (T) instruction moves the pointer past the end of a record then that record is extended as necessary in the new file by the addition of spaces.

If a position (P) instruction moves from the start of a record to the start of another record then intervening records are deleted. If a P instruction starts from within a record then the front of the starting record is joined to the endpoint record. For example, if the sequence

    T1.25,P1,E

were applied to the file considered earlier the result would be

    THE QUICK BBROWN FOX
    JUMPED OVER THE LAZY     LAZY DOG

Inserting text

The Insert instruction

The I instruction is used to insert information into the new file.

The string must be delimited by a pair of identical delimiters from the set previously given and has the format I. Unlike any other instruction, the string may occupy more than one record.

If a multi-record insert is being made on-line, the user types an Accept where he requires a new record in the string. The system will then remind him that the second delimiter has not been given by replying with the delimiter and the invitation to type, e.g.

    /_ instead of _

where / is the string delimiter being used.

Consider the file

    ABCDEF
    GHI

The pointer is initially at 0.0

T./D/ would transcribe to before the D,
I?  
? would insert a new-line,
T/G/ would transcribe to the record beginning with a G,
I?XYZ  
? would insert a record of XYZ,
TE would copy the rest of the old file,
I?**** would insert a new record of **** at the end of
? the new file,
E would finish the edit.

The result would be

    ABC
    DEF
    XYZ
    GHI
    ****

If the second Insert had been I/XYZ/ the result would instead have been

    ABC
    DEF
    XYZGHI
    ****

because a new record was not started. Note that when inserting a number of short records it can be inconvenient to input several lines (particularly on-line, where following an Accept the user must await a response). A double delimiter will be taken as a newline, for example

    I?ABC??DEF???

is equivalent to

    I?ABC
    DEF
    ?

The Replace Instruction

The Replace (R) instruction has the format:

    R/oldtext/newtext/

and causes the next occurrence of oldtext in the current record to be replaced by newtext, where / may be any of the allowed string delimiters.

For example, if the current record is

    JAN FEB MARCH APR

and the pointer is at the beginning of the sequence, then

    R/CH//

would change the record to:

    JAN FEB MAR APR

Note that to retain the position of APR, the instruction would be R/CH/  /.

R/CH// is equivalent to T./CH/,P.2 and

R/CH/  / is equivalent to T./CH/,P.2,I/  /.

The After and Before instructions

The A and B instructions have the format:

    A/oldtext/newtext/ and
    B/oldtext/newtext/

where / may be any of the allowed string delimiters.

They cause the current record to be transcribed to after or before the first occurrence of the oldtext specified, and then the newtext to be inserted. Thus, if the pointer is at the first character of

    SUNDAYTUESDAY

then either

    B/T/MONDAY/ or A/Y/MONDAY/

would convert the record to

    SUNDAYMONDAYTUESDAY

Note that

    A/oldstring/newstring/

is equivalent to

    T./oldstring/,T.n,I/newstring/

where n is the number of characters in oldstring.

Also,

    B/oldstring/newstring/

is equivalent to

    T./oldstring/,I/newstring/.

Repetition

A sequence of editing instructions may be repeated by placing the sequence in brackets, and following it either with *n or <endpoint>. *n means that the sequence should be repeated n times. <endpoint> means that repetition should be performed until the pointer reaches <endpoint>.

For example, to change all statements of the form

    FORMAT(xxx,xxx)

in a Fortran program to

    FORMAT(1H ,xxx,xxx)

the required instructions would be

    (TC/FORMAT/,R/(/(1H ,/)E,E

This says "transcribe to any line containing FORMAT, replace the first occurrence of a left hand bracket with (1H , then repeat this sequence until the end of the file, then terminate the edit".

Note that the use of the TC string facility in this way is somewhat expensive in processor utilisation.

Merging files

The George editor allows a number of files to be edited and merged into a single new file during one edit by using the Merge (M) instruction which has the format:

    M<filename>

This causes the current old file to be closed and the position of the pointer in that file to be remembered. The file specified in the M instruction is then opened with the pointer at 0.0, and may then be edited. A file that is closed as a result of the M instruction is placed at the top of a push-down stack. Subsequent M instructions place files on the top of the stack, and cause the pointer position to be remembered. Up to ten old files may be in use at any one time.

The X instruction, which has the format:

    X

causes the current old-file to be closed, and for the top file in the stack to be reopened as the current old file, with the pointer in the same position as when it was put on the stack.

Suppose the file ALPHA contains

    FIRST
    THIRD

and the file BETA contains

    SECOND

If the pointer is at 0.0 of ALPHA, then

    T1,MBETA,TE,X,TE

would create a new file of

    FIRST
    SECOND
    THIRD

Note that a file may be merged with itself. This can be especially useful for re-ordering a file. Thus, if FRED contains

    ABC
    GHI
    DEF

The instructions

    EDIT FRED
    T1,P1,TE,M FRED(-1),P1,T1,X,E

would create a new file

    ABC
    DEF
    GHI

Note the use of FRED(-1) in this M instruction. This is necessary since the EDIT command creates a new file called FRED and the old file is therefore now FRED(-1). Notice also that the same effect could be achieved by

    EDIT FRED
    T1,P1,T1,P-2,T1,PE,E

where P-2 specifies a backwards positioning of the pointer.

Terminating or abandoning the edit

Normally an edit is terminated by the E instruction which has already been described. The rest of the oldfile is automatically copied to the new file before control is returned to the George command source.

When using the editor on-line it is possible to abandon an edit by means of the Q (Quit) instruction. The edit is terminated immediately and the new file is left as it was before the edit.

Special features for editing on-line

Any fault in the editing instructions produces a suitable error message. If editing off-line the message is simply sent to the monitoring file of the job and the edit continues. If editing on-line the message is sent to the terminal and control is returned to the console. The user can then decide what to do according to the circumstances. A number of features of the editor are designed specifically to simplify on-line editing.

The Window facility

The user can switch on a "window" facility. If the switch is on and the pointer is moved to a new record by a T or P instruction then that record is listed on the console. The window facility is controlled by the following instructions:

    W ON switches the window on,
    W OFF switches the window off,
    W reverses the state of the switch.

The Listing facility

This is controlled by the instructions L ON, L OFF and L in the same way as the window facility. If listing is switched on then all lines transcribed to the new file are listed on the console. This facility should be used with caution.

Having made some alterations to a line a useful sequence to see whether the line is now correct is

    L,1,L
This is on the assumption that listing is initially switched off.

The F (Forget) instruction

The F instruction has the effect of resetting the pointer to the position it was at before the last editing record was obeyed. Any records copied to the new file as a result of instructions in the last editing record are removed. E.g.

    P26

    F,T1

is equivalent to T1.

This instruction is a useful dodge when a mistake has been made, but note that two or more consecutive F instructions are not allowed.

Break-in during an edit

If the Control A key is pressed while the editor is obeying an instruction then the following message is output:

    INSTRUCTION TERMINATED

and new editing instructions may then be typed in as desired.

Editor messages

The most common editor messages are:

CHARACTER NOT FOUND T, A, B or R instruction specifies a non-existent position in the current record.
INSTRUCTION TERMINATED Broken-in while the instruction was being executed.
SYNTAX ERROR: incorrect instruction Invalid instruction.
YOU'VE RUN OFF THE END OF THE FILE Trying to move pointer past the end of the file.

Other facilities

A number of other facilities are available within the editor. For a full description of these Chapter 6 of the George reference manual should be consulted.