.REPORT ECCE Mark 1 under AOF .NUMBER DDTR370 .ISSUE 2.0 .AUTHOR Ian Macmillan .CHAPTER INTRODUCTION .HEREIS INTRO ECCE (the Edinburgh Compatible Context Editor) is a text editor suitable for processing files containing lines of text. Originally developed at Edinburgh University its philosophy is to provide a small set of general purpose commands together with a command structuring facility from which more powerful commands may be constructed. This is in contrast to the many editors which provide a command for every conceivable purpose often confusing the would be user who at the very least makes use of only a subset of the available functions. In general, commands consist of a single letter (upper and lower case are equivalent) most of which may optionally be followed by a repetition number causing the command to be repeated the specified number of times. ECCE may be regarded as a character editor in that all commands effect text at, or alter the position of, a conceptual file pointer. In reality the file pointer is just the current character position within the source file. Typically the file pointer will proceed sequentially through the file in response to various commands although it is possible to 'step back' up the file. A feature of ECCE is that all lines input are checked for correctness before execution is attempted minimising accidental typing errors. It follows that a command line will never be only partially executed as a result of a syntax error somewhere within the input. This is in contrast to the failure of a command during execution which is covered in section >FAILURE<. This manual is structured in order of increasing complexity of function, the simplest concepts being introduced first to allow the novice user to progressively gain in proficiency. The naming conventions used throughout are those used to describe the syntax of the command language in section >SYNTAX<. .CHAPTER NOTATION .HEREIS NOTATION The notation used in the following examples is: .LIST .BLOB A line preceded by an equals sign '=' is a line of output from ECCE. .BLOB Lines starting with the prompt character '>' indicate a user response (i.e input of commands). .BLOB The up-arrow symbol '^' is used to denote the position of the file pointer which is defined to point to the text immediately to its right. .BLOB Double slash '//' introduces a comment. .ENDLIST .CHAPTER INVOCATION OF ECCE .HEREIS INVOCATION ECCE may be invoked under AOF by typing: <>ECCE . in response to the system prompt '<>'. ECCE will respond by printing its initial message together with the issue number and date. .NJ =ECCE Issue 4A on 07 Oct 83 > .JU All requests for input are preceded by ECCE's standard prompt character '>'. .CHAPTER COMMANDS AND THEIR EFFECTS .HEREIS EFFECTS Commands consist of a single letter and may be entered, several to a line, in upper or lower case (they are equivalent). Such a list is known as a command sequence. Spaces are not significant and may be used to improve clarity. Command sequences may be grouped into executable units by separating them with a semicolon ';'. Upon input of a 'newline' (carriage return on most terminals), ECCE will check the first command sequence for correctness. Only if the entire command sequence is correct will execution be attempted. Any error detected will result in the production of an appropriate message indicating the cause of the error. After executing or discarding the command sequence the above action is repeated for any remaining command sequences. Typically a line of input will consist of only one such sequence terminated by a 'newline'. After executing the commands (from left to right), ECCE will usually display the current line of the file (the exact action is dependant on the setting of the monitor control described in section >SPECIAL<). By default the line is displayed only if a command causes a move to a different line within the file. Commands consist of two main types, those which effect text within the file being edited and those which alter the editing environment. The latter are called 'Special commands' and are described in section >SPECIAL<. The former type may be further subdivided in terms of both their action and the way in which they are specified. These divisions and the commands within them are described below. .SECTION The file pointer ECCE operates on a source file of characters and produces a new output file to which the editing changes have been applied. During editing ECCE maintains a file pointer which defines the current character position within the file. It is represented by highlighting the character to which it points using inverse video. A line displayed without highlights is defined to be one in which the file pointer is positioned at the start. .SECTION Simple Commands A simple command is one which operates on or at the position of the file pointer. These commands take the form of a single letter some of which may be followed by an optional minus sign '-' which reverses the direction of operation. Normally commands either alter text immediately to the right of the file pointer or cause the latter to move through the file from top to bottom. Simple commands may be optionally followed by a repetition modifier (see section >REPETITION<) specifying how many times the command is to be executed. .SUBSECT Character Position Commands .NE 16 So called because they operate at character level within the current line, consequently they may not be used to move the file pointer beyond the start or end of the line. Left~~(L) This command causes the file pointer to be placed immediately in front of the preceding character (spaces and layout symbols count as one character). =Line of sou^rce >L10~~~~~~~~~~~~~~~~~~~~~~~~~~// move left by 10 characters. =L^ine of source .ne 10 Right (R) Complementary to the left command this causes the file pointer to be advanced by one character. Note: the furthest position to which the file pointer may be moved is immediately beyond the last character in the line. =L^ine of source >R~~~~~~~~~~~~~~~~~~~~~~~~~~~~// move right by one character =Li^ne of source .NE 19 Case~~(C) Case provides the facility to reverse the case (shift) of alphabetic characters. If the character to the right of the file pointer is alphabetic then its case is reversed i.e upper case becomes lower and vice versa. The file pointer is then advanced by one character irrespective of whether the case change was performed or not. Case may also be followed by a minus sign causing it to operate on the character to the left of the file pointer which is then repositioned immediately in front of the altered character. =Line o^f source >C3~~~~~~~~~~~~~~~~~~~~~~~~~~~// change the case of the next // three characters. =Line oF S^ource~~~~~~~~~~~~~~// (the space is unaltered.) >C-4~~~~~~~~~~~~~~~~~~~~~~~~~~// change case of previous // four characters. =Line ^Of source .ne 12 Erase (E) Erase deletes the character to the right of the file pointer unless followed by a minus sign in which case it operates on the preceding character. =Line o^f source >E-~~~~~~~~~~~~~~~~~~~~~~~~~~~// Erase preceding char =Line ^f source >e3~~~~~~~~~~~~~~~~~~~~~~~~~~~// Erase the next // three characters =Line ^ource .NE 17 .SUBSECT Line Commands These affect whole lines within the file rather than operating at the character level. Move~~(M) Move causes the file pointer to be placed at the start of the next line in the file. Appending a minus sign has the effect of moving the file pointer to the start of the previous line in the file. .nj =Line 1 of file // first line of the file >M2 // move on by two lines =Line 3 of file // third line in file >m- // move back on line =Line 2 of file .JU .ne 9 Kill~~(K) In order to delete a line from the file, the kill command is used. It deletes the current line and positions the file pointer at the start of the next line in the file. .NJ =Line 2 of file >K // delete this line =Line 3 of file // now at next line in file .JU .ne 23 Break and Join~~(B and J) These commands are described together since their effect is complementary. Break splits a line in two by inserting a 'newline' immediately before the file pointer, the second part of which becomes the new current line. Join appends the next line in the file to the end of the current line by deleting a 'newline' and places the file pointer at the position of the join. .NJ =Line 1 ^of file >B // break in two =of file // line 1 is now 'Line 1 ' >J // join to next line =of file^Line 2 of file // note file pointer at join .JU A useful effect of break is to insert a blank line when used with the file pointer at the start or end of the current line. e.g A break command executed when the file pointer is at the start of the line inserts a blank line before the current line which remains unaltered. Conversely if the file pointer were at the end of the line then a blank line would be inserted after the current line and also becomes the new current line. .NE 25 Print~~(P) Print instructs ECCE to print the current line on the display stream. When used with a repetition number its effect is to display several lines of the file. This is not true repetition as a move is executed after each line is printed but in practice is rather more useful. A consequence of this is that the last line printed becomes the new current line. Lines longer than the available screen width are displayed according to the following criteria. If the file pointer lies within the first part (equivalent to a screen width) of the line then the display is truncated at the right-most side of the screen. A 'blob' (delete symbol) is output at the far right to indicate that this has occurred. A similar technique is applied when the file pointer is within the last part of the line, the truncation occurring to the left. Other file pointer positions cause truncation at both sides (a 'blob' appearing at both ends), the line being centered about the file pointer. .NJ .IN+5 =Line 1 of file >P3 // print three lines =Line 1 of file // first is current line =Line 2 of file =Line 3 of file .JU .IN-5 .ne 26 Get~~(G) Get is provided to interactively insert a line of text, input from the command stream, before the current line. This command is unusual as it does not affect the file pointer. When used without a repetition number its effect is to request a single line of input from the command input stream which is then inserted before the current line. During 'get-mode' ECCE prompts with a colon ':' rather than the default '>' as a reminder. A multiple get (G followed by a repetition modifier) may be prematurely terminated by typing a line consisting of only a colon. This is particularly useful for inserting large volumes of text when 'G*' is normally used. Note: Get causes a request for input when it is actually executed rather than taking the rest of the command line as input, this is a common source of confusion to the novice user. As an example 'G R C' does not insert 'R C' but requests futher input after which the commands 'R' and 'C' are executed. .NJ =Line 1 of file >G0 // G is often used with a :Input line 1 // repetition count of zero :Input line 2 // which means accept as :Input line 3 // many lines as possible. :: // Colon terminates 'get-mode' =Line 1 of file // current line unchanged. .JU .BP .SECTION Text Commands All the commands described in this section require a text string to be specified which consists of a sequence of characters enclosed in delimiters. A delimiter may be any character having no special meaning to ECCE (often punctuation is used) and not itself appearing within the text string. i.e /string/ is a valid text string but /str/ing/ is not. Slash '/' is used for the purpose of the following examples. .NE 14 .SUBSECT Found status Before describing the text commands it is necessary to define the concept of found status. Found status is said to apply when a particular occurrence of text is uniquely defined by length and position. In practice this means when the file pointer points to a piece of text located by one of the commands 'F', 'V' or 'U'. It is cleared by any command which changes the text to the right of the file pointer or causes the latter to move. e.g 'L' clears found status but 'E-' does not. When found status applies all the 'found text' at the file pointer is shown highlighted rather than the usual single character. This serves as a reminder both that found status is set and to which text it applies. .NE 20 .SUBSECT Text location commands Find~~(F) Find is used to locate a particular occurrence of text within the file. The search commences from the position of the file pointer which is subsequently repositioned in front of the located text. Any occurrence of the text already found (found status set) is ignored so that a subsequent use of find with the same text string will locate the next instance of the string. By default the search proceeds from left to right and towards the end of the file. Following 'F' with a minus sign however reverses the action and provides the mechanism to search backwards. .NJ .IN+5 =Line 1 of file >F/file/ // position file pointer in // front of 'file' =Line 1 of ^file // file pointer repositioned. .JU .IN-5 .ne 9 Traverse~~(T) Similar to find but operating only on the current line , traverse searches for the specified text and positions the file pointer immediately after the last character of the matched string. .NJ .IN+5 =Line 1 of file >T/file/ // traverse the string 'file' =Line 1 of file^ .JU .IN-5 .NE 20 Delete~~(D) This command deletes the first occurrence of the specified text located within the rest of the current line. An occurrence of text already found is not ignored by delete. e.g f/text/ followed by d/text/ would delete the text just found. The file pointer is repositioned in front of the first character immediately following the deleted text. .NJ .IN+5 =Line 1 of file >d/of/ // delete the word 'of' =line 1 ^ file // file pointer at position // of deleted text. .JU .IN-5 Appending a repetition count to delete causes the specified number of deletions (it does not mean delete the n'th occurrence as might be expected). .NJ .IN+5 =Line 1 of file >D/i/2 // delete 2 occurrences of 'i' =Lne 1 of f^le // file pointer positioned at // second occurrence. .JU .IN-5 .ne 12 Uncover~~(U) This curiously named command causes the deletion of all text between the current position of the file pointer and the first occurrence of the specified text located within the rest of the current line. This command may be thought of as 'delete up to specified text'. An occurrence of the text already found is ignored. .NJ .IN+5 =Line 1 of file >U/of/ // delete up to 'of' =of file .JU .IN-5 .NE 19 .SUBSECT Specifying an explicit searchspace In the previous sections text commands were described as operating on either the rest of the current line or the remainder of the file. This is only the default action, a specific searchspace may be specified. A searchspace defines the maximum number of lines (including the current line) that may be scanned for a particular occurrence of text. It takes the form of a number typed immediately after the command letter. As an example specifying a searchspace of one restricts the scan to the rest of the current line so 'f1/dog/' would only locate an occurrence of 'dog' found on the same line. Note: The effect of say d50/dog/ is as follows. If the command succeeds the first occurrence of 'dog' within the next 50 lines is deleted. If it fails the result is m49, not m50. A further point to watch is that d2/dog/4 may scan up to a total of 8 lines since the searchspace is applied for each repetition. .NE 18 .SUBSECT Text insertion command Insert~~(I) Insert causes the specified text to be placed immediately before the file pointer whose position remains unaltered. It should be noted that it is only possible to increase the size of a line up to an implementation dependant maximum. Attempts to increase the size beyond this value will cause the command to fail and no text to be inserted. .NJ .IN+5 =Line 1 of ^file >I/source / // insert 'source ' before =Line 1 of source ^file // file pointer .JU .IN-5 Note: When used as the last command on a command line it is permissible to omit the closing delimiter. .ne 23 .SUBSECT Text replacement command Substitute~~(S) This is used to replace a particular piece of text with another. Substitute is only valid following a text location command (one of F,U,V) and replaces the text just found with the specified text. The file pointer is repositioned immediately after the replacement text. .NJ .IN+5 =Line 1 of file >F/file/ // find the text 'file' =Line 1 of ^file >S/input/ // replace 'file' with 'input' =Line 1 of input^ // note that the file pointer // is placed after the // replacement text. .JU .IN-5 Substitute is the only command which may be used with a null text string (delimiter followed by closing delimiter or newline) meaning replace the found text with nothing i.e. delete it. .NE 9 .SUBSECT Text verification command Verify~~(V) This command is only of use with the command structuring facilities described in a section >STRUCTURING< and effectively succeeds if the file pointer points to the specified text or fails if the text does not match. .CHAPTER COMMAND FAILURE AND TREATMENT OF END-OF-FILE .HEREIS FAILURE Obviously commands do not always succeed, they may fail immediately or during a repetition sequence. When a command fails it is abandoned and typically an error message is output to the display stream. In later sections it will be seen how this feature may be used to modify the effect of complex command lines. Some typical failure conditions are listed below: .NJ .IN+5 R when file pointer already at end-of-line. L when file pointer already at start-of-line. M when file pointer already at end-of-file. M- when file pointer already at start-of-file. S when found status not set. .JU .IN-5 If a command fails during a repeated execution it may be partially completed. As an example: .NJ .IN+5 =Line 1 of input >R50 // attempt to move right 50 =Failure: R50 // error message =Line 1 of input^ // but note file pointer now // at end-of-line. .JU .IN-5 Many failure conditions are associated with reaching the end of the file which is handled in the following way. When the file pointer is advanced beyond the last line in the file ECCE outputs the message: .CE **~End~** which is considered to be an imaginary line on which no operations are permitted. In general the only commands that may be used are those which cause the file pointer to be moved back up the file. e.g M-.~~In addition G and B may be used providing the means to append lines of text to the end of the file. .CHAPTER REPETITION OF COMMANDS .HEREIS REPETITION Most commands may be followed by a repetition modifier which in its simplest form is just a number typed immediately after the command. The latter case is known as simple repetition and causes the command to be executed the specified number of times or until failure. .SECTION Indefinite repetition Indefinite repetition, denoted by '*' (zero '0' is synonomous), causes a command to be executed as many times as posible until a failure condition is encountered. On failure the command is terminated but the error condition is suppressed and no error message is produced. Indefinite repetition is an alternative to a standard repetition number and is valid in the same context. .NJ .IN+5 =Line 2 of input >R0 // move right until failure =Line 2 of input^ // i.e until end of line. >m-* // move back until failure. =Line 1 of input // now at start of file. >F/of/E0 // find 'of' and delete to EOL =Line 1 ^ .JU .IN-5 .SECTION Repetition of previous command line A command line consisting only of a number instructs ECCE to execute the last command line typed the specified number of times. This will only succeed if the last line input was syntactically correct. .NJ .IN+5 =Line 1 of input file >f/i/ =L^ine 1 of input file >2 // repeat last command twice =Line 1 of input f^ile .JU .IN-5 .CHAPTER COMMAND STRUCTURING FACILITIES .HEREIS STRUCTURING It is this facility which provides the user with the ability to construct powerful command lines. Since all commands are self delimiting any number may be typed on a single line, this is called a command sequence. Several command sequences may be entered on a line separated by semicolons ';'. Each command sequence in turn is verified for correctness and executed upon reciept of a 'newline' or semicolon ';'. Any command sequence containing syntax errors will not be executed at all. .NJ .IN+5 =Line 1 of input file >f/input/s/current/r0 // command sequence =Line 1 of current file^ >L0f/// // faulty delimiters =Text for F? // error message indicating // faulty text for find. =Line 1 of current file^ // note that the L0 has not // been executed. >f///s/fred/; L0 P // two command sequences =Text for F? // first sequence discarded. =Line 1 of current file // but 'L0 P' executed. .JU .IN-5 .SECTION Repeated commands A command sequence enclosed in brackets '()' is called a compound command and is treated as a single command for the purpose of failure and repetition. Failure of any individual command will terminate the whole compound command but not necessarily the whole command line. e.g. If a compound command is followed by say, an ignore failure condition, then execution will resume at the first command following the ')'. .NJ .IN+5 >(f/fred/s/joe/)* // changes all occurrences of // 'fred' to 'joe'. .JU .IN-5 .SECTION Optional execution Normally the failure of a command will cause the execution of the sequence containing it to be abandoned. It is possible however to instruct ECCE to ignore the failure of a particular command or compound command by using a question mark '?' as the repetition modifier. .NJ .IN+5 =Line 1 of input >l?f/input/ // ignore any failure of left. =line 1 of ^input // find has been executed even // though left failed. .JU .IN-5 This is most useful when using a complex command sequence to process many lines of text, the exact contents of which may be unknown. .SECTION Inverted failure condition Just as '?' causes any failure to be ignored, backslash '\' has the effect of inverting the condition. i.e Any command which fails will effectively succeed! .NJ .IN+5 >(F/fred/\p)* // print all lines that do not // contain 'fred'. .JU .IN-5 It sould be noted that '*', '?' and '\' are all instances of a repetition modifier as is a simple repetition number. Therefor if both are required for a single command then the latter must be enclosed in brackets. e.g. R10? is illegal for it has two repetition modifiers and so (R10)? must be used. .SECTION Alternative command sequences It is often useful to be able to execute a different command sequence when a previous one fails. This is specified by separating command sequences with commas ','. e.g C1, C2, C3 means if C1 fails then try C2, else if C2 fails try C3. Once an alternative succeeds the remaining alternatives are skipped, execution being resumed after the end of the sequence which is often the closing bracket of a compound command. .NJ .IN+5 >D/DOG/,D/CAT/,m // will delete either 'DOG' // or 'CAT' if one exists on // the current line, otherwise // a move is performed. >f1/fred/,f1/joe/ // this would find 'fred' or // 'joe' on the current line // else fails. >((f1/fred/,f1/joe/)p,m)* // this would print any line // containing 'fred' or 'joe' // within the rest of the file. .IN-5 .JU .SECTION Action on command failure It is difficult to describe exactly what happens when a command within a a complex command line fails. This is not due to any inherent complexity but rather because of the diversity of structures that the user may construct. Because of this only a brief description is attempted here and it is suggested that it be read together with the following examples of structured command lines. Failure of a command causes ECCE to check the repetition modifier (if one exists) to see if the failure is to be ignored or inverted. If it is then execution resumes at the next command in the sequence. Otherwise subsequent commands are skipped until either an alternative is encountered in which case it is executed, or the end of the sequence is detected causing the generation of an error message. This action also applies to compound commands such that failure of an item within the compound command causes the latter to fail unless it is followed by a a repetition modifier of '*', '?' or '\'. It follows that the skipping of commands on failure also applies to compound commands, the whole contents of the brackets being ignored. In the case of nested compound commands the action is repeated at each level until either the failure is suppressed or the whole sequence fails. e.g. ((R2E (F/fred/) P)? M)* Failure of F/fred/ causes execution to resume at M since the enclosing compound command has an ignore failure repetition modifier '?'. .SECTION Examples of structured command lines Some examples of structured command lines are given below to illustrate the useage of the features just described. To print all lines ending in the string 'fred' we could use: .CE1 (R0L4V/fred/P, M)* A more complicated example might be to change upper case comments to lower case leaving the initial letter alone. Assume that within the source file comments are introduced by '//' and terminated by 'newline'. Any number of spaces may follow the '//' and we insure there is at least one. .CE1 (f1.//.R2 (V/ /R, I/ /) (V/ /R)* R? C0, M)* As a final example suppose we wish to ensure that all lines begin with five spaces, are padded to 80 characters with spaces and end in a '+'. Any blank lines are to be ignored and overlong lines truncated. .CE1 ((R\M)*L (V/ /R, I/ /)5 (R, I/ /)74 E0 I/+/ M)* .CHAPTER SPECIAL COMMANDS .HEREIS SPECIAL A set of special commands exist for updating the editing environment. These are preceded by a percent '%' sign and must appear as the first and only item of a command sequence. Thus in order to input more than one special command to a line semicolon ';' separaters must be employed. .SECTION Finishing the session .LIST 20 .ITEM %C~~(Close) Close the session copying all the current file to the output file. .ITEM %A~~(Abort) Terminate the session immediately without copying to the output file. .ENDLIST .SECTION Comment facility .LIST 20 .ITEM %R~~(Remark) The rest of the command line is taken as a comment and is reproduced on the display stream. .ENDLIST .SECTION Control of monitoring Normally ECCE only prints out the current line on completion of a command sequence if a different line has been reached in the file. This default action may be modified as follows: .LIST 20 .ITEM %F~~(Full monitor) Print out the current line onr completion of each command sequence. .ITEM %M~~(Monitor) Default monitoring. .ITEM %Q~~(Quiet mode) Only print if an explicit print command is executed. Note: If the last command executed was a print (P) then the line will not be re-printed reqardless of the monitor setting. .ENDLIST .SECTION Input prompting Prompting for input (the default) may be turned off using the prompt toggle. Subsequent use will reinstate the default mode. .LIST 20 .ITEM %P~~(Prompt toggle) Switch input prompting on or off. .ENDLIST .SECTION Horizontal start This is used to control the start column for the print command. In particular when the line is too long to display in its entirety the user may select the portion currently of interest. .LIST 20 .ITEM %H= Print will subsequently display the line from character position . %H 'Newline' is identical to %H=0. .ENDLIST .SECTION Macro facility Up to four macros called W,X,Y and Z may be defined as any sequence of commands. Subsequent use of the macro name in a command line will result in its being replaced with the text of its definition. .NJ .IN+5 %X=F/fred/ // set X=F/fred/ .IN-5 .JU Note: this is implemented as text substitution so that X2 is not equal to (X)2. As an example suppose X=RE then X2 means RE2 and not (RE)2. Of course the macro definition could have included the brackets if the latter was intended. Semicolons may also be included within the body of a macro consequently the definition may only be terminated by 'newline'. Hence a possible trap for the unwary: %X=(R,I/ /) ;%R tabulate macro here the intended comment is included in the macro definition so that each use of 'X' will result in the text 'tabulate macro' being output on the display stream. A macro may be re-defined at any time and also returned to its original undefined state by specifying a null definition. .SECTION Display value of object .LIST 14 .ITEM %V~~(Value) This command is used to display the current value of an item specified as an argument. Currently the only acceptable arguments are the names of macros and an equals sign '=' which outputs the current line number. .NJ .IN+5 >%VX // Value of X macro =F/fred/ >%VZ // value of Z macro =Undefined: Z // not defined yet .IN-5 .JU .ENDLIST .CHAPTER SECONDARY INPUT .HEREIS SECONDARYINPUT Secondary input provides the means to incorporate all or part of another file within the file being edited. In order to make use of this facility the secondary input file must first be defined using a command of the form: .CE %S= Insertion is achieved by moving the file pointer to the desired position and using a %S command to 'switch-on' secondary input. Whilst in secondary mode ECCE will prompt with '>>' as a reminder. In this mode any text passed over by the secondary file pointer (a separate file pointer is maintained for the secondary file) is included in the main file immediately before the main file pointer. Any text deleted will not appear in the main file. n.b the secondary file isself will not be altered by any command. During secondary input no commands may be used that would move the file pointer backwards or up the file e.g. m-, l, e-. A subsequent %S will restore normal mode and editing may continue. Further %S commands cause the secondary file to be re-opened at the position when the last %S was used and may be issued at any time to include other parts of the secondary file at various positions within the main file. The secondary file can always be rewound however by reconnecting using %S=. .CHAPTER SUMMARY OF COMMANDS .HEREIS SUMMARY .nj Notation {-} denotes an optional negative variant {ss} denotes an optional searchspace (may include *) {rep} denotes an optional repetion number (may include *, \, ?) denotes a mandatory text string. Command Meaning A Undefined B{rep} Break a line in two at the file pointer C{-}{rep} Change the Case of a character D{ss}{rep} Delete the specified text E{-}{rep} Erase the specified number of characters F{-}{ss}{rep} Find an occurrence of 'text' G{rep} Insert lines before the current line H Undefined I{rep} Insert 'text' before the file pointer J{rep} Join current line to next in file K{rep} Delete specified number of lines L{rep} Left one character M{-}{rep} Move to next/previous line N Undefined O{rep} Move line over next in file P{rep} Display current line on console Q Undefined R{rep} Right one character S Substitute 'text' for 'found' text T{ss}{rep} Traverse specified text U{ss}{rep} Delete up to specified text V Verify specified text is to right of file pointer W, X, Y, Z Macro command .CHAPTER SUMMARY OF SPECIAL COMMANDS .HEREIS SUMMARYSPECIAL .NJ Command Meaning %A Abort ECCE. %C Close ECCE in an orderly manner. %F Full monitoring. %H {=} Horizontal start (for print 'P') %M Monitor normally. %P Prompt toggle. %Q Quiet mode (don't monitor). %R Remark (comment facility). %S {=} Secondary input control. %V Value of object. %W = {} Macro definition. %X = {} Macro definition. %Y = {} Macro definition. %Z = {} Macro definition. .JU .CHAPTER ERROR MESSAGES AND THEIR MEANING .HEREIS MESSAGES Error messages from ECCE are always brief and result from either mistakes in the syntax of a command line or failure during execution. A list of common errors is given below: Message~~~~~~~~~~~~~Meaning .LIST 20 .ITEM Command~Q? Command (in this case Q) not understood. Sometimes the command letter may be omitted in the message indicating a more global mistake. .ITEM Text~for~F? Usually results from a mistyped delimiter, however a null string in the wrong context also produces this error. .ITEM Too~long! An internal limit has been exceeded. Typically an over-long macro or command line. .ITEM Overflow! Attempt to specify a number outside the permitted range. .ITEM Brackets! Brackets mismatch. This often arises as a result of (... ; ...) which is illegal as ';' instructs ECCE to execute the command sequence which has only an opening bracket. .ITEM Macro~recursion! A macro ultimately calls itsself perhaps indirectly via another. e.g. %X=y followed by %Y=x. .ITEM Undefined: X Attempt to use an undefined macro (in this case X). .ITEM Failure~F'fred' The specified command has failed during execution. .ITEM Source~line~too~long Self explanatry, the line will be truncated. .ENDLIST .CHAPTER SYNTAX OF ECCE .HEREIS SYNTAX Notation Items enclosed by brackets '[]' are optional, the item may appear once or not at all. Braces '{}' denote optional items which may appear any number of times or not at all. Items bounded by quotes ".." are literal values (terminal symbols). Parentheses '()' are used to group items together. Identifiers or names without quotes denote syntax rules (non-terminal symbols). Syntax .NJ .PD` CommandLine = ( SpecialCommand | RepetitionModifier | CommandSequence ) { ";" CommandLine } Newline SpecialCommand = "%" Text CommandSequence = ( CompoundCommand | Command | AlternativeList ) { CommandSequence } CompoundCommand = "(" CommandSequence ")" [ RepetitionModifier ] AlternativeList = CommandSequence {"," AlternativeList } Command = SimpleCommand | TextCommand | MacroCommand SimpleCommand = ( LineCommand | CharacterCommand ) [ RepetitionModifier ] LineCommand = LineCommandName | ReversibleLineCommand CharacterCommand = CharacterCommandName | ReversibleCharacterCommand .BP TextCommand = TextReplacementCommand | TextInsertionCommand | TextLocationCommand | TextVerificationCommand MacroCommand = "W" | "X'"| "Y" | "Z" LineCommandName = "B" | "G" | "J" | "K" | "P" ReversibleLineCommand = "M" [ "-" ] CharacterCommandName = "R" | "L" ReversibleCharacterCommand = ( "C" | "E" ) [ "-" ] TextReplacementCommand = "S" Delimiter [ Text ] ( Delimiter | Newline ) TextInsertionCommand = "I" Delimiter Text ( Delimiter [ RepetionModifier ] | Newline ) TextLocationCommand = "F" | "T" | "U" | "D" [ Searchspace ] Delimiter Text Delimiter { } TextVerificationCommand = "V" Delimiter Text Delimiter Searchspace = RepetitionNumber RepetitionModifier = "\" | "?" | RepetitionNumber .PD* Delimiter = "#" | "$" | "&" | "=" | "~" | "{" | "}" | "[" | "]" | "+" | ":" | "<" | ">" | "." | "/" | "^" | "|" | "@" | "`" .PD` Text = "Any character excluding the delimiter used" { Text } RepetitionNumber = ( Digit { Digit } ) | "*" Digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" Newline = "Carriage return" .JU .PD~ .APPENDIX IMPLEMENTATION DEPENDANT FEATURES .HEREIS IMPLEMENTATION Conceptually ECCE operates inplace on a source file. In practice this may be implemented in a variety of ways, two of which are most common. The first of these provides an in-store window to which edits are applied. As the file pointer is moved through the file parts of the window are progressively copied to the output file. A consequence of this is that m-0 can only move the file pointer back to the start of the window and not to the beginning of the file. In the second implementation edits are applied to a copy of the source held in a disc workspace which is copied to the output file on receipt of a %C command. In this version unrestricted movement is available throughout the file. .SECTION Cancelling of commands If a command is mis-specified resulting in looping or the production of large volumes of text, it may be interrupted using the ESC key. A message of the form: .CE *** Command cancelled is output and the command abandoned. .SECTION Failure codes ECCE may terminate with a failcode for one of several reasons, the following are most common: .LIST 15 .ITEM Failcode 2 A syntax error was detected during the edit. .ITEM Failcode 4 A command failure occured. .ITEM Failcode 6 A combination of the above. .ITEM Failcode 8 Only when %A (Abort) is used. .ITEM Failcode A filing error was detected on an output file. .ENDLIST .SECTION Size restrictions .LIST .BLOB Source lines may not exceed 132 characters, longer lines will be truncated. .BLOB A command line including macro expansion must not exceed 200 commands. .BLOB A macro definition may not exceed 80 characters. .ENDLIST .APPENDIX ARGUMENT SPECIFICATION (LITERAL DATA) .HEREIS ARGUMENTS ECCE decodes its arguments against an internally held proforma or template. Arguments may be specified both by position and/or name providing a flexible means of identifying the neccessary data. Arguments may be entered as either literal data 'names' or labels (name followed by a colon ':'). The current proforma used by ECCE is as follows: .SP .NJ PROFORMA ECCE FROM Filespec TO Filespec () WITH Filespec (**) WORK Filepsec (/(S200)) OPT String () .JU Items shown within brackets are the defaults, empty brackets denoting a null default whilst the absence of brackets indicates that the argument may not be defaulted. .SP If no output file is specified then the edited file is written to a file of the same name as the input after first renaming the latter as /BAK. Commands are input from the WITH stream so that an edit file may be prepared and then executed. It also provides the means of recovering an edit after a system crash. For example to run the edit script in .ECCESCRIPT on the source file .ECCESOURCE we might use: .SP ECCE .ECCESOURCE WITH:.ECCESCRIPT .SP or if we do not have enough room in our partition for the workfile: .SP ECCE .ECCESOURCE WITH:.ECCESCRIPT WORK:/DD777(S500) .SP which creates a scratch file of 500 pages on LVN 777 partition 2. .SP The available options which are input as a string (enlosed in quotes ") are as follows: .LIST .BITEM SEQential Edit the file in a pseudo-sequential manner. The file is divided into workspaces. Within a workspace you are free to move up and down as normal. However, you can only move to the next workspace (ie go forward through the file). .sp The SEQUENTAIL option is useful is you do not have enough disc space to hold the ECCE work file. .BITEM RETain ECCE automatically maintains a recovery file containing all commands entered during an editing session (see below). At the end of a successful edit, this file is normally deleted. The RETAIN option allows this file to be kept. This might be useful as an update mechanism, where different people apply successive edits to a file without altering the original. .ENDLIST .SECTION Recovering after system errors ECCE maintains a file of all commands entered during an editing session. This is called /REC. This file may be used to recover if the system crashes while an edit is in progress. For example, recover after editing AFILE/1/S, use the commands: .sp <>FILES .AFILE/1/S/REC .AFILE/REC <>ECCE .AFILE/1/S WITH .AFILE/REC 4-WITH: *N <> .sp It is necessary to rename the recovery file to stop ECCE overwriting it during the edit. .APPENDIX COMMAND DEFINITIONS AND EFFECT .HEREIS DEFINITIONS This section attempts to define the effects of individual commands in success and failure conditions. It is intended to be definitive for this implementation of ECCE and may deviate in some small details from the original Edinburgh version. .LIST 24 .ITEM Command ~~Break .ITEM Action ~~A 'newline' is inserted immediately before the file pointer splitting the line in two. The text to the right of the file pointer becomes the new current line. .ITEM Effect~of~found~status: None. .ITEM File~pointer: Unaltered. .ITEM Effect~on~found~status: None. .ITEM Failure~condition ~~None. .ITEM File~pointer: Unaltered. .ITEM Effect~on~found~status: None. .ITEM Command ~~Case .ITEM Action ~~The case of the character to the right of the file pointer is reversed if it is alphabetic. .ITEM Effect~of~found~status: None. .ITEM File~pointer: Advanced by one character. .ITEM Effect~on~found~status: Cleared. .ITEM Failure~condition ~~The file pointer is already at the end of the line or at the end of the file. .ITEM File~pointer: Unaltered. .ITEM Effect~on~found~status: None. .BP .ITEM Command ~~Delete .ITEM Action ~~The first occurance of the specified text is deleted. .ITEM Effect~of~found~status: None. .ITEM File~pointer: Repositioned immediately after the deleted text. .ITEM Effect~on~found~status: Cleared. .ITEM Failure~condition ~~The specified text does not occur within the searchspace which defaults to the rest of the current line. .ITEM File~pointer: Unaltered with default searchspace otherwise repositioned at the start of last line scanned. .ITEM Effect~on~found~status: None with default searchspace otherwise cleared. .BP .ITEM Command ~~Erase .ITEM Action ~~The character to the right of the file pointer is deleted. .ITEM Effect~of~found~status: None. .ITEM File~pointer: Unaltered. .ITEM Effect~on~found~status: Cleared. .ITEM Failure~condition ~~The file pointer is already at the end of the line or at the end of the file. .ITEM File~pointer: Unaltered. .ITEM Effect~on~found~status: None. .ITEM Command ~~Erase back .ITEM Action ~~The charcter to the left of the file pointer is deleted. .ITEM Effect~of~found~status: None. .ITEM File~pointer: Unaltered. .ITEM Effect~on~found~status: None. .ITEM Failure~condition ~~The file pointer is already at the start of the line or at the end of the file. .ITEM File~pointer: Unaltered. .ITEM Effect~on~found~status: None. .BP .ITEM Command ~~Find .ITEM Action ~~The file is scanned from left to right and towards the end of the file for an occurrence of the specified text. .ITEM Effect~of~found~status: An occurrence of the specified text already found is ignored. .ITEM File~pointer: The file pointer is placed in front of the first occurrence of the specified text. .ITEM Effect~on~found~status: Set. .ITEM Failure~condition ~~The specified text does not occurr within the seachspace which defaults to the rest of the file. .ITEM File~pointer: Unaltered for a searchspace of one otherwise set to the start of the last line scanned. .ITEM Effect~on~found~status: Unaltered for a searchspace of one otherwise cleared. .BP .ITEM Command ~~Find back .ITEM Action ~~The file is scanned from right to left and towards the start of the file for an occurrence of the specified text. .ITEM Effect~of~found~status: An occurrence of the specified text already found is ignored. .ITEM File~pointer: Repositioned immediately in front of the specified text. .ITEM Effect~on~found~status: Set. .ITEM Failure~condition ~~The specified text does not occur within the searchspace which defaults to all of the file before the file pointer. .ITEM File~pointer: Unaltered for a searchspace of one otherwise set to the start of the last line scanned. .ITEM Effect~on~found~status: Unaltered for a searchspace of one otherwise cleared. .BP .ITEM Command ~~Get .ITEM Action ~~One complete line read from the command input is inserted into the file before the current line. .ITEM Effect~of~found~status: None. .ITEM File~pointer: Unaltered. .ITEM Effect~on~found~status: None. .ITEM Failure~condition ~~A line input consisting of only a colon ':'. This feature may be used to terminate a multiple get command by forcing the failure condition. .ITEM File~pointer: Unaltered. .ITEM Effect~on~found~status: None. .ITEM Command ~~Insert .ITEM Action ~~The specified text is inserted immediately before the file pointer. .ITEM Effect~of~found~status: None. .ITEM File~pointer: Unaltered. .ITEM Effect~on~found~status: None. .ITEM Failure~condition ~~The maximum line length would be exceeded or the file pointer is already at the end of the file. .ITEM File~pointer: Unaltered. .ITEM Effect~on~found~status: None. .BP .ITEM Command ~~Join .ITEM Action ~~A 'newline' is deleted from the end of the current line causing the next line of the file to be appended. .ITEM Effect~of~found~status: None. .ITEM File~pointer: Repositioned at the 'join'. .ITEM Effect~on~found~status: Cleared. .ITEM Failure~condition ~~The maximum permitted line length would be exceeded or the file pointer is already at the end of the file. .ITEM File~pointer: Unaltered. .ITEM Effect~on~found~status: None. .ITEM Command ~~Kill .ITEM Action ~~The current line is deleted. .ITEM Effect~of~found~status: None. .ITEM File~pointer: Positioned at the start of the next line in the file. .ITEM Effect~on~found~status: Cleared. .ITEM Failure~condition ~~The file pointer is at the end of the file. .ITEM File~pointer: Unaltered. .ITEM Effect~on~found~status: None. .BP .ITEM Command ~~Left .ITEM Action ~~The file pointer is moved one character to the left. .ITEM Effect~of~found~status: None. .ITEM File~pointer: See action. .ITEM Effect~on~found~status: Cleared. .ITEM Failure~condition ~~The file pointer is already at the start of the line or at the end of the file. .ITEM File~pointer: Unaltered. .ITEM Effect~on~found~status: None. .BP .ITEM Command ~~Move .ITEM Action ~~The file pointer is moved to the start of the next line in the file. .ITEM Effect~of~found~status: None. .ITEM File~pointer: See action. .ITEM Effect~on~found~status: Cleared. .ITEM Failure~condition ~~The file pointer is already at the end of the file. .ITEM File~pointer: Unaltered. .ITEM Effect~on~found~status: None. .ITEM Command ~~Move back .ITEM Action ~~The file pointer is placed at the start of the previous line of the file. .ITEM Effect~of~found~status: None. .ITEM File~pointer: See action. .ITEM Effect~on~found~status: Cleared. .ITEM Failure~condition ~~The file pointer is already at the start of the file. .ITEM File~pointer: Unaltered. .ITEM Effect~on~found~status: None. .BP .ITEM Command ~~Print .ITEM Action ~~The current line is output to the display stream. If a repetition count is appended the effect is to move to the next line in the file after each repetition so printing a number of lines. .ITEM Effect~of~found~status: The found text is highlighted. .ITEM File~pointer: Unaltered for a repetition count of one else moved to the start of the last line printed. .ITEM Effect~on~found~status: Unaltered for a repetition count of one otherwise cleared. .ITEM Failure~condition ~~The file pointer is already at the end of the file and a repetition number greater than one was specified. .ITEM File~pointer: Unaltered. .ITEM Effect~on~found~status: None. .ITEM Command ~~Right .ITEM Action ~~The file pointer is advanced by one character. .ITEM Effect~of~found~status: None. .ITEM File~pointer: See action. .ITEM Effect~on~found~status: Cleared. .ITEM Failure~condition ~~The file pointer is already at the end of the line or at the end of the file. .ITEM File~pointer: Unaltered. .ITEM Effect~on~found~status: None. .BP .ITEM Command ~~Substitute .ITEM Action ~~The found text is replaced by the specified text. .ITEM Effect~of~found~status: Defines the text that is to be replaced. .ITEM File~pointer: The file pointer is placed immediately after the replacement text. .ITEM Effect~on~found~status: Cleared. .ITEM Failure~condition ~~Found status not set. .ITEM File~pointer: Unaltered. .ITEM Effect~on~found~status: None. .ITEM Command ~~Traverse .ITEM Action ~~The line is scanned from left to right for the specified text. .ITEM Effect~of~found~status: An occurrence of the specified text already found is ignored. .ITEM File~pointer: Repositioned immediately after the found text. .ITEM Effect~on~found~status: Cleared. .ITEM Failure~condition ~~The specified text is not found within the searchspace which defaults to the rest of the current line. .ITEM File~pointer: Unaltered for the default searchspace otherwise set to the start of the last line scanned. .ITEM Effect~on~found~status: None for the default searchspace otherwise cleared. .BP .ITEM Command ~~Uncover .ITEM Action ~~All text (including 'newlines') between the current position of the file pointer and the next occurrence of the specified text is deleted. The specified text itsself is unaltered. .ITEM Effect~of~found~status: An occurrence of the specified text already found is ignored. .ITEM File~pointer: Positioned immendiately in front of the specifed text. .ITEM Effect~on~found~status: Reset. .ITEM Failure~condition ~~The specified text does not occur within the searchspace which defaults to the rest of the current line. .ITEM File~pointer: Unaltered for the default searchspace otherwise set to the start of the last line scanned. .ITEM Effect~on~found~status: None for the default searchspace otherwise cleared. .ITEM Command ~~Verify .ITEM Action ~~Found status is set if the specified text occurs immediately to the right of the file pointer. .ITEM Effect~of~found~status: None. .ITEM File~pointer: Unaltered. .ITEM Effect~on~found~status: See action. .ITEM Failure~condition ~~The specified text does not occur immediately to the right of the file pointer. .ITEM File~pointer: Unaltered. .ITEM Effect~on~found~status: Cleared. .ENDLIST .APPENDIX SAMPLE EDITING SESSIONS .HEREIS SESSIONS Two example editing sessions are given in this appendix to illustrate the way in which ECCE may be used. The first is a 'batch' job which executes the prepared editing script held in the file ECCESCRIPT. Following this is a simple online example to give some idea of what to expect! .NJ .SECTION Running an edit script BCPLPROG contains the following simple BCPL program: GET "LIBHDR" MAINFEST $( VERSION = 1 UG = GLOBAL.BASE FIX = 2 UNDO = 3 $) MAINFEST $( TITLEINDEX = 2 TODAYINDEX = 3 $) GLOBAL $( VAR1: UG VAR2 : UG+1 VAR3 : UG+2 PROC1 : UG+3 PROC2 : UG+4 $) LET START() BE $( LET A = 1 PROC1(VAR1) STOP(0) $) . .BP BCPLSCRIPT contains a small editing script intended to format the declarations: %RSimple format for BCPL program %RDefine macro Y to erase spaces. %Y=(v/ /e)* %RDefine macro X to tabulate to specified column. %X=L0(R,I/ /) %RGlobal exchange MAINFEST to MANIFEST (can't spell)! (f/MAINFEST/S/MANIFEST/P)* M-0 %RAlign global declarations (F/GLOBAL/M(F1/:/BM-X20JR2YM)*)* M-0 %RAlign manifest declarations (F/MANIFEST/M(F1/=/BM-X20JR2YM)*)* %RPrint resultant file. M-0P0 %RClose the edit. %C .BP Running ECCE with the above files produces the output: ECCE .BCPLPROG /(S).BCPLPROG/1 .BCPLSCRIPT ECCE Issue 4A on 10 Oct 83 Simple format for BCPL program Define macro Y to erase spaces. Define macro X to tabulate to specified column. Global exchange MAINFEST to MANIFEST (can't spell)! MANIFEST $( MANIFEST $( ** End ** GET "LIBHDR" Align global declarations ** End ** GET "LIBHDR" Align manifest declarations ** End ** Print resultant file. GET "LIBHDR" MANIFEST $( VERSION = 1 UG = GLOBAL.BASE FIX = 2 UNDO = 3 $) MANIFEST $( TITLEINDEX = 2 TODAYINDEX = 3 $) GLOBAL $( VAR1 : UG VAR2 : UG+1 VAR3 : UG+2 PROC1 : UG+3 PROC2 : UG+4 $) LET START() BE $( LET A = 1 PROC1(VAR1) STOP(0) $) . ** End ** Close the edit. File: BCPLPROG/1 Lines output: 28 Size: 1 page(s) .JU .BP .SECTION Online use of ECCE A BCPL program is to be entered into a file and any typographical errors corrected once the input is complete (there will of course be no logical errors)! .NJ ECCE *N /(S).BPROG/1/S ECCE Issue 4A on 10 Oct 83 G0 :GET "LIBHDR" : :manifest $( :Mark = 1 :Issue = 2 :format =0 :indent_inc = 5 :$) : :LEET do_indent(amount0 BE :$( LET margin := 1 : LET len = ? : : FOR i=! TO page_width DO lbuff := ' *S' : copy_text(lbuff) : RETTRN :$) : :AND start() BW :$( start_module1() : start_module2'( : format() :$) :. :: >P10 GET "LIBHDR" manifest $( Mark = 1 Issue = 2 format =0 indent_inc = 5 $) LEET do_indent(amount0 BE >F-/man/ manifest $( >C8 MANIFEST $( >P20 Mark = 1 Issue = 2 format =0 indent_inc = 5 $) LEET do_indent(amount0 BE $( LET margin := 1 LET len = ? FOR i=! TO page_width DO lbuff := ' *S' copy_text(lbuff) RETTRN $) AND start() BW $( start_module1() start_module2'( format() >F-/LEET/S/LET/ LET do_indent(amount0 BE >F/0/S/)/ LET do_indent(amount) BE >M $( LET margin := 1 >D/:/ >F/!/S/i/F/ */E FOR i=i TO page_width DO lbuff := '*S' >F/TRN/S/URN/ RETURN  >M3 AND start() BW >D/W/I/E >M-0P0 GET "LIBHDR" MANIFEST $( Mark = 1 Issue = 2 format =0 indent_inc = 5 $) LET do_indent(amount) BE $( LET margin = 1 LET len = ? FOR i=i TO page_width DO lbuff := '*S' copy_text(lbuff) RETURN $) AND start() BE $( start_module1() start_module2'( format() $) . ** End ** >%C File: BPROG/1/S Lines output: 24 Size: 1 page(s) .JU