1 TED version 1.1, July 1980 TED TECO [1] compatable text editor for Z-80 CP/M systems Copyright (C) 1980, 1984 by Mark E. Mallett ---------- [1] TECO is a product of Digital Equipment Corporation 2 TED version 1.1, July 1980 Table of Contents 1.0 PREFACE . . . . . . . . . . . . . . . . . . . . . . . . 1-1 1.1 System Requirements . . . . . . . . . . . . . . . . . 1-1 1.2 Salient features . . . . . . . . . . . . . . . . . . 1-1 2.0 Introduction . . . . . . . . . . . . . . . . . . . . . 2-1 2.1 Characters . . . . . . . . . . . . . . . . . . . . . 2-1 2.2 Files . . . . . . . . . . . . . . . . . . . . . . . . 2-2 2.3 The editing buffer . . . . . . . . . . . . . . . . . 2-2 2.4 Files and the buffer . . . . . . . . . . . . . . . . 2-4 2.5 Commands . . . . . . . . . . . . . . . . . . . . . . 2-5 3.0 Invoking TED . . . . . . . . . . . . . . . . . . . . . 3-1 4.0 Entering Commands . . . . . . . . . . . . . . . . . . . 4-1 5.0 Basic Commands . . . . . . . . . . . . . . . . . . . . 5-1 5.1 Value commands . . . . . . . . . . . . . . . . . . . 5-1 5.1.1 Buffer Positions . . . . . . . . . . . . . . . . 5-1 5.2 Buffer Pointer Positioning . . . . . . . . . . . . . 5-1 5.2.1 The J command . . . . . . . . . . . . . . . . . . 5-2 5.2.2 C and R . . . . . . . . . . . . . . . . . . . . . 5-2 5.2.3 The L command . . . . . . . . . . . . . . . . . . 5-2 5.2.4 Searching . . . . . . . . . . . . . . . . . . . . 5-3 5.3 Text viewing . . . . . . . . . . . . . . . . . . . . 5-4 5.3.1 The T command . . . . . . . . . . . . . . . . . . 5-4 5.4 Insertion and Deletion . . . . . . . . . . . . . . . 5-4 5.4.1 Insertion . . . . . . . . . . . . . . . . . . . . 5-5 5.4.2 Deletion . . . . . . . . . . . . . . . . . . . . 5-5 5.4.3 Replacement . . . . . . . . . . . . . . . . . . . 5-6 5.5 File Control and Exiting . . . . . . . . . . . . . . 5-6 5.5.1 File Control . . . . . . . . . . . . . . . . . . 5-6 5.5.2 Exiting . . . . . . . . . . . . . . . . . . . . . 5-7 6.0 File Selection and Control . . . . . . . . . . . . . . 6-1 6.1 File Selection . . . . . . . . . . . . . . . . . . . 6-1 6.1.1 The ER command . . . . . . . . . . . . . . . . . 6-1 6.1.2 The EW command . . . . . . . . . . . . . . . . . 6-1 6.1.3 The ED command . . . . . . . . . . . . . . . . . 6-2 6.1.4 The EB command . . . . . . . . . . . . . . . . . 6-2 6.2 File Control . . . . . . . . . . . . . . . . . . . . 6-2 6.2.1 The A command . . . . . . . . . . . . . . . . . . 6-2 6.2.2 The ^P and ^Y commands . . . . . . . . . . . . . 6-3 6.3 File Termination . . . . . . . . . . . . . . . . . . 6-3 6.3.1 The EF command . . . . . . . . . . . . . . . . . 6-3 6.3.2 The EK command . . . . . . . . . . . . . . . . . 6-4 6.3.3 The EX command . . . . . . . . . . . . . . . . . 6-4 7.0 Q-registers . . . . . . . . . . . . . . . . . . . . . . 7-1 7.1 Buffer Selection . . . . . . . . . . . . . . . . . . 7-1 TED version 1.1, July 1980 7.1.1 The EE command . . . . . . . . . . . . . . . . . 7-1 7.1.2 The EA command . . . . . . . . . . . . . . . . . 7-2 7.1.3 The FE command . . . . . . . . . . . . . . . . . 7-2 7.1.4 The FA command . . . . . . . . . . . . . . . . . 7-2 7.2 Text manipulation . . . . . . . . . . . . . . . . . . 7-3 7.2.1 The X command . . . . . . . . . . . . . . . . . . 7-3 7.2.2 The G command . . . . . . . . . . . . . . . . . . 7-3 7.3 Macros . . . . . . . . . . . . . . . . . . . . . . . 7-3 7.3.1 The M command . . . . . . . . . . . . . . . . . . 7-4 7.3.2 The W command . . . . . . . . . . . . . . . . . . 7-4 7.3.3 The EP and EI commands . . . . . . . . . . . . . 7-4 7.4 Numeric Q-registers . . . . . . . . . . . . . . . . . 7-5 7.4.1 The U command . . . . . . . . . . . . . . . . . . 7-5 7.4.2 The Q command . . . . . . . . . . . . . . . . . . 7-5 7.4.3 The % command . . . . . . . . . . . . . . . . . . 7-5 7.4 Numeric Q-registers . . . . . . . . . . . . . . . . . 7-5 7.5 The Q-register stack . . . . . . . . . . . . . . . . 7-5 7.5.1 The [ command . . . . . . . . . . . . . . . . . . 7-6 7.5.2 The ] command . . . . . . . . . . . . . . . . . . 7-6 7.5.3 General . . . . . . . . . . . . . . . . . . . . . 7-6 8.0 Values . . . . . . . . . . . . . . . . . . . . . . . . 8-1 8.1 Multiple values . . . . . . . . . . . . . . . . . . . 8-1 8.2 Expressions . . . . . . . . . . . . . . . . . . . . . 8-1 8.2.1 Classes of commands . . . . . . . . . . . . . . . 8-1 8.2.1.1 Value commands . . . . . . . . . . . . . . . 8-1 8.2.1.2 Operator commands . . . . . . . . . . . . . . 8-1 8.2.1.3 Value arrangement . . . . . . . . . . . . . . 8-2 8.2.1.4 Value Clearing . . . . . . . . . . . . . . . 8-2 8.2.1.5 Invisible Commands . . . . . . . . . . . . . 8-2 8.3 Partial vs complete values . . . . . . . . . . . . . 8-3 8.3.1 Complete values . . . . . . . . . . . . . . . . . 8-3 8.3.2 Partial values . . . . . . . . . . . . . . . . . 8-4 9.1 Iterations . . . . . . . . . . . . . . . . . . . . . 9-1 9.1.1 Iteration format - < and > . . . . . . . . . . . 9-1 9.1.2 The ; command . . . . . . . . . . . . . . . . . . 9-2 9.2 Conditional execution . . . . . . . . . . . . . . . . 9-2 9.3 Branching . . . . . . . . . . . . . . . . . . . . . . 9-3 9.3.1 The ! command . . . . . . . . . . . . . . . . . . 9-4 9.3.2 The O command . . . . . . . . . . . . . . . . . . 9-4 10.0 Advanced Insertion . . . . . . . . . . . . . . . . . . 10-1 10.1 Numeric value insertion . . . . . . . . . . . . . . 10-1 10.1.1 n\ and n\\ . . . . . . . . . . . . . . . . . . . 10-1 10.2 Special insert string characters . . . . . . . . . . 10-1 11.0 Advanced Searching . . . . . . . . . . . . . . . . . . 11-1 12.0 Miscellaneous Advanced Commands . . . . . . . . . . . 12-1 TED version 1.1, July 1980 Appendix A - Alphabetic Summary of Commands . . . . . . . . A-1 Appendix B - Topical Summary of Commands . . . . . . . . . B-1 Appendix C - Error messages . . . . . . . . . . . . . . . . C-1 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . I-1 TED version 1.1, July 1980 1.0 PREFACE This document describes the CP/M Z-80 TED editor. TED, based on various implementations of Digital Equipment Corporation's (DEC) program TECO, is a character oriented text editor. More than that, it provides an editing language, which may be used to perform functions not normally associated with editors. 1.1 System Requirements TED runs under the control of CP/M, a disk operating system by Digital Research, Inc., on a Z-80 processor. Its program space (non-text area) occupies between 12K and 13K bytes of memory, and its buffer space occupies the rest of free memory available (including the CCP area of CP/M). Therefore, TED can run on a 20K CP/M system, with about 4K bytes of text buffer space. It is recommended, however, that no less than a 24K system be used, the 8K buffer then available being quite tolerable. 1.2 Salient features Some of the outstanding features of TED follow o Multiple text buffers. o Advanced character editing facilities. o Programmable commands. TED offers the advanced user the ability to write and store editing programs. o TED uses a subset of the fast string searching algorithm presented by Boyer and Moore in the November, 1977 issue of the Communications of the ACM. 1-1 TED version 1.1, July 1980 2.0 Introduction This chapter contains various introductory concepts. Those already familiar with CP/M and TECO may skip this chapter, but should first scan the table of contents. 2.1 Characters TED is basically a character oriented editor; it operates on characters rather than on lines. It is therefore appropriate to begin this introduction with a discussion of the characters used. Any 7-bit ASCII character (hex values 0 through 7F) is a valid object to TED; it may be inserted into and deleted from, included in a file to be edited by TED - most characters are also valid editing commands;. This character set can be divided into several classes. These classes are discussed in the next few paragraphs. Printing characters are those which can be printed; they are the normal characters. These can be further divided into such groups as digits, upper and lower case alphabetics, and others, but in general are considered to be of the same class. Control characters are ASCII codes 00 through 17 (hex). Some control characters belong in another class as well (e.g., ESC), but they are still control characters. A control character is entered by striking a key while the control key (CTRL, CNTRL, or some such) is depressed, and is named by the key which is depressed to produce the character. For example, depressing CTRL and A produce the character whose ASCII code is 01 and which is called control-A. TED normally displays control characters by preceding the namesake character with an up-arrow (or carat). Control-A is displayed as ^A, etc. ASCII codes 08 through 0D (hex) are carriage control characters, used for carriage (cursor) movement. They are: 08 (^H) Backspace. This backs up the cursor one column, and has special meaning during command input. 09 (^I) Horizontal tab. TED assumes tab stops every 8 columns, starting at column 1. 0A (^J) Linefeed. A line ending character. 2-1 TED version 1.1, July 1980 0B (^K) Vertical tab. Currently not treated specially. 0C (^L) Formfeed. This character echos as ^L. It is treated as a line ending character, and as a page ending character (see data files and paging) 0D (^M) Carriage return. Returns the carriage or cursor to the beginning of the current line. ASCII code 1B is control-[, but it is commonly known as the escape character (ESC). Most keyboards have a special key labeled ESC or ALT (ALTMODE) which will produce this character. The escape character has many special uses in TED commands, as you will see. 2.2 Files TED operates on ASCII CP/M data files. File names are of the form d:filename.type d is the drive number. This may be a single alphabetic character or a single digit. Drive A corresponds to drive 0, etc. filename is the root name of the file, which may consist of 0 to 8 characters. type is the secondary file name, which may consist of 0 to 3 characters, and usually indicates the kind of data in the file (e.g., filename.TED would be likely to contain a TED macro, described later). As an editing convenience, TED sees files as being divided into one or more logical pages. Pages are recognized by the presence of a formfeed character (control-L), which marks the end of the page. When TED reads data into its editing buffer, it will stop if a page mark (FF) is encountered. The formfeed itself is never read into the buffer, but it is remembered and subsequently put into the output file. This will be described again later, in better context and more detail, but is presented here to introduce the concept. 2.3 The editing buffer 2-2 TED version 1.1, July 1980 As previously mentioned, TED uses the processor memory between the last byte of the program and the first byte of CP/M's BIOS as a text area. This area is the total space available for TED's text buffers, and is known informally as the buffer pool. Some amount of this space (0 or more bytes) is used as the current editing buffer, an area of text subject to editing. (For those of you who are interested, this does not mean to imply that the buffer remains in a fixed position or is a fixed size; the buffers in the buffer pool change a lot.) Since TED is a character oriented editor, methods of identifying characters are essential. Related to this is the concept of a buffer position, which describes any position in the buffer. Such a buffer position is always between two characters, and not directly on a character, thus they are boundary markers. The buffer position is specified as the number of characters to its left, and can be in the range 0 to Z, where Z (described later) is the number of characters in the buffer. You may notice that there is 1 more buffer position than there are characters in the buffer. There is a special buffer position known as the buffer pointer. This is a movable pointer (position) in the text buffer which locates the current editing point. Many editing commands affect the buffer at this position (for instance, text insertion is always done at the buffer pointer). The buffer pointer may be explicitly set by a number of commands, and is set as a result of many others (e.g., string search). The concept of buffer positions and the buffer pointer is essential to the understanding of this editor. Although TED is primarily a character oriented editor, some line handling facilities are provided. More precisely, some characters are recognized as line ending characters, and some commands can use this recognition to achieve line orientation. Some TED commands can be used as either line or character oriented commands. The determining factor in commands of this sort is the number of numeric arguments present: if only one argument is given, then line orientation is done; and if two, then character orientation. In this type of command, the notation m,n represents the character oriented argument, and n 2-3 TED version 1.1, July 1980 represents the line oriented argument. The specific interpretations m,n Specifies buffer positions m through n. For instance, 0,1 indicates the first character in the buffer; 8,27 indicate the 9th through 27th characters. Observe that n must not be less than m. n Specifies a number of lines. More precisely, this specifies the characters between the current buffer pointer and the buffer position after some number of line termination characters. There are two cases: If n is greater than zero, then the following n lines are indicated. If n is less than or equal to zero, then the preceding (-n)+1 lines (including the current one) are indicated. Thus a value of zero specifies the characters from the beginning of the line which the buffer pointer is in up to the buffer pointer. A note to the advanced reader: TED offers the user a large number of selectable editing buffers, each of which have their own buffer pointer. This will be discussed in more detail later in this manual. 2.4 Files and the buffer Editing text to be saved it done by manipulating text in the editing buffer and writing it out to a file. In most cases the process also involves reading text from an existing file into the editing buffer. Many files (this document, for example) contain too much data to fit into the editing buffer at once. In this case, the process is repeated so that it includes a process known as paging through the file, or just paging (not to be confused with paged files). Paging is the process of writing all of the text in the buffer to the output file, clearing the buffer, and reading text into the buffer from the input file. The part of paging which excludes writing to the output file is known as yanking: clearing the buffer and reading the next section from the input file. The terms paging and yanking will be used again. 2-4 TED version 1.1, July 1980 To make the process of paging easier, files may be divided into logical pages (such a file is said to be paged). Such pages should be fairly small so that each will fit into the editing buffer. Pages are separated by pagemarks, which are the formfeed character, and thus can be defined just by inserting a formfeed into the text. When a page is read into the editing buffer, the formfeed character is not included. However, the fact that it was there is remembered (and in fact may be tested by commands) so that it can be written out again when paging. 2.5 Commands Similar to the concept of the editing buffer is that of the command buffer. This is a buffer containing the group of commands last given by the user. TED executes each command in the buffer one at a time, starting from the beginning. Some more advanced commands exist to alter this command "flow", they are presented later. The commands are not executed until the command buffer has been filled by the user (see the section on entering commands). This buffer is emptied when the user begins to enter commands, thus its contents are quite volatile. Most commands are single characters, although some are two characters. Many commands exist only to modify subsequent commands, in that they represent some numeric value. Such commands can be considered as arguments, rather than commands, and in fact are generally described as such in the rest of this manual. (You may want to remember, however, that the number 345, when used as an argument to another command, is really the command "3", signalling a decimal number. Such thinking, though, is probably too literal to be useful.) As just implied, some commands take numeric arguments. Such arguments always precede the command. Some commands can be modified by more than one such argument, where this is true the arguments are separated by commas. A numeric argument can be any arithmetic expression. This is discussed in more detail later in this manual. Some commands can have text as an argument. Where this is so, the text always follows the command and is usually terminated by an escape character (ESC or ALTMODE). For example, the I command can be followed by text, the result being that the text will be inserted into the current editing buffer. It is possible that an error can occur while TED is executing 2-5 TED version 1.1, July 1980 commands. When this happens, TED will print a , a question mark, and a 3 character code indicating the type of error encountered. At this point, command processing is terminated, and the user must enter another command. For example: ?ILL indicates that TED has encounterd a character which is not defined as a legal command. A complete list of these error codes and their meanings is provided in an appendix. 2-6 TED version 1.1, July 1980 3.0 Invoking TED TED is run in the same way that all programs are run under CP/M. You must be at CP/M monitor level, having been prompted with d> where "d" is the name of the 'logged in' drive (see CP/M manuals if this isn't familiar). At this point, tell CP/M to run TED by typing t:TED followed by the carriage return. "t:" indicates which disk contains TED.COM, and may be omitted if it is the same as the logged-in disk, and will be omitted in further examples. This command causes TED.COM to be loaded and run. TED will print a message announcing itself, which will be followed by the prompt for commands (see the section Entering Commands). The alternate (and most usual) form of TED invocation is TED filename wherein you specify to TED that you want to edit the indicated file. TED will open this file for edit with backup if it exists, or cause the new file to be created if not (see EB). * The rest of this section is for advanced users * When TED is run, it builds and executes an initial command string. The actions taken by executing these commands are as follows: o Do an EQ command on the file TED.INI on the current disk. If this file does not exist, look for it on A:. (The effect of the EQ command is to load Q-registers from a file). o Execute the commands in Q-register 0. This is done so that the user can have special commands processed before any files are opened. o If a filename was specified, open it for edit with the EB command. 3-1 TED version 1.1, July 1980 o Execute the commands in Q-register 1. This is done so that the user can have special commands processed after any files are opened. o Clear the text from Q-registers 0 and 1. It is assumed that these were once-only command strings, and they may as well be emptied. The actual command string built by TED when no file is specified is :EQTED.INI$"U:EQA:TED.INI$'$M0$$M1$0,0X0 0,0X1$ The string built when a file (say TED.DOC) is specified is :EQTED.INI$"U:EQA:TED.INI$'$M0$EBTED.DOC$$M1$0,0X0 0,0X1$ 3-2 TED version 1.1, July 1980 4.0 Entering Commands As indicated earlier, interactive editing consists of these steps, which are continually repeated : o TED indicates readiness for command input by a prompt. o The user (you) fills the command buffer by typing commands. o TED executes these commands. This section presents the command input phase in detail. When TED is ready for commands, it signals this by printing onto the terminal a followed by its prompt character, which is a pound sign ("#"). The user is then able to enter commands. Commands are entered by simply typing characters, which are always appended to the end of the command buffer. (Just after the first character is entered, TED clears the old contents of the command buffer. The reason for the delay will be presented later.) The end of the command string is signaled by typing two consecutive escape characters, at which point TED will process the commands entered. Some characters cause immediate action, and are not (generallYy placed into the command buffer. These characters are thus command entry function characters, and are: ^G Control-G. This character is sometimes special, depending on what other character is typed next. As such, it signals a special function mode and is actually used to limit the number of characters reserved as function characters. The characters which have effect after control-G follow. ^G Control-G followed by control-G causes the command entry to re-start without executing the commands entered. It should be noted, however, that the characters which were entered remain in the command buffer until entry is started again. " " Conrol-G followed by a space causes the line which is currently being entered to be re-typed. 4-1 TED version 1.1, July 1980 "." Control-G followed by a period causes the entire command string being entered to be retyped. ^H Control-H, or backspace, backs up command entry by one character. This causes special action to actually remove the character from the screen. ^R Control-R is a quote character. It will cause the next character to be taken literally, and not as a special function character. The exceptions are rubout and backspace, which may not be quoted. The control-R character is also placed into the command buffer. ^U Control-U. Used if you don't like the line you are typing, this function removes the current line and lets you start it over. Note that after typing control-U, you can type one or two rubouts or backspaces and be on the previous line. Escape (ALTMODE). This is only significant if it follows another escape, in which state it indicates the end of command entry. Delete, or RUBOUT. This backs up command entry by one character, and prints the character removed. Some characters are treated as function characters under certain circumstances when given as the first character in the command stream. (It is to handle some of these functions that the command buffer is not cleared until AFTER the entry of the first command character.) These characters and circumstances are: Linefeed. This will cause TED to advance the buffer pointer by one line and display the following line on the terminal. In this manner the user can view the text in the editing buffer by stepping through the lines. ^H Backspace. This will cause TED to backup the buffer pointer by one line and display the following line on the terminal. * Asterisk. If the previously entered command is still in the command buffer, this character has effect. 4-2 TED version 1.1, July 1980 (This is for advanced users.) TED will wait for another character, which must be a valid Q-register name. The text is removed from the specified Q-register, and will be replaced by the contents of the command buffer. After this the command buffer will be empty. ? Question mark. This character has effect if the previous command terminated in an error, and causes all commands from the beginning of the buffer containing the erroneous command up to and including the command that caused the error to be printed. After one of these initial functions has been executed, command entry is restarted. The advanced reader may be interested to know that the command buffer is an unnamed Q-register. All command execution is therefore consistent, all command strings are in Q-registers. When a command is saved via the "*" initial character, the Q-register pointers, and not the text, are copied. This means that this function will never fail because of no available space. 4-3 TED version 1.1, July 1980 5.0 Basic Commands This chapter presents a set of basic editing commands. This set is all that is needed by the novice or uninterested (impossible!) user to edit files. Commands in this chapter are divided into the following groups: o Value commands o Buffer pointer positioning o Text viewing o Insertion and deletion o File control and exiting 5.1 Value Commands TED provides some commands which just represent values. Some of these commands are given here. 5.1.1 Buffer Positions The most useful of the value commands are those which represent buffer positions. B The first buffer position. Its value is always zero. It is included because it is part of DEC TECO's reportoire. Z Represents the number of characters in the editing buffer. . Period. This is the value of the current buffer pointer. H The H commands represents the value pair B,Z. It is used to specify all of the characters in the buffer. 5.2 Buffer Pointer Positioning The position of the buffer pointer is important to many editing commands, therefore methods of moving it are provided. 5-1 TED version 1.1, July 1980 Commands exist to specify the new position absolutely, relatively, and logically. 5.2.1 The J command The J command positions the buffer pointer at a specific place. The form is nJ where n is assumed to be 0 if it is omitted. The effect is to place the pointer at buffer position n. Thus 0J (or just J) moves the pointer to the beginning of the buffer; ZJ to the end, 5J to the position after the 5th character. n, if specified, must be within the range 0 to Z. 5.2.2 C and R The C command is used to move the buffer pointer to a relative position. Its form is nC where n is assumed to be 1 if it is omitted. This command advances the buffer pointer by n positions (n may be negative). An error (POP) will be given if an an attempt is made to move the pointer out of the buffer. The R command is the complement of the C command, moving the pointer backwards instead of forwards. Thus nR is the equivalent of -nC. 5.2.3 The L command The L command is a line oriented command which moves the pointer in a relative manner. Its form is nL where n is assumed to be 1 if omitted. The effect is to move the pointer to the position after the nth line mark after (before) the pointer. Relative line positions were discussed in the section on 5-2 TED version 1.1, July 1980 command formats. Essentially, if n is greater than zero, the pointer is advanced, if it is zero, it is moved to the beginning of the current line, and if it is negative, it is retreated. 5.2.4 Searching The search commands move the pointer in a fashion which was nebulously described as "logical". The effect is to find a sequence of characters in the text buffer which match a given pattern and to place the buffer pointer after that sequence. Searching is described in detail later in this manual, so it will be covered here only enough to make it usefull. There are 3 search commands: S, N and _ (underline or back-arrow). The form is the same for each, and is nSpattern$ where n is assumed to be 1 if omitted. If the search pattern is omitted, the pattern which was last given to a search command is used. The escape must always be present to indicate the end of the pattern. The effect of this command is to position the buffer pointer after the nth sequence of characters following the current buffer pointer which matches the specified pattern. If the search fails (the pattern cannot be matched n times) the buffer pointer is not changed. (Note that this is different than DEC TECO!) For the purpose of this chapter, the search pattern can be considered to be a sequence of characters which much be the same as the sequence of characters matched. Thus, if the buffer pointer is at the beginning of a buffer containing the text THIS IS A TEST and the command SIS A$ is executed, the buffer pointer will be positioned after the characters "THIS IS A" and before the characters " TEST". The N command is the same as the S command, except that TED will page through the files if necessary to find the string. If the search fails, the final buffer will have been written to the output file and the text buffer will be empty. 5-3 TED version 1.1, July 1980 The _ command is the same as the N command, except that TED will yank pages from the input file if necessary until the pattern is matched or the end of the file is reached. As with the N command, if the search fails the buffer will be empty. The numeric argument which precedes the S command may be negative, which will cause the search to proceed backwards through the buffer. This is not allowed with the other search commands. 5.3 Text viewing This section explains how to see text in the buffer. 5.3.1 The T command The T command displays on the user's terminal some portion of the text in the editing buffer. This is one of the aforementioned commands that can take either a line or character oriented form. For detail about these forms, see the section on command formats. m,nT Displays all of the text included between the specified buffer positions. nT Displays all of the text represented by the line argument n. If no arguments are given, 1 is assumed. 0,1T Print the first character in the buffer. 0T print the portion of the line which the contains the buffer pointer which precedes the pointer. 2T print the next two lines. 5.4 Insertion and Deletion This section describes how to enter text into the editing 5-4 TED version 1.1, July 1980 buffer from the terminal, and how to get rid of text that is already in the buffer. The concept of replacement is also introduced. 5.4.1 Insertion Entry of text from the terminal into the editing buffer is accomplished by either of 2 commands: I and ^I (TAB). The I command is of the form nItext$ where $ is an escape which must be present. If the numeric argument is present, then the first action of the I command is to insert, before the buffer pointer, the character whose ASCII value in n. This provides a way of inserting characters that are not available on your keyboard. The effect of Itext$ is to insert the given text immediately before the current buffer pointer (note that this moves the pointer). The TAB command is the same as the I command, except that the I is implicitly before the tab. That means that the tab character is also inserted into the buffer. Some special characters may be included in the insertion text that have an effect on what is inserted. These are presented in a later chapter. 5.4.2 Deletion Deletion of text is done by using one of the commands D or K. The D command deletes characters relative to the buffer pointer. Its form is nD where n is assumed to be 1 if omitted. The effect is to delete the next n characters after (or if negative, the next -n characters before) the buffer pointer. The pointer is left at the point of deletion. The K command is one of the dual mode commands, and thus has the following forms 5-5 TED version 1.1, July 1980 m,nK nK In both cases, the effect is to delete the specified characters. (For a description of these argument forms, see the treatment of line and character commands in the command format section.) The buffer pointer is always left at the point of deletion. 5.4.3 Replacement TED provides facilities to replace one string with another. These are the search-and-replacement commands FS, FN and F_, which corrrespond to the search commands S, N, and _. The difference between these commands is exactly the difference between the search commands, that is, how the string to be replaced is found. The basic form of the S&R commands is nFSpattern$text$ where n is assumed to be 1 if it is omitted. The $ characters shown indicate escapes (ALTMODEs). The effect is to search for the nth occurance following the pointer of the sequence of characters which match the search patter, delete that sequence of characters, and insert the text. 5.5 File Control and Exiting This section describes how to control file data, which includes paging and exiting. The assumption is made that novice users will edit files by issuing the command e commands that select files. Anyway, those commands are presented in a future chapter. When a file is edited in this manner, the original file is renamed to filename.BAK as a backup. For this section, file control refers to reading and writing data from and to files. 5.5.1 File Control 5-6 TED version 1.1, July 1980 Control of file data is accomplished by the commands A, EY, and P. The A command causes data to be read from the input file and appended to the end of the editing buffer. Data is read from the file until one of the following conditions occurs: o The end of the input file is reached o A page mark (formfeed) is encountered o After a linefeed is read, two thirds of the space that was available is filled. This helps prevent the buffer from filling up. o The buffer is nearly full (some small number of bytes left). Be careful that no numeric argument precedes the A command, for that changes its meaning (it isn't important yet to know to what). EY is the yanking command, it simulates the command sequence HKA; in other words, the buffer is cleared and data is read into the buffer. Any numeric argument is ignored. The P command takes two forms: m,nP Writes the characters between the buffer positions m and n to the output file. nP Performs n paging operations. The paging operation, you will remember, is writing the entire buffer to the output file (with a pagemark if it was there in the input file), and yanking another page from the input file. Expressed as a sequence of commands, the paging operation is HPEY. 5.5.2 Exiting There are 3 commands which cause TED to exit to CP/M. These are ^C, ^Z, and EX. The ^C (Control-C or up-arrow C) command causes TED to exit to 5-7 TED version 1.1, July 1980 CP/M immediately. No files are closed. The ^Z (Control-Z or up-arrow Z) command causes TED to close its output file (which means writing out the last partial sector and telling CP/M to close it) and exit to CP/M. The EX command causes a complete exit. The current buffer is written to the output file (if any), and the rest of the input file is appended to the output file. All files are closed and TED exits to CP/M. Part of the process of EX is to simulate an EF command. EF is discussed in a later section, but the following information is significant. When TED opens a file for output, it opens a file called filename.$$$, where filename is the name specified by the user. $$$ is used as the file type because that is the CP/M convention for temporary files. The EF processing includes renaming the original file to filename.BAK (as a backup) and renaming filename.$$$ to the desired name. 5-8 TED version 1.1, July 1980 6.0 File Selection and Control Normal use of TED (via TED filename) allows the editing or creation of a particular file. While this is the primary function of an editor, other things are sometimes desired. Alternate uses of an editor can include viewing a file (paged files and global searching make an editor the logical choice here), and copying parts of one file into another. To this end, TED provides commands to select and manipulate files. The commands discussed in this section are EB, ED, EF, EK, ER, EW, EX, A, ^P, and ^Y. Other relavent commands are EY and P, which were discussed in the chapter on basic commands. 6.1 File Selection This section describes the commands used to select files. Whenever a file is specified for output (EW, ED, EB), TED actually opens the file as filename.$$$, "filename" being taken from the user-specified name. When that file is closed, the original (if any) is deleted or renamed and the output file is renamed to its correct name. This prevents until the very last moment existing file from getting clobbered. Also, a file may not be selected for output unless there is currently no file already selected for output. This is not true of input files. It should be noted that TED remembers the name of the file last selected for input and for output, and that when you specify a file name, only the parts that you supply are changed. For example, if you had last selected the input file TED.ASM, you may then specify just ".DOC" to indicate the file TED.DOC. 6.1.1 The ER command The ER command selects a file for input. The form is ERname$ where "name" is a CP/M filename. If the file is found, it is selected for input. 6.1.2 The EW command 6-1 TED version 1.1, July 1980 The EW command selects a file for output. The form is EWname$ where "name" is a CP/M filename. If the file already exists, TED prints an advisory message to that effect to give the user a chance to not overwrite it. 6.1.3 The ED command The ED command allows the selection of input and output files by a single command. This command can take any of the forms EDfile$ EDoutfile=infile$ If the first form is used, the input and output files are the same. This command does an ER on the specified input file followed by an EW on the specified output file. 6.1.4 The EB command The EB command is the normal file editing command. It allows a file to be edited and specifies that the original file be renamed to .BAK so that it may be kept as a backup file. This command can take any of the forms EBfile$ EBoutfile=infile$ If the second form is used, this command functions exactly like the ED command and a backup file is not made. The two-filename form exists so that input and output files can be specified on the CP/M command line that invokes TED. 6.2 File Control This section describes commands which read and write file data. These commands are P, A, ^P, ^Y, and EY. P and EY have been presented in the basic commands chapter, they are not repeated here. 6.2.1 The A command 6-2 TED version 1.1, July 1980 Most of the A command was described in the basic commands chapter. One more form of the A command exists, the :A (colon followed by A) command. Its form is n:A where n is assumed to be 1 if it is omitted. This command causes n lines of text to be read from the input file and appended to the end of the editing buffer. 6.2.2 The ^P and ^Y commands ^P and ^Y (Control or up-arrow P and Y) are commands which are used to locate a particular logical page in the input file (as determined by the pagemarks). They are the same except that ^P pages through the files, whereas ^Y only does yanks (no output). l to the number of pages in the file, otherwise an error message will be printed and command execution terminated. 6.3 File Termination This section presents the commands which are used to terminate files. These commands are EF, EK, EX, and ^Z. ^Z has already been described in the basic commands chapter. 6.3.1 The EF command The EF command causes the orderly closing of the output file. The sequence of operations caused by this command is o Write the last partial sector to the output file. (TED buffers file output in a sector-sized buffer, this operation just writes what was intended to have been written.) o Tell CP/M to close the output file. o If the backup flag is set 6-3 TED version 1.1, July 1980 (i.e., an EB was done) then the original file is renamed to .BAK after deleting any old .BAK file. If the backup file is not set, delete the original file. o Rename the output file (filename.$$$) to its intended name. 6.3.2 The EK command The EK command causes the output file to be erased. This is used to abort an edit. The action taken is just to close the output file and delete it (remember that the output file has a temporary name). 6.3.3 The EX command" The EX command causes the current buffer to be written to the output file, the rest of the input file to be written to the output file, an EF command to be executed, and TED exits (to CP/M). 6-4 TED version 1.1, July 1980 7.0 Q-registers TED maintains many buffers within its buffer pool, some invisible to the user, and some not. Text Q-registers are buffers which are each named by a single character and are all accessable by the user for text storage. Numeric Q-registers are named values which may be set and examined by various commands. This chapter lists the commands which deals with Q-registers. There are 42 named Q-registers and one unnamed one. (The unnamed one is the command buffer.) Q-register names are all of the characters whose ASCII values are 30 through 5A ("0" through "Z"), inclusive. Specifically, the names are "0"-"9", ":", ";", "<", "=", ">", "?", "@", and "A"-"Z". This chapter presents the following topics: o The editing buffer o Text manipulation o Macros o Numeric Q-registers o The Q-register stack 7.1 Buffer Selection One of the major features of TED is the ability to edit q-registers individually. This is accomplished by the fact that the editing buffer is a Q-register, and that the Q-register which will serve as the editing buffer is user-selectable. Each Q-register has associated with it the current buffer pointer, so that the pointer position is not lost by switching between Q-registers. TED's default editing buffer is Q-register @. The commands that deal with editing buffer selection are EA, EE, FA, and FE. 7.1.1 The EE command 7-1 TED version 1.1, July 1980 The EE command selects an editing buffer. Its form is EEx where x is the name of a Q-register. 7.1.2 The EA command The EA command selects an editing buffer temporarily. Its form is EAx Setting an editing buffer temporarily means that the specified buffer is selected for editing, but at the completion of command execution (that is, when a command is next prompted for) the editing buffer is reset to its last permanent setting. 7.1.3 The FE command The FE command is used to determine or to select the editing buffer. Its forms are FE nFE When used without an argument, FE returns the ASCII value of the name of the Q-register that is the permanently selected editing buffer. When used with an argument, FE selects as the editing buffer the Q-register whose name's ASCII value is given as the argument. E.g., 65FE selects Q-register A as the editing buffer. 7.1.4 The FA command The FA command is to FE as EA is to EE. Its forms are FA nFA When used without an argument, FA returns the ASCII value of the name of the editing buffer which is currently selected. 7-2 TED version 1.1, July 1980 When used with an argument, FE selects as the temporary buffer the Q-register whose name's ASCII value is given as the argument. 7.2 Text manipulation Text Q-registers are useful in manipulating text. Text can be copied from a Q-register into any point in the editing buffer, and from any area of the editing buffer into a Q-register. This provides the capabilities of rearranging and duplicating text. The commands which accomplish text moving are X and G. 7.2.1 The X command The X command is one of the dual-mode (line and character) commands whose arguments are described in the command formats chapter. Its forms are m,nXx nXx where x is a valid Q-register name. If no numeric argument is given, a 1 is assumed. The effect of this command is to delete any text that may have been in the specified Q-register, and to copy the indicated text into that Q-register. For example, 2XA puts the next two lines of text (starting at the buffer pointer) into Q-register A; 0,2X0 puts the first two characters in the buffer into Q-register 0. 7.2.2 The G command The G command copies all of the text from a Q-register into the editing buffer. Its form is Gx where x is a valid Q-register name. The effect is to copy the Q-register's text into the editing buffer behind the current buffer pointer. This causes the pointer to be moved down by the number of characters copied. 7.3 Macros An interesting and very useful quality of text Q-registers is that the text in any Q-register (except the editing buffer) can be 7-3 TED version 1.1, July 1980 executed as command strings. Text used in this manner is called a macro, because a single command can cause the macro to be executed. The commands which relate to macros are M, W, EP, EI, and EQ. The EP and EQ commands were described in the Text Q-register section. 7.3.1 The M command The M command causes the execution of the commands in a particular Q-register. Its form is Mx where x is a valid Q-register name which is not the current editing buffer. The effect is that the text in Q-register x is executed. When the entire Q-register text has been processed, command execution resumes at the point after the M command; thus this functions as a sort of subroutine call. These "calls" may be nested to 15 levels. 7.3.2 The W command The W command also causes the execution of Q-register text. Its form is Wx where x is a valid Q-register name which is not the current editing buffer. This, like the M command, causes the Q-register text to be executed; however flow does not return to the point after this command. Instead when the end of the Q-register has been reached, command processing will resume at the point where it would have had the end of the command string containing the W command had been reached. In other words, this is a Jump to Q-register, rather than Call Q-register, command. 7.3.3 The EP and EI commands As mentioned earlier, the EP command loads text from a file into Q-register "?". Its form is EPfile$ The EI command combines the EP and M command. Its form is EIfile$ 7-4 TED version 1.1, July 1980 and causes Q-register "?" to be loaded from the specified file, and that macro executed as with an M command. 7.4 Numeric Q-registers TED also has a complete set of Q-registers for storage of numeric values. These correspond (by name) to the text Q-registers. The commands described by this section are U, Q, and %. 7.4.1 The U command The U command stores a value into a numeric Q-register. Its form is nUx where n is a complete numeric value and x is a valid Q-register name. The effect is to store the value n into Q-register x. 7.4.2 The Q command The Q command examines a numeric Q-register. Its form is Qx where x is a valid Q-register name. This command is used as a numeric value, and represents the value stored in the indicated Q-register. 7.4.3 The % command The % command adds a value to a Q-register. Its form is n%x where n is assumed to be 1 if omitted, and x is a valid Q-register name. The effect is to add the value n to the contents of the specified Q-register, storing the result in that Q-register, and returning the result as the value of the command. Thus this command can be used not only as a functioning command, but also as a value. 7.5 The Q-register stack 7-5 TED version 1.1, July 1980 Associated with the set of Q-registers is the Q-register stack, which allows Q-register contents to be preserved temporarily. This stack can contain the contents of up to 35 Q-registers, which are pushed onto the stack and retrieved in the reverse order as put on. The stack is useful in writing TED macros, in that any Q-registers used by a macro can be saved by the macro. Both the text and numerical contents of a Q-register are stored on the stack. The contents of the Q-register stack are temporary. When a Q-register is pushed, TED remembers which Q-register it came from. If, when TED returns to ask the user for another command, this stack is not empty, each entry on the stack is popped back to its original owner. The commands dealing with the Q-register stack are [ and ]. 7.5.1 The [ command The [ command pushes the contents of a Q-register onto the Q-register stack. Its form is [x where x is the name of a Q-register that is not the current editing buffer. The effect is to save the text and numerical value contained by the indicated Q-register on the Q-register stack, and to clear the text from that Q-register. 7.5.2 The ] command The ] command pops an item from the Q-register stack. Its form is ]x where x is the name of a Q-register which is not the current editing buffer. The effect is to replace both the text and numerical contents of the specified Q-register with those that are at the top of the stack (the last pushed that was not popped). 7.5.3 General The Q-register stack can be used for at least the following three purposes: 7-6 TED version 1.1, July 1980 o Ensuring the integrity of Q-registers around macros o Exchanging or copying Q-register data. E.g., [A]B copies Q-register A to Q-register B; [A[B]A]B exchanges A and B. o Aiding in recursive macros. This is really not a separate purpose; it is a use of Q-register integrity insurance. A macro is presented in the Examples appendix which outputs a number in binary which uses the stack in this manner. One interesting use of the Q-register stack is that a executing macro can push itself. Suppose you wanted to write a single macro which could be invoked with the EI command that would load several different Q-registers from separate files. The easiest way to do this would be to use the EP command, but that uses the "?" Q-register. The command sequence [? EPA.TED$ [?]A EPB.TED$ [?]B EPC.TED$ [?]C ]? accomplishes this. It first pushes the Q-register that contains itself, and loads the files A.TED, B.TED, and C.TED into Q-registers A, B, and C, respectively. The final step is to pop the macro back into Q-register "?". 7-7 TED version 1.1, July 1980 8.0 Values Except for a brief reference in the introductory chapter to expressions, values have been presented to this point as single numeric commands (e.g., 345 is the number 345, Z is the number of characters in the buffer). This chapter describes the combination of numeric and operation commands into expressions, and introduces the concept of partial and complete values. 8.1 Multiple values Multiple values may be given to TED commands by separating the values with a comma. The presence of a comma is interpreted by TED as a break in the expression, rather than a new value. Thus if a TED command accepts a single numeric argument where two were given, the expression reverts to the point immediately preceding the comma. 8.2 Expressions TED supports complete arithmetic expressions as numeric values. 8.2.1 Classes of commands This section presents classifications of commands with respect to the contribution they have on expressions. 8.2.1.1 Value commands Value commands are commands which represent a value. E.g., Z, :S, ET, ^P, etc. If two such commands appear sequentially, the second value overwrites the first. Thus 4+2 5 returns 9 (being 4+5). Value commands may also take numeric arguments (usually a partial value, read on). One is example is the nA command, which returns the ASCII value of the nth character after the buffer pointer. The value returned by such a command replaces the value (or values) taken. 8.2.1.2 Operator commands Operator commands are commands which perform operations on values within an expression. In other words, such a command combines with the following value and possibly the preceding value 8-1 TED version 1.1, July 1980 to represent some composite value. The value returned replaces the value or values that it operates on. Unlike DEC TECO, TED performs operator precedence arithmetic. That means that some operators are more important than others (have precedence) and get applied first. In the expression 3+4*5 the multiplication ("*") is considered to have precedence over the addition ("+") and is performed first; thus the value of the expression is 23, and not 35. Parentheses may be placed around operations (and their values) in order to give them artificial precedence, e.g., (3+4)*5 returns 35. Operator commands and their priorities are given in an appendix. 8.2.1.3 Value arrangement Some commands exist just to provide grouping of values. These are parentheses ("(" and ")") and the comma (","). The comma is used to separate values, and was described earlier in this chapter. Parentheses indicate parts of an expression which are to be treated as a single value. The effect is that the part of the expression within parentheses must be calculated before it can be combined with another value by an operator. This is why parentheses can be used to override operator precedence rules, that in fact is their main purpose. 8.2.1.4 Value Clearing Some commands "clear" TED's value and expression memory. Any expression which is outstanding at the time of the execution of one of these commands is lost. This includes multiple values separated by commas. 8.2.1.5 Invisible Commands 8-2 TED version 1.1, July 1980 Some commands are either completely or partially invisible to expressions. Examples of completely invisible commands are the space command and the M command. The expression is in the same state after the execution of an invisible command as it was before. A partially invisible command is one that takes a numeric argument but does not clear the expression. One example is the U command. The U command takes a complete value (see partial vs complete values, later) but does not destroy any others. The sequence 7,1U0+5 is evalued as 12. The U command takes the 1 immediately before it and leaves the value 7. When 5 is added to this, the result is 12. This can be useful in passing multiple values to macros. Suppose the macro in Q-register M begins with +0U2 +0U1 +0U0 The command 4,5,6MM would then immediately result in the numbers 4,5, and 6 being put into Q-registers 0,1, and 2, respectively. (The "+0" in front of each U command is there to ensure that some value exists for the U command to take; it is an error if there is none.) 8.3 Partial vs complete values Some casual reference has been made to partial and complete numeric values. The terms are used to identify how much of the preceding expression a given command uses as an argument. 8.3.1 Complete values A command that takes a complete numeric value uses the entire expression which precedes it, or that portion which follows the last comma. The one rule of complete expressions is that no unmatched parentheses may exist. For example, 5+Q0U1 commands TED to store into Q-register 1 the value 5 plus whatever number is contained in Q-register 1. Another example, (5+Q0U1) would cause an error, since the expression is not 8-3 TED version 1.1, July 1980 complete before the U. However, the following (2,5+Q0U1) is a valid expression, returning 2, because of the fact that U does not clear the entire expression, but only back to the comma. If it were not U, but an expression clearing command, for example (2,5+Q0C) then the expression is illegal because there is an outstanding parenthesis at the time the expression is cleared (note that the C would have been executed). 8.3.2 Partial values A command which takes a partial value uses only that part of the expression preceding it which follows the last outstanding expression grouping command, which is to say that part of the expression which follows the last comma or open parenthesis. Partial values are used by some commands which both take and return a numeric value. Such a command is the % command, which adds a number to the contents of a numeric Q-register, storing and returing the value. Suppose that Q-register 0 contains the number 5. In the expression 2*7%0 the % command uses the expression 2*7 which precedes it, adds that (14) to the 5 contained by the Q-register, yielding 19, which is storing in the Q-register and also returned to the expression. The value of the expression is then 24 also. However, 2*(7%0) returns 24, because the argument to the % command is 7, which gives 12 when added to the 5 contained by the Q-register. The value 12 is stored in the Q-register, and also returned to the expression, where it is mulitplied by 2 to yield 24. A command which takes a partial value does not, therefore, require that an expression be complete before the command. 8-4 TED version 1.1, July 1980 Some TED commands specify that some command other than the one next in the command stream be executed. These commands alter the flow of control, so to speak, and help to make TED a programming language and not merely an editor. Types of flow control are o Iterations o Conditional execution o Branching Macros are not strictly flow control, they are treated more as command substitution. At any rate, they have already been described. 9.1 Iterations TED allows iterations; which is to say that parts of a command string may be executed repeatedly. The string may be repeated a specified number of times. There is also a command for terminating an iteration. Iterations have a peculiar effect on search commands. Any search command which does not succeed and which is contained in an iteration will not cause TED to give an error message or to stop - it simply fails. This, along with the definition of the ";" command, allows repetitive use of the search feature. 9.1.1 Iteration format - < and > Iteration is specified by enclosing a command string in angle-brackets. The form is n< ... > This causes the command string within the angle brackets to be executed n times (if n is omitted, the loop is performed 65,536 times). Iterations may be nested. Thus, the command 2<3 4> causes 2 iterations of the inner command string 9-1 TED version 1.1, July 1980 3 4 The result is the same as typing AAALTLTLTLTAAALTLTLTLT An iteration must end in the same command buffer that it begins in. This means that angle-brackets must be matched within macros. 9.1.2 The ; command Sometimes it is desirable to iterate some indefinite number of times, stopping only when a particular condition is met. This occurs most frequently when replacing all occurances of a given string with another string. The ";" command allows this goal to be achieved. Under the proper circumstances, this command causes the commands between it and the next right-angle bracket (which does not match a left-angle bracket following the command) to be skipped, thus terminating the iteration which immediately contains the command. Its forms are n; ; If a numeric argument preceds the command, then the iteration will be exited if the number is not less than zero (this quality of numeric value will be referred to again under conditionals). If no number precedes the command, then the iteration will be terminated if the last search failed. Thus the command will replace all occurances of "mumble" with "grumble". The ";" will cause the iteration to terminate when the search fails. 9.2 Conditional execution A useful feature of programming languages is the ability to perform conditionally. TED's conditional command execution allows commands to be executed or not executed depending on numeric values. Conditional command strings have the form 9-2 TED version 1.1, July 1980 n"c ... ' The ellipses represents a the command string. The effect of the " command is that all commands up to the next matching ' may be skipped, depending on the value of n and of the conditional control character "c" (n must be supplied). The control characters, and the conditions (value of n) under which the conditional command string is executed, are as follows: A n is the ASCII value of an alphabetic (upper or lower case) character C n is the ASCII value of an alphabetic character, a digit, or one of the characters "$", "%", "." D n is the ASCII value of a decimal digit ("0"-"9") G n is greater than zero H n is the ASCII value of a hexadecimal digit L n is less than zero N n is not zero S n represents a successful value U n represents an unsuccessful value V n is the ASCII value of a lowercase character W n is the ASCII value of an uppercase character Some TED commands, when preceded by a colon, return (numerically) a successful or an unsuccessful result. These commands will be discussed in a later chapter, however the value is presented here. A successful value is one that is less than zero; unsuccessful one that is not less than zero. 9.3 Branching TED supports unconditional change of control by allowing labels to exist in the command string. These labels may be referenced as a transfer point. Branching is most useful (probably ONLY useful) with conditional commands, described elsewhere. 9-3 TED version 1.1, July 1980 9.3.1 The ! command The ! command begins a command string label. Its form is !label! All characters within the two exclamation points are part of the label, which essentially defines a position in a command buffer. Labels may also be used for commenting a macro, since they have no effect on the commands around them. (Note that, relating to expressions, they are invisible.) 9.3.2 The O command The O command specifies an unconditional branch within a command buffer. Its form is Olabel$ where the "$" character is an escape (ALTMODE). This will cause command execution to begin at the specified label (as defined by "!"). Some restrictions on the use of unconditional branching are o Branching can not be used across command buffers. The label must be defined in the same buffer (macro level) that it is referenced in. o Branching should not be used to exit iterations. It may work, but don't count on it. In the same light, branching should not be used to ENTER an iteration. 9-4 TED version 1.1, July 1980 10.0 Advanced Insertion Simple text insertion was presented in the introductory commands chapter. This section describes special characters in the insert string, as well as introduces some new insertion commands. 10.1 Numeric value insertion 10.1.1 N\ and n\\ It is sometimes useful to insert some number into the editing buffer. The commands n\ and n\\ provide this capability. (These commands NOT preceded by a numeric value were described in the chapter on values.) The n\ command causes the insertion of the string of digits which represents the value n, in decimal. n\\ causes the insertion in hexadecimal representation. Like the I and commands, the insertion is done immediately before the buffer pointer, so that the pointer is moved forward. 10.2 Special insert string characters Some characters in the string following an I or command have special effect. These characters and effects follow. ^V Control-V. This forces the next character, if it is alphabetic, to be inserted as a lower case character. ^V^V Two successive control-V characters force all following alphabetic characters in this insert string to be inserted as lower case. This does not apply to explicitly modified characters. ^W Control-W. This forces the next character, if it is alphabetic, to be inserted as an upper case character. ^W^W Two successive control-W characters force all following alphabetic characters in the same insert string to be inserted as upper case. This does not apply to explicitly modified characters. ^R Control-R. Causes the next character to be taken literally (used primarily to insert an escape 10-1 TED version 1.1, July 1980 character). 10-2 TED version 1.1, July 1980 11.0 Advanced Searching The search commands were presented in the chapter on introductory commands. Therefore you know that a search command causes TED to find a string of characters in the editing buffer which matches a specified pattern. What you may not know, however, is that the search pattern can contain some characters which cause special matching to occur. The special characters, and their matching qualities, follow. ^EA (Control-E followed by A) Match any alphabetic character. ^ED Match any decimal digit ("0" - "9") ^EH Match any hexadecimal digit ^EV Match any lowercase character ^EW Match any uppercase character ^Nx Match any character EXCEPT x ^R Match the next character exactly (even ESCAPE). ^S Match any character except alphabetics, digits, and the characters "$", "%", and "." (see "C conditional). ^V Force the next character, if alphabetic, to match only its lowercase equivalent. ^V^V Force all alphabetic characters (unless modified) to match only their lowercase equivalent. ^W Force the next character, if alphabetic, to match only its uppercase equivalent. ^W^W Force all alphabetic characters (unless modified) to match only their uppercase equivalent. ^V^W Reset alphabetic matching to either-case ^W^V Reset alphabetic matching to either-case ^X Match any single character. 11-1 TED version 1.1, July 1980 11-2 TED version 1.1, July 1980 12.0 Miscellaneous Advanced Commands 12-1 TED version 1.1, July 1980 Appendix A - Alphabetic Summary of Commands A-1 TED version 1.1, July 1980 Appendix B - Topical Summary of Commands B-1 TED version 1.1, July 1980 Appendix C - Error messages The following is a list of the 3 character error codes and the meaning of each. ARG Argument error CCT Cannot close temp output file EBC Edit attempted before closing output file. EBO EB is ongoing ENT Cannot create a file FNF File not found. FUL Buffer is full ICE Illegal ^E search operation ICO Illegal conditional operator. IEC Illegal character after E. IFC Illegal character after F. IFN Illegal file name ILL Illegal command IPN Illegal page number (^P, ^Y) IQN Illegal Q-register name ITD Iterations nested too deep MAP Missing apostrophe MDL Missing delimiter. In a text argument to an @-modified command, no leading delimiter is found. MLA Missing left angle-bracket MLP Missing Left Parenthesis C-1 TED version 1.1, July 1980 MQT Missing double quote. MRA Missing right angle-bracket MRP Missing Right Parenthesis MTD Macros nested too deeply NAC No argument to conditional. NAE No argument before = NAU No argument before U NER Not enough room in memory NFI No file for input NFO No file for output. OER Output error POP Attempt to move pointer off of page. QSO Q-register stack overflow SLF Second argument less than first SNA Initial search with no argument SNI Semicolon not in iteration SRH Search failed STL Search string too large TAG Can't find referenced tag (Otag$) TQR May not use text Q-register UCA Unterminated Control-A command UTT Unterminated tag. C-2 TED version 1.1, July 1980 C-3 TED version 1.1, July 1980 I-1 TED version 1.1, July 1980