Digital PDFs
Documents
Guest
Register
Log In
AA-D029B-TE
March 1980
142 pages
Original
5.7MB
view
download
Document:
VAX-11 Text Editing Reference Manual
Order Number:
AA-D029B-TE
Revision:
000
Pages:
142
Original Filename:
OCR Text
VAX-11 Text Editing Reference Manual Order No. AA-00298-TE March 1980 This document describes the features and use of SOS, an interactive textediting program provided with VAX/VMS. VAX-11 Text Editing Reference Manual Order No. AA-00298-TE SUPERSESSION/UPDATE INFORMATION: This revised document supersedes the VAX-11 Text Editing Reference Manual (Order No. AA-D029A-TE) OPERATING SYSTEM AND VERSION: VAX/VMS V02 SOFTWARE VERSION: VAX/VMS V02 To order additional copies of this document, contact the Software Distribution Center, Digital Equipment Corporation, Maynard, Massachusetts 01754 digital equipment corporation · maynard, massachusetts First Printing, August 1978 Revised, March 1980 The information in this document is subject to change without notice and should not be construed as a commitment by Digital Equipment Corporation. Digital Equipment Corporation assumes no responsibility for any errors that may appear in this document. The software described in this document is furnished under a license and may only be used or copied in accordance with the terms of such license. No responsibility is assumed software on equipment that affiliated companies. Copyright for the use or reliability of is not supplied by DIGITAL or its © 1978, 1980 by Digital Equipment Corporation The postage prepaid READER'S COMMENTS form on the last page of this document requests the user's critical evaluation to assist us in preparing future documentation. The following are trademarks of Digital Equipment Corporation: DIGITAL DEC PDP DEC US UNIBUS COMPUTER LABS COMTEX DDT DECCOMM ASSIST-11 VAX DECnet DATATRIEVE DECsystem-IO DECtape DIBOL EDU SYSTEM FLIP CHIP FOCAL INDAC LAB-8 DECSYSTEM-20 RTS-8 VMS !AS TRAX MASSBUS OMNIBUS OS/8 PHA RSTS RSX TYPESET-8 TYPESET-11 TMS-11 ITPS-10 SB! PDT CONTENTS Page PREFACE vii SUMMARY OF TECHNICAL CHANGES ix CHAPTER 1 INTRODUCTION TO SOS 1-1 1.1 1.4 1.5 INITIATING AND TERMINATING SOS CONTROL CHARACTERS USE OF ESCAPE USE OF DELETE UPPER- AND LOWERCASE CHARACTERS 1-2 1-2 1-3 1-3 1-4 2 MODES OF OPERATION 2-1 2.1 2.3 2.4 2.5 2.6 2.7 INPUT MODE READ-ONLY MODE EDIT MODE COPY-FILE MODE DECIDE MODE ALTER MODE ALTER/INSERT MODE 2-2 2-3 2-3 2-5 2-5 2-6 3 LINE NUMBERS, PAGE NUMBERS, AND RANGES 3-1 3.1 3.2 LINE NUMBERS PAGE NUMBERS POSITIONS RANGES OF LINE NUMBERS SHORTHAND CHARACTERS THE CURRENT POSITION DEFAULTS FOR LINE AND PAGE NUMBERS LINE-NUMBER AND PAGE-NUMBER OFFSETS HOW SOS NUMBERS NEW LINES 3-1 3-1 3-2 3-2 3-3 3-4 3-4 3-6 3-7 3-8 3-8 3-8 1. 2 1.3 CHAPTER 2.2 CHAPTER 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.9.1 3.9.2 3.9.3 CHAPTER CHAPTER The Current Line-Number Increment When an Existing Line Intervenes Input Mode versus Alter/Insert Mode 2-6 4 USING SOS 4-1 4.1 4.2 4.3 4.3.1 4.3.2 4.3.3 4.3.4 DEFAULT CONDITIONS WHEN SOS IS INITIATED LIMITATIONS AND RESTRICTIONS USING SOS SAFELY 4-1 4-1 4-2 4-2 4-2 4-2 Built-in Safety Features The Save World Command Two Options for Automatic File Saving Recovering Information from Temporary Files: An Example 4-3 5 EDIT-MODE COMMANDS 5-1 5.1 5.2 5.2.1 ALTER (A -- ALTER MODE) COPY (C) 5-4 5-18 5-20 Copy-file Mode iii. CONTENTS Page 5.3 5.4 5.5 5.5.l 5.6 5.7 5.8 5.9 5.10 5 .11 5.12 5.13 5.14 5.15 5.15.l 5.15.2 5.15.3 5.10 5.17 5.18 5.19 5.20 5.21 5.22 DELETE (D) END ( E) FIND (F) 5-22 5-23 5-25 5-27 5-29 5-30 5-33 5-34 5-35 5-36 5-37 5-39 5-41 5-43 5-45 5-45 5-46 5-47 Find Options HELP (H) INPUT (I -- INPUT MODE) JOIN (J) KILL PAGE MARK (K) LIST (L) MARK (M) RENUMBER (N) PRINT (P) REPLACE (R) SUBSTITUTE (S) Multiple Substitutions Substitute Options Decide Mode TRANSFER (T) SAVE WORLD (W) EXTEND (X) MOVE POSITION (.) GIVE PARAMETER (=) SET PARAMETER (/) EXECUTE COMMAND FILE (@) 5-50 5-51 5-53 5-54 5-55 5-56 6 SOS PARAMETERS AND SWITCHES 6-1 6.1 6.2 6.3 PARAMETERS SWITCHES SETTING DEFAULT CONDITIONS USING SYMBOL ASSIGNMENT 6-3 6-10 7 SPECIAL CONSTRUCTS AND CHARACTERS 7-1 7.1 7.1.l 7.1.2 7.1.3 7.2 7.3 SPECIAL PATTERN-MATCHING CONSTRUCTS SPECIFYING RANGES BY CONTENT SOS SPECIAL CHARACTERS 7-1 7-2 7-5 7-6 7-6 7-9 8 SOS INTERNALS 8-1 8.1 8.1.l 8. l . 2 8.2 8.3 TEMPORARY FILES FORMAT OF TEXT LINES AND PAGE MARKS USING SOS EFFICIENTLY 8-1 8-1 8-2 8-2 8-3 APPENDIX A SUMMARY OF SOS FUNCTIONS AND FEATURES A-1 APPENDIX B SOS ERROR MESSAGES: B-1 CHAPTER CHAPTER CHAPTER '1-14 Find-String Constructs Substitute-String Constructs Combining Find-String Constructs Wraparound The Save World Command NOVICE AND EXPERT FORMS Index-1 INDEX iv CONTENTS Page FIGURES FIGURE 3-1 5-1 5-2 How SOS Calculates the Numbers of New, Inserted Lines Alter-Mode Example Transfer Operation to Move Part of a File to Another Location 3-10 5-7 5-48 TABLES TABLE 2-1 3-1 5-1 5-2 5-3 6-1 6-2 7-1 7-2 A-1 A-2 A-3 A-4 A-5 A-6 A-7 A-8 A-9 B-1 Edit-Mode Commands: Form and Function Defaults for Line and Page Numbers Edit-Mode Command Summary Alter-Mode Commands Decide-Mode Commands SOS Parameters SOS Switches Special Pattern-Matching Constructs SOS Special Characters SOS Modes of Operation Edit-Mode Commands: Function and Format Meaninis of Edit-Mode Command Options Alter-Mode Commands Decide-Mode Commands sos Parameters SOS Switches Special Pattern-Matching Constructs Position Shorthand Characters SOS Error Messages: Novice and Expert Forms v 2-4 3-5 5-3 5-5 5-46 6-2 6-2 7-2 7-10 A-1 A-2 A-4 A-4 A-n A-6 A-7 A-8 A-8 B-1 PREFACE MANUAL OBJECTIVES This manual is designed as a reference for users who have had some exposure to text-editing computer programs. It is not intended as a tutorial introduction, either to text editors in general or to the SOS editor in particular. INTENDED AUDIENCE If you have read the introduction to SOS in the VAX/VMS want to know more about SOS, this is the manual for you. Primer and If you are familiar with some other text editing program either a DIGITAL text editor or another -- you can use this manual to gain familiarity with sos. The tables and figures will prove helpful in this familiarization. Later, you can study this manual to learn details of SOS commands and features. ASSOCIATED DOCUMENTS The following documents may also be useful. • VAX-11 Information Directory and Index e VAX/VMS Primer CONVENTIONS USED IN THIS MANUAL In examples of user-system dialog, the text that you type red. For example: appears in *P500:700 This means that after the SOS prompt (*) you type P500:700 followed by a carriage return. The examples in this manual do not show the <RET> symbol when it is used as a command line terminator. The following symbols represent special keys on the terminal keyboard: ®9 The escape key (labeled ESC, ALT, SEL, or PRE, depending on the terminal) vii ffi) The carriage return key (labeled CR or RETURN) C® The delete key (labeled DEL, RUB, or CAN) (ill The line feed key @ The space bar @ID The tab key or <CTRL/I> (see below) @ The backspace key The following symbols stand for various control functions, which you initiate by pressing the given key while holding down the CTRL key. Section 1.2 discusses these control functions. (CTRL/CJ tTRL/S) t!fillJ ~ ~Q) ~ tIBQB.J ~ Brackets [] indicate optional parts of an argument within a particular command string. The exceptions to this convention are directory and file specification, in which one set of brackets must be typed. viii SUMMARY OF TECHNICAL CHANGES The following changes have been made Reference Manual for Version 2.0. to the VAX-11 Text Editing 1. SOS is now the only editor that is documented in this manual. All information about the batch-oriented editor SLP has been made part of the VAX-11 Utilities Reference Manual. 2. The following new features have been added to editor: the SOS text a. The sequence of characters <CTRL/A> <ESC> which allows you to change from Input mode to Alter mode. This new feature is described in Chapter 5. b. The new switch /NUMBERS, which controls the printing of line numbers. This new feature is documented in Chapter 6. ix CHAPTER l INTRODUCTION TO SOS SOS is a line-oriented, interactive text-editing program. Using it, you work on line to the computer, carrying on a dialogue with the program as you create or modify a file. (SOS stands for SON OF STOPGAP, an earlier editor.) Unlike many line-oriented editors, SOS has features that allow you to examine and change text, character by character. You can use SOS to perform the following functions: • Examine, create, and modify ASCII text files • Search for and/or change one or more arbitrary text strings, with the option to verify each change before it is made • Merge parts of one file into another • Create a file that is a subset of another file SOS is line-oriented, so it works with line-numbered text files. If you edit a file that does not have line numbers, the editor adds line numbers to the text lines. When SOS writes your file to disk, it includes the line numbers unless you specifically request that it omit them. SOS requires you to be concerned with line numbers within the file. For most SOS commands, a line number or a range of line numbers specifies the text to be operated on. When you insert, delete, move, or copy text, SOS is programmed to keep line numbers in ascending order within each "page" of text. To this end, SOS may refuse to accept more inserted text, or insert "page marks," or warn you to renumber the lines in the file. SOS is more interactive than many other editors. In some modes of operation, it responds on a character-by-character basis to what you type. This degree of interactivity may be new to some users accustomed to less interactive editors, which always expect a command line terminated by a carriage return. For example, one SOS feature that exhibits this character-by-character intera~tivity is Alter mode. This special mode lets you make changes within a line of text, interactively. Alter mode has its own commands and syntax; it functions essentially as an editor within an editor. This mode is discussed in detail in Section 5.1. Advanced features of SOS allow you considerable flexibility in searching for a string of text (see Section 7.1) and allow you to specify blocks of text by content, instead of by line number (see Section 7.2). Many SOS parameters and switches, which you can set, control editor's default values. (See Section 5.21 and Chapter 6.) 1-1 the INTRODUCTION TO SOS 1.1 INITIATING AND TERMINATING SOS SOS is invoked by the DCL command EDIT. Initiate SOS by typing one of the following commands in response to the DCL prompt: $ EDIT $_File:file-sPec or $ EDIT file-sPec $ EDIT/OUTPUT=output-file-sPec file-spec or In the first form above, SOS prompts you for the specification of the file you want to edit or create. {See the chapter on file manipulation in the VAX/VMS Primer for an introduction to file specifications.) In the second form, you explicitly type the the file does not exist, SOS creates it. file specification. If In the third form, you specify both the file you want to edit and the file to which you want the edits to be written. If you do not designate a file name or file type in the output file specification, SOS defaults to the file name and type of the input file. In the second and third forms above, you can optionally append qualifiers, separated by slashes {/),to the file specification. There are several ways to terminate SOS; they are discussed in detail under the End command {E) in Section 5.4. Usually, you give the command E after SOS's prompt {*): *'::. Lfil0~····spec] Upon terminating, SOS writes an output file containing all the modifications you made in editing the file. The original file is not changed. The specification SOS uses for the output file {unless you supply it explicitly) has a version number higher by 1 than the latest version of the original file. 1.2 CONTROL CHARACTERS All the usual VAX/VMS control characters can be used in most contexts within SOS. However, some of these characters are not effective in Alter mode. For details, see the Alter command in Section 5.1. The control characters are described briefly below. ~lQ) This character, typed before an input line is complete, deletes the entire line being input. You can then retype the line. ~ is generated by typing u or U while holding down the CTRL key. It is echoed as "'u. This character, typed while output suspends the output until you type is not echoed. 1-2 is tTRL/O) in progress, ~ INTRODUCTION TO SOS ©IBOO This ~TRL~ ©TRL/OJ character resumes is not echoed. output suspended by ~ • This character interrupts output in progress. SOS continues to send output to the terminal, but the terminal discards it. SOS prompts when it is ready for further input; the prompt depends on which mode the editor is in. (CTRL/Ol is not echoed. This character, typed before an input completed, redisplays the entire line. echoed as "R. line ~ is is pRL/Yl This character immediately gets the attention of the DCL interpreter. You can then type any legal DCL command, such as SHOW or CONTINUE. If the DCL command does not change the SOS image, you can resume SOS by typing the DCL command CONTINUE. ©rRL~l This character interrupts whatever command is in progress and returns you immediately to Edit mode. Any changes already made by the command (for example, by an Alter or Substitute command) are incorporated into the file. ~RL~l is echoed as Ac. USE OF ESCAPE 1.3 Some SOS commands use the escape character, ®9 , as part of their syntax. On some terminals, the key corresponding to the escape character is labeled ESC; on others, it is labeled ALT (ALTmode), SEL (SELect), or PRE (PREfix). The escape character is a message delimiter in the VAX/VMS system. Although many VAX-11 programs accept escape interchangeably with carriage return to indicate the end of input, SOS does not. You can use escape only in the contexts in which it is legal. In this manual, on the terminal. ®9 indicates that you should press the escape key SOS echoes the escape as $. Do not confuse this character with the dollar-sign character ($), shift-4. The dollar sign normally has no special meaning to sos.l 1.4 USE OF DELETE The delete character rQill deletes the previous input character. On terminal devices, the delete key may be labelled DEL (DELete), RUB (RUBout) or CAN (CANcel). Successive @ID characters remove previous characters one by one. Any number of characters can be deleted, up to the last carriage return or escape typed. The way this deletion is represented on your terminal depends on the type of terminal. On video display terminals, the characters are physically deleted and the cursor is moved backward. On hard-copy terminals, the deleted characters are echoed in reverse order, and set off within backslashes (\) . 1 The dollar-sign character is significant only when the parameter ESCAPE is set, enabling you to insert escape characters into a text file. See Sections 5.22 and 6.1. 1-3 INTRODUCTION TO SOS 1.5 UPPER- AND LOWERCASE CHARACTERS Whether a terminal generates all uppercase characters, or both upperand lowercase characters, depends on the type of terminal and on how the terminal characteristics are set. (Terminal characteristics are changed by the DCL SET command -- see the VAX/VMS Command Language User's Guide and the VAX/VMS Primer.) SOS accepts either uppercase or lowercase characters in commands, or a combination of the two. In the examples in this manual, upper- and lowercase characters are used interchangeably in commands. SOS distinguishes between upper- and lowercase characters in text that you enter into a file. Normally, SOS does not distinguish uppercase from lowercase when searching for a given text string. Thus, a search for the text string "holiday," using the Find or Substitute commands, would be satisfied if SOS encountered any of the following: holiday, Holiday, or HOLIDAY. (See Chapter 5 for a description of these search commands.) You can request SOS to distinguish upper- and lowercase characters either by setting the EXACT switch (see Section 6.2) or by using an option of the Find and Substitute commands. 1-4 CHAPTER 2 MODES OF OPERATION SOS operates in a number of different modes. A mode of operation is defined as a state of SOS in which the editor interprets terminal input in a distinctive way. You can tell which mode SOS is operating in by the kind of prompt displayed. SOS has seven modes and two submodes of SOS operation. There are paths between the various modes, and each mode has its own prompt. You can initiate the editor in one of three modes: Input, Read-only, or Edit. Edit mode is the heart of SOS, from which the other modes can be accessed. Two submodes of Decide mode correspond to Alter and Alter/insert modes, but communicate only with Decide mode. In different modes, SOS prints different prompts when it is ready to accept input. It then accepts a certain set of commands, each set unique to its mode. In some modes, SOS interprets input on a character-by-character basis, so that you need not type <RET> after a command. In different modes, SOS has different ways of informing you that you have typed unacceptable input. As mentioned above, SOS performs differently depending upon in which it is initiated: the mode • In Input mode, SOS accepts text you type and adds file. it to the • In Read-only mode, you can file; you cannot change it. display the • In Edit mode, you issue most of the commands to display and change a file. From Edit mode you can move to any. other mode, or you can exit to DCL. only search and Four other modes of SOS operation are accessible from Edit mode. are Copy-file, Decide, Alter, and Alter/insert. They • Copy-file mode lets you to copy all or part of one file into another. You can search and display the copy file to locate the text to be copied. • Decide mode is used in conjunction with the Substitute command (see Section 5.15). You can issue a Substitute command to replace all occurrences of one text string with another string within a given range of text. ·If you specify Decide mode, you can choose on a case-by-case basis whether or not to make the substitution, or you can enter Alter mode to make more extensive changes within a line. 2-1 MODES OF OPERATION • Alter mode lets you edit character by character within a line. In this special intraline mode, each character that you type is a command that SOS acts upon immediately; you need not type <RET>. • Alter/insert mode lets you insert text that you type into the text file. In this mode, most control characters are treated as text; they do not perform their usual control functions. Decide mode has two submodes: Decide Alter and Decide Alter/insert. In these submodes, SOS acts almost exactly as it does in Alter mode and Alter/insert mode, respectively. The only difference is that these submodes are accessed from Decide mode, not from Edit mode. When you exit from the submodes you return to Decide mode, not to Edit mode. The following sections discuss the seven modes and two submodes of SOS in general t~rms. 2.1 INPUT MODE In SOS Input mode you can insert one or more new lines of text into a file. You enter Input mode either directly from DCL or from Edit mode. SOS starts up in Input mode if, when you give the DCL EDIT command, you specify a file that does not exist. SOS creates a file with the specified name and waits for you to type text to put into it. An example follows. $ EDIT NEW.FOR INPUT:DBA1:CMANCHJNEW+FOR~1 00100 Notice that SOS types the word INPUT before the file specification remind you that it is creating the file and entering Input mode. to In Input mode, the prompt is the line number that SOS assigns next line to be typed. Initially, SOS numbers lines by lOOs. to the To correct typing errors while entering text, use any of the control characters described in Section 1.2. terminal When input is complete, switch to Edit mode by typing an escape character. You can type escape either at the end of a line of input, or after SOS has prompted with the next line number. SOS then prompts with an asterisk (*), indicating that you are in Edit mode. You can store the file and end SOS at this point by typing the command E. Or, before terminating, you can make changes to the text you have just typed by using other Edit-mode and Alter-mode commands. You can also pass directly from Input mode to Alter mode by typing the character sequence <CTRL/A> <ESC> at the current position on a given line. See Section 5.7 for further information. To enter Input mode again from Edit mode -- if you have more whole lines of text to put into the file use the Input or Replace commands (described in Sections 5.7 and 5.14, respectively). 2-2 MODES OF OPERATION 2.2 READ-ONLY MODE Use Read-only mode if you only need to examine a file and do not intend to modify it, or if you need to look at a file that is protected against your writing it. Start SOS in this mode by appending the qualifier /READONLY to the file specification: $EDIT PAYROLL.MST/READONLY READ:DBA1:ECORPJPAYROLL.MST~3 R* Note that SOS types the word READ before the file that R* is the prompt in Read-only mode. specification, and Only nine commands are legal in Read-only mode (see Chapter 5): End, Find, List, Print, Save World, Move Position, Give Parameter, Set Parameter, and Command File. These commands do not modify the file. Any other commands, which would modify the file, result in the error message COMMAND INVALID FOR READ ONLY FILE. Read-only mode is the most efficient way to use sos if you do not need to modify a file. It is efficient because SOS does not copy the file to a temporary file as it does in Edit mode. See Chapter 8 for details. SOS allows you to change from Edit mode to Read-only mode, provided you have not modified the input file since you entered Edit mode. To change mode to Read-only, type the SOS switch /READONLY at the Edit mode prompt (*). (SOS switches are described in Section 6.2.) 2.3 EDIT MODE Edit mode constitutes the main part of sos. You can switch to any of the other modes of operation from Edit mode, and you can return to Edit mode from any of them. (You can switch to Read-only mode from Edit mode only if you have not modified the file; see Section 2.2.) SOS accepts 24 commands in Edit mode. Most are represented by a single character, and most take arguments in a predetermined syntax. Table 2-1 lists the names and single-character forms of the commands, and gives a brief summary of their functions. For complete descriptions of the commands, see Chapter 5. Initiate SOS in Edit mode by giving the file specification of a file that already exists, either on the EDIT command line or in response to SOS's prompt. For example: $ EDIT $_File: TESTBLD.MAC EDIT:DBA1:EHENDRIKSJTESTBLD.MAC;6 * SOS prints the word EDIT before the file specification, Edit mode. The prompt for this mode is an asterisk (*). indicating For details on the operation of each Edit-mode command, see Chapter 5. Table 5-1 in that section summarizes the command syntax. Most commands take as an argument a line number, or a range of line numbers, indicating what text SOS is to operate on. Page numbers may also appear if the file is divided into pages. The formats of line numbers, page numbers, and ranges are given in Chapter 3. 2-3 MODES OF OPERATION Table 2-1 Edit-Mode Commands: Form and Function Form Command Meaning A Alter Enter Alter mode for intraline, character-by-character editing. C Copy Copy a range of lines to another place within a file, or from another file. Optionally, enter Copy-file mode. D Delete Delete a range of lines. E End End SOS, return to DCL. F Find Search for the occurrence of one more specified strings of text. H Help Print Help package on terminal. I Input Enter Input mode text. J Join Join two text lines into one line. K I< ill L List List a range of lines on the printer or to a file. M Mark Insert a page mark. N reNumber Renumber a range of lines. p Print Print a range of lines on the terminal. R Replace Delete a range of lines and enter Input mode. s Substitute Replace one or more text strings with other string(s} in a range of lines. Optionally, enter Decide mode. T Transfer Copy a range of lines to a new location and delete the original lines. w Save World Write a new file containing changes made so far. all the x extend Enter Alter/insert mode to add text the end of a line. to Move Position Reset the position of the current line. Give Parameter Give the value of parameter or switch. I Set Parameter Reset an SOS parameter or switch. @ Execute Command File Execute the SOS commands contained in a command file. page mark to insert lines or of Delete a page mark. Print next line. Print previous line. 2-4 an SOS internal MODES OF OPERATION 2.4 COPY-FILE MODE Copy-file mode allows you to copy all or part of one file into another file at a specified location. Furthermore, it lets you search through and display the copy file to locate the exact part you want to copy. Enter Copy-file mode by using the Edit-mode command Copy with the qualifier /C (see Section 5.2). For example, to search the file SUBRLIB.FOR and copy part of it after line 100 into the file being edited, type: *C100=SUBRLIB+FOR/C C* Note that C* is the prompt for this mode. The copy file is opened read-only. Thus, only commands that do not change the file are legal, as in Read-only mode. The commands most often used are Print and Find. To exit from Copy-file mode, use the command E. (Do not confuse this command with the Edit-mode command E, with which you exit to DCL.) SOS then prompts for the range of lines to copy. When you supply the range, the copy operation is completed and you return to Edit mode. Copy-file mode is described in detail in Section 5.2.1. 2.5 DECIDE MODE The SOS command Substitute (see Section 5.15) allows you to replace arbitrary strings of text with other strings. Decide mode, entered by way of the Substitute command, lets you decide, line by line, whether or not to make the specified substitution. For each line in which a substitution is called for, SOS displays the modified line and prompts with D* for your decision. You reply with a single character. (No <RET> is needed; SOS reads and acts upon the single character that you type.) If you reply with an illegal character, SOS repeats the prompt. The options you can exercise in Decide mode include: • Yes, make the change as shown. • No, do not make the change. • Enter Decide Alter mode with the change already made. • Make the change, and make all further without decision. • Return immediately to Edit mode. changes Decide mode is described in detail in Section 5.15.3. 2-5 automatically, MODES OF OPERATION 2.6 ALTER MODE Us~ Alter mode to make minor changes within a line of text. mode, you can perform the following functions: In this • Insert or delete single or multiple characters or words within a line • Move forward or backward within a line, either by character(s) or word(s) • Move to the next occurrence of a given character within a line • Delete all text until the next occurrence of a given character within a line • Split a line at any point • Insert control characters into a line In Alter mode, SOS does not echo single-character commands that you type; if you type an illegal command, a bell rings on the terminal. SOS displays the line of text that you are editing as you build it, that is, as you insert, delete, and pass over characters and words. You enter Alter mode by issuing the Alter command from Edit mode, or by typing the character sequence <CTRL/A> <ESC> from Input mode. (This special sequence is discussed in Section 5.7.) The prompt in Alter mode is the line number followed by a tab, the same as the prompt for Input mode. You can easily determine which mode SOS is in, however, by observing the behavior of the terminal (for example, commands are not echoed in Alter mode). There are several ways to return to Edit mode. The most common is to type <RET> (unless you entered Alt~r mode by typing the character sequence <CTRL/A> <ESC>; see Section 5.7). SOS prints the remainder of the line, if any, and gives the Edit-mode prompt (*). Alter mode is described in detail in Section 5.1. 2.7 ALTER/INSERT MODE In Alter/insert mode, characters that you type are inserted into the text. Most control characters (with seven exceptions!) are inserted into the text without performing their usual special functions. For example, <CTRL/U> does not discard the input line. (See the VAX/VMS Command Language User's Guide for control-character functions.) You enter Alter/insert mode from Alter mode by giving the I or R command, or from Edit mode by giving the extend command. SOS does not prompt in Alter/insert mode. You return to Alter mode by typing <ESC>, or to Edit mode by typing <RET>. Alter/insert mode is Section 5.1. described with the 1 The eKceptions are <RET>, <ESC>, <DEL>, and <CTRL/Y>. 2-6 Alter-mode <LF>, command <CTRL/C>, I in <CTRL/R>, CHAPTER 3 LINE NUMBERS, PAGE NUMBERS, AND RANGES Many SOS commands take as one argument a line number or a range of line numbers, indicating what text the command is to operate on. This section describes how to use line numbers and page numbers to form such ranges. It also discusses shorthand characters for line and page numbers, line and page number offsets, and SOS-supplied defaults in range specifications. The examples in this section use the Print command, which displays lines of text. 3.1 LINE NUMBERS sos line numbers are 5-digit decimal numbers, such as 00400 or 13280. Line numbers may not be greater than 65535. When you type a line number, you need not type leading zeros: thus typing 50 is the same as typing 00050. When SOS first numbers a file, it assigns line numbers starting at 100 and ascends by hundreds. (You can change these defaults with the Set Parameter command; see Sections 5.21 and 6.1.) Line numbers are always in ascending order on any given page. The following is an example of the Print command using a number: *P300 00300 single line DATES 15-AUG-77 * 3.2 PAGE NUMBERS If a file is large, or if the information it contains falls naturally into a number of logical divisions, you can divide the file into pages. For example, if an assembly-language source file contains a number of logically independent sections, you could place each section in this file on a separate page. The Edit-mode commands Mark and Kill Page Mark, respectively, insert and delete page marks in a file (see Sections 5.9 and 5.11). Sometimes SOS automatically inserts page marks when you give a Copy or Transfer command, depending on how the line numbers fall. 3-1 LINE NUMBERS, PAGE NUMBERS, AND RANGES The complete specification for a line position in an SOS text file can contain both a line number and a page number. A slash (/) separates the two. For example: *P110/2 This means print line 110 on page 2. 3.3 POSITIONS A position marks a single line in a text file. Some commands take a position as an argument, as for example the Mark command (Section 5.11). Other commands take a range as an argument (see the next section); a range can be specified by giving two positions as its end points. A position consists of a line number and a page number. You can omit either one; if you do, SOS supplies a default, as shown below. The notation => means "is defined as." The braces indicate that one of the enclosed expressions must be chosen. position => 3.4 line /page { line/page l (current page assumed) (first line on page assumed) RANGES OF LINE NUMBERS A range of line numbers can be formed in two ways.I One way is to specify a starting position and an ending position; separate the two positions with a colon (:). For example, the following command tells SOS to print all lines from line 100 on page 4 through line 500 on page 5, inclusive. *Pl00/4:500/5 Depending on how the lines are numbered, this command could tell SOS to print five lines, or 50, or none. If you know exactly how many lines you want to print, but not what all their numbers are, you can form a line-number range using the exclamation point (!) to indicate a relative number of lines. The following command tells SOS to print six consecutive lines, starting with line number 100 on page 4. *Pl00/4!6 This command prints six lines whether or boundary. not it encounters a page The end points of a range need not themselves be existing line numbers. For instance, in a file whose lines are numbered by 10s, the range 33:67 refers to the three lines numbered 40, 50, and 60. A range can consist of only a single line: you can omit the ending position or relative number of lines. Previous examples showed how the Print command, which takes a range as its argument, can print a single line. A command whose range is /page applies to all lines on the page. 1 A third, much less common Section 7.2. way to 3-2 form ranges is described in LINE NUMBERS, PAGE NUMBERS, AND RANGES You can omit the starting position of a range; SOS starting position to the current line, as shown below. 3.5 l the (range is a single line) ( position range => defaults position n position position ! n position l (range starts at current line) (range starts at current line) SHORTHAND CHARACTERS SOS recognizes three characters as shorthand for special line numbers. These shorthand characters can be used in position specifications to stand for both line numbers and page numbers: {period) The current line The current page (caret or up-arrow) The first line on a page The first page in the file (asterisk) The last line on a page The last page in the file /. /" * I* ,. The character , ASCII 94, is represented as a caret on some terminals and as an up-arrow on others. The character 0 can be used interchangeably with " to represent the first line on a page or the first page in a file. A line or page number of 0 is illegal, and SOS interprets 0 in a position specification to mean " Some examples of the use of these shorthand characters follow. Print all lines from line 100 through the current line, inclusive. Print all lines from the beginning of the page through line n20. Print 10 lines beginning with the current line. Print all lines on the current page. Same as above: print all lines on the current page. Print the last line on the current page and the first line on the next page. 3-3 LINE NUMBERS, PAGE NUMBERS, AND RANGES 3.6 THE CURRENT POSITION The current position in SOS is the position of the last line to by a command.l referred For example, after SOS completes a Print or List command, the current position is that of the last line that was output. After a Copy or Transfer, it is the last line moved. After a Find or Substitute, it is the last line matched. (These commands, arranged alphabetically, are described in Chapter 5.) Immediately after SOS is initiated, the current position corresponds to the first line in the file. The current-line pointer is not moved reason and returns an error message. if a command fails for any Two Edit-mode commands allow you to interrogate and to reset SOS's current-line pointer. To find out where the current line is without printing it, use the Give Parameter command (described in Section 5.20). For example: *=· • IS AT 00450/5 * The Move Position command (see Section 5.19) resets the current line. Its argument is a position specification, which can contain a line number, a page number, or their shorthand equivalents. For example, the following command moves the current-line pointer to the last line on page 3. 3.7 DEFAULTS FOR LINE AND PAGE NUMBERS One form for a complete range specification is: linel/pagel:line2/page2 You can omit various parts of the complete specification, and SOS will supply defaults for the omitted parts. The defaults discussed in this section apply only to ranges for which: • You explicitly type a colon (:) • You explicitly type an exclamation mark (!) • You use the form /page If none of these conditions holds, then the range involves line, and the defaults listed in Section 3.3 apply. a single These defaults apply to all commands when you omit part of a range specification. For some commands, the entire range specification is optional. The default range that results depends on the command. See the individual command descriptions in Chapter 5 for details. 1 The terms "current position" and "current line" are used interchangeably. In fact, the current position is made up of two components, the current line number and the current page number. 3-4 LINE NUMBERS, PAGE NUMBERS, AND RANGES The following partial range specifications all represent legal ways to indicate a range. 1. linel/pagel:line2 2. linel:line2/page2 3. /pagel: line2 4. linel:/page2 5. /pagel 6. :line2 Below are the complete specifications of the partial above. The defaults SOS supplies are underlined. 1. linel/pagel:line2/pagel 2. linel/.:line2/page2 3. 2/pagel:line2/pagel 4. linel/.:*/page2 5. ~/pagel:*/pagel ranges listed 6 • • /.:line2/. Table 3-1 shows the rules SOS uses to supply the omitted parts of a range specification. Note that linel defaults to if pagel is supplied; but if neither is supplied, the starting position defaults to ./. (the current position). If omitted, page2 defaults to pagel, if pagel is given; if neither is given, both default to the current page. A Table 3-1 Defaults for Line and Page Numbers I f this part is omitted: Its def a ult is: linel A . /pagel (if pagel is supplied) (if pagel is defaulted) /. : line2 /page2 * /pagel (whether pagel is supplied or defaulted) Applying the rules given in Table 3-1 in some common cases gives these results: • A command with an argument of /page acts on all lines given page. • A command with an argument of :line/page acts on all between the current position and the given position. • A command with an argument of :/page acts on all lines between the current line and the last line on the given page. 3-5 on the lines LINE NUMBERS, PAGE NUMBERS, AND RANGES The examples below illustrate SOS's defaults for omitted range specification. Command Complete Equivalent P.1.:ao1. parts of a Meaning Print all lines from the current line through line 80 on the current page. Print all lines on the current page. *P:905/3 3.8 P.1.:905/3 Same as above: print all the current page. lines on Same as above: print all the current page. lines on Print all lines from the current line through line 905, page 3. LINE-NUMBER AND PAGE-NUMBER OFFSETS Anywhere that a line number is legal, so is an arithmetic expression forming a line-number offset. You can use arithmetic expressions to refer to lines whose numbers you do not know. Expressions with a plus sign (+) refer to lines later in the file, and those with a minus sign (-) refer to earlier lines. Arithmetic expressions do not act across page boundaries, unlike the exclamation mark construction (relative number of lines). Thus, if the current line is the third line from the end of a page, the command P.+4 prints the last line on the page (as do P.+5, P.+6, and so on). Some examples of line-number offsets follow. Print the line two lines before the current line. Print all lines from the fourth line on the current page through the current line. Print the last six lines on the current page and the first four lines on the next page. Print three lines centered about the current line. Same as above: print three lines centered about the current line. Print the first line. Note that arithmetic expressions do not cross page boundaries. 3-6 LINE NUMBERS, PAGE NUMBERS, AND RANGES Page-number offsets are analogous to line number offsets: anywhere that a page number is legal, so is an arithmetic expression forming a page-number offset. Some examples follow. Print line 100 on the next page. Print four lines starting with line 305 on the next-to-last page. *F'l.-1:1.+1 Print all text from the first line on.the previous page through the last line on the following page. You are allowed only one plus or minus sign in an expression. Thus, Pl0+3 is legal, but Pl0+3+1 is illegal. arithmetic The syntax of line numbers and page numbers can now be formally defined. In the definitions below, 1, m, p, and q are positive integers, and represent the following: 1 is a line number less than 65536. m is a line-number offset. p is a page number. q is a page-number offset. A line number can consist of a number 1 or one of the three shorthand characters, optionally followed by an arithmetic expression. A page number has an analogous form. That is: line=> ! ~ [+ m] ~ - l: page=> ~ ~ [+ q] l: ~ - where the braces indicate that one of the enclosed expressions must be chosen. 3.9 HOW SOS NUMBERS NEW LINES Basically, when you insert new lines of text into a file, sos numbers each new line by adding the current line-number increment to the previous line number. This section discusses three topics that elaborate on this basic rule: • What the current line-number increment is, and how it is set • How SOS behaves when an existing line next line number it wants to assign before the • Differences in SOS's line-numbering, depending on whether are ~ntering lines in Input mode or in Alter/insert mode you intervenes LINE NUMBERS, PAGE NUMBERS, AND RANGES 3.9.1 The Current Line-Number Increment The current line-number increment is a parameter that SOS maintains. If you do not set it, SOS uses a value of 100 for the increment. You can find out what its value is by giving the Give Parameter command =INCREMENT, and you can set it directly with the Set Parameter command /INCREMENT:n. The usual way to change the line-number increment however, is by specifying a second argument to an Input or Replace command. With this second argument you can call for either a permanent update to the increment or a temporary update that applies for this command only. Alternatively, you can request SOS to calculate a line-number increment that allows a known number of lines to fit in the space available to them. See the description of the Input command, Section 5.7, for details. 3.9.2 When an Existing Line Intervenes SOS does not let you insert lines so that the line numbers would be out of sequence. If an existing line stands in the way of the series of new line numbers that SOS is generating, the editor eventually refuses to accept any more inserted lines since it cannot number them in sequence. For example, suppose the current line-number increment is 100. You want to insert some new text after line 400; however, line 500 already exists. You type an Input command: I400. SOS bends its usual rule (which would call for the new line to be numbered 500) and assigns the number 450, halfway in between the existing lines. SOS then accepts one input line. The next line number sos calculates, however, is 550 (the increment, 100, plus the previous line number, 450). Again, this line number is beyond an existing line. At this point, SOS returns you to Edit mode, ending text insertion. 3.9.3 Input Mode versus Alter/Insert Mode There are two ways in SOS to insert new lines of text: Input mode (accessed by the Input or Replace commands) and Alter/insert mode (accessed from Alter mode by the command I, or from Edit mode by the extend command). SOS behaves differently in the two modes when it encounters an existing line whose number intervenes in the sequence of new line numbers SOS is generating. The difference is as follows. In Input mode, SOS lets you insert one line before an intervening line, if it is the first inserted line. If SOS encounters an intervening line after you have inserted one or more lines, it immediately terminates Input mode. In Alter/insert mode, upon encountering an intervening line, SOS always numbers the next line halfway between the previous line and the intervening line. For example, suppose you want to insert text after line 100. The current increment is 100, and the next existing line is 500. If you enter Input mode to insert the text (IlOO), SOS numbers the new lines 200, 300, and 400; then SOS returns you to Edit mode. 3-8 LINE NUMBERS, PAGE NUMBERS, AND RANGES However, if you enter the new lines in Alter/insert mode (AlOO, followed by I, followed by <LF> for each new line), SOS numbers the new lines 200, 300, 400, 450, 475, 487, 493, 496, 498, and 499. At this point, no room is left for any more new lines, since the previous line and the intervening line are numbered 1 apart. SOS rings the terminal's bell and rejects further line insertion, but leaves you in Alter/insert mode. If you have more lines to insert, you must return to Edit <RET>) and issue a reNumber (N) command. mode (type Figure 3-1 shows the logic of SOS's line numbering. In this figure, IN is the current line-number increment; NL is the number of the new line; PL is the number of the previous line; IL is the number of a line that intervenes in the sequence of line numbers SOS is generating. In the calculation of a line number halfway between PL and IL, the notation [-1] means that SOS subtracts 1 if IL - PL is odd, but does not subtract 1 if IL - PL is even. NL=PL+IN Insert line (Alter/insert mode) Ring bell, refuse insert. Remain in Alter/insert mode. NL= PL+ (IL -PL)/2 [-1) Insert line NL= PL+ (IL-PL)/2 [-1) Insert line Return immediately to Edit mode Figure 3-1 How SOS Calculates the Numbers of New, Inserted Lines CHAPTER 4 USING SOS The following sections describe default conditions when SOS is invoked and give guidelines for using sos. 4.1 DEFAULT CONDITIONS WHEN SOS IS INITIATED The default conditions that apply to various SOS parameters and switches when you start up the editor are listed below. The SOS parameters and switches are described fully in Chapter 6 along with a way (the symbol-assignment mechanism) to override these initial defaults. Noexpert -- SOS starts by assuming that you are not an experienced sos user. Therefore, it prints long, self-explanatory error messages; it asks for verification before deleting large blocks of text; and it displays deleted characters in Alter mode. All examples in this chapter assume a nonexpert user. See Section 6.2 for a discussion of the EXPERT switch. Line numbering -- SOS numbers lines by lOOs initially, starting at 100. When you insert lines of text, SOS uses a line-number increment of 100. Automatic file saving -- The two parameters that govern automatic file saving (see Sections 4.3.3 and 6.1) are initially set to O; therefore, SOS does not automatically save a copy of your file as you work on it. You must issue Save World commands to achieve file backup. Lowercase characters -- Initially, SOS accepts lowercase characters as typed. If your terminal can generate lowercase characters, and if you have instructed VAX/VMS not to convert them to uppercase (using the DCL command SET), then SOS accepts and echoes them as lowercase. 4.2 LIMITATIONS AND RESTRICTIONS Some limitations and restrictions on the use of SOS are listed below. Line length -- No line of text can be longer than 500 characters, including spaces but excluding the <RET> that terminates the line. If you attempt to generate a line longer than 500 characters (with the Alter, Input, Join, Substitute, or extend commands), SOS prints the error message LINE IS TOO LONG, and returns you to Edit mode. In the case of an Alter or extend command, any changes that you made previously to the line are discarded, and you are returned to Edit mode. 4-1 USING SOS String length -- No string used in a Find or Substitute command can exceed 200 characters in length. If you use the forms of these commands that allow multiple strings, the combined length of all such strings cannot exceed 200 characters. If you exceed these limits, SOS prints the error message SEARCH STRINGS EXCEEDED BUFFER LENGTH and returns you to Edit mode. Reissue the command with fewer or shorter strings. Line numbers -- Line numbers cannot exceed 65535 (decimal). 4.3 USING SOS SAFELY Some risk is associated with the use of any text editor. You can, by mistake, delete or garble large amounts of text, or even whole files. A hardware or software failure that occurs while you are using a text editor can destroy a considerable amount of work. SOS is designed for safe use. The editor assumes that you can make mistakes; therefore (unless you have declared yourself an expert SOS user, via the EXPERT switch), SOS asks you to confirm certain commands that would delete large amounts of text. It also provides features that you can use to minimize the adverse effects of system malfunctions. 4.3.1 Built-in Safety Features SOS requests confirmation before making major changes to a file. Decide mode is one safety feature of SOS; the editor lets you decide case by case on charact~r-string substitutions, instead of simply making all substitutions. (Section 5.15.3 describes Decide mode.) SOS also requests confirmation before performing a Replace or Delete that would delete all the text on one page, or would delete across a page boundary. 4.3.2 The Save World Command The sos Save World (W) command saves "everything in the world." It creates a back-up file that is a copy of the input file containing the results of all the editing changes you have made so far. The W command should be used frequently, perhaps every five or ten minutes in a long editing session. In this way you protect yourself against the ill effects of system failures, and against any possible errors of your own. If some system failure does occur, you lose only the work done since the last W command. See Section 5.17 for more details on the Save World command. To understand how SOS handles files, refer to Chapter 8. 4.3.3 Two Options for Automatic File Saving For even greater safety, you can set two SOS parameters that govern the automatic use of the Save World command. These parameters are named SAVE and !SAVE. SAVE control$ automatic file saving in Edit mode; !SAVE controls it in Input mode. 4-2 USING SOS To select these options, use the Set Parameter command, slash (/) Section 5.21). For example: (see */SAVE:10 */ISAVE:5 * SOS automatically performs a Save World command after you have issued ten Edit-mode commands that modify the file, or after you have inserted five lines of text in Input mode, whichever comes first. While executing the save, sos displays this message: DOING AUTO-SAVE. PLEASE WAIT. You can set or reset the SAVE and !SAVE parameters at any time while SOS is operating in Edit mode. Setting either parameter to a value of zero turns off the corresponding auto-save option. When you initiate SOS, both options are turned off. Recovering Information from Temporary Files: An Example 4.3.4 If SOS execution is interrupted by a system malfunction, you may be able to recover some lost work from SOS temporary files. These files, and the way in which SOS uses them, are described in Chapter 8. Briefly, one or both of the files SOScnn.TMl and SOScnn.TM2 may contain part of your file (c is the controller number, and nn is the number of your terminal). The following example illustrates one way in which lost work might be recovered from an SOS temporary file. A hypothetical user, Adams, is updating a master address list on terminal number 22 when the system loses power. Not being prudent by nature, Mr. Adams has not been using the W command frequently. After this close call, however, he sets the !SAVE parameter for automatic file saving. *::=name DBA1:CADAMSJADDRESS.MSTP17 * *fl<~rk:i.n ~ PAGE 4 () :I. () ~.) 0 *i.,!5 0 :I. ()!~i~5 L.. a r It.. i n Lawson I... C:~ V ~ 49~3!5 Adam tTRL/C) Fc>rbes Av. 335 Grand Av. tTRL/C) Pittsbur•h PA 15213 Or:~kland CA 946:1.0 tTRL/Y) Nothing works: the system has expired. Several minutes later, after Adams logs back onto the revitalized system, he recovers information from an SOS temporary file as shown below. The temporary file must be renamed, because SOS refuses to open a file it recognizes as a temporary file. 4-3 USING SOS DIRECTORY/SIZE SOSA22+* $ Directorw _DBAl:CADAMSJ SOSA~.~2. TM:I.; :L SOSA22+TM2;1 4 Total cf 2 files, 6 blocks. S RENAME SOSA22.TM1 ADDTMP.MST S EDIT ADDTMP.MST EDIT:DBA1:CADAMSJADDTMP+MST91 *Ii. savf:~: ~.) *flarkin ®G PAGE 4. 01()~)0 *i +, 5 Larkin ,James 49:i5 Fr.>rbes Av. Pittsbursh PA 15213 *w: add res~:;. m~;t CDBA1:CADAMSJADDRESS.MST918J * The exact details of the editing done so far determine how current the material contained in an SOS temporary file will be. Adams was lucky; most of the previously edited material was in the temporary file. However, the point of emphasis here is that you cannot depend on SOS temporary files to provide reliable back-up in case of system failure. Such files are at best a last resort. The safest back-up is frequent use of the W command. 4-4 CHAPTER 5 EDIT-MODE COMMANDS This chapter describes in detail the forms and functions of SOS Edit-mode commands. The commands are presented in alphabetical order. The four nonalphabetic commands ( • = / @ ) are given last. The functions of <RET> and <ESC>, when they are used as Edit-mode commands, are discussed along with the Print command. Table 5-1 summarizes the commands, their syntax, and the pages on which they are described. The remainder of this introduction defines the terms used both in the table and in the rest of this chapter. 5-1 EDIT-MODE COMMANDS Definitions for the Edit-Mode Command Summary (Table 5-1) Uppercase letters represent literals that you type verbatim. (SOS accepts either upper- or lowercase letters.) Lowercase terms, represent variables, defined below. The symbol => means "is defined as." Brackets ([ ]) indicate optional parts of the argument string (except in directory or file-spec, in which one set of brackets must be typed). Stacked braces ({ }) mean choose one of the enclosed expressions. Angle-brackets (< >) enclose descriptive terms, and <ESC> represents the escape key (or ALTmode, SELect, or PREfix). file-spec => [device:] [[directory]] filename [.type [;version]] increment => <a positive integer line-number increment> 1 => <a line number> (0 < 1 < 65536) line => m => <an integer line-number offset> n => <a positive integer> p => <a page number> page => ~ p } [+ q] l: - parameter => <a legal sos parameter or switch> position => J line [/page] ( /page l f q => <an integer page-number offset> . . [{:position}] pos1t1on !n range => :position !n start => <a positive integer line number> string => stringl [ ffiJ string2 [ ffiJ string3 [ ffiJ string4 [ ffiJ strings[ ffiJ string6]]]]] (fewer than 200 characters) 5-2 EDIT-MODE COMMANDS Table 5-1 Edit-Mode Command Summary Command Fonn Alter 1 Copy2 c Delete End Overwrite input file No output file Strip line numbers No numbers, no pages Find 3 Help Input4 D E EB EQ ES ET F H I Join Kill page mark List: LP or file J Mark re Number Print: terminal Replace 4 M N Substitute 5 Transfer Save World eXtend 6 Move Position Give Parameter Set Parameter Execute Command File Print next line Print previous line A K L p R s T w x = I @ ~ ~ [range] position[=file-spec] ,range[Jncrementl [,increment2]] position=file·spec/C [range] [B] [Q] [S] [T] [:file-spec] [[string]~[range]] [,A] [,N] [,E] [,n] [:n] [position] [,increment] [position] [;increment] [position] [;!n] [position] /page [range[,S] [,P[:file-spec]]] [range] [,[S] [,F:file-spec]] [position] [increment] [, [range] [,start] ] [range] [,S] [range] [,increment] [range] [;increment] [range] [;!n] [[oldstring~newstring] ~[range] [,D] [,N] [,E]] position,range[,incrementl [,increment2]] [B] [:file-spec] [range] [,N] position parameter parameter [:n] file-spec 1 4 2 5 Enter Alter mode. Enter Copy-file mode (if /C). 3 Enter Alter mode (if ,A). Arguments ,_ Enter Input mode. Enter Decide mode (if ,D). 6 Enter Alter/insert mode. 5-3 EDIT-MODE COMMANDS A Alter 5.1 ALTER (A -- ALTER MODE) Format: A[range] Argument: range Specifies the range of lines to be edited one at a time in mode. If you omit range, only the current line is edited. Alter Current line: After SOS completes an Alter command, it sets the current line to last line edited. the The Alter command invokes Alter mode, a special intraline editing mode, for each line in turn in the given range. Alter mode is useful for making changes within a line without having to retype it. It is also useful for making changes involving the column positions of characters in a single line or within a range of lines. For each line in the given range, SOS prints the line number and waits in Alter mode for your input. Eighteen commands are legal in Alter mode; any other input is ignored and rings a bell on the terminal. These commands are listed in Table 5-2 and described fully later in this section. The single-character commands are not echoed when typed. Instead, they are effected immediately. SOS maintains an intraline pointer in Alter mode. At any given time this pointer points between two characters in the line. You can space the pointer across the line a character or a word at a time (forward or backward); you can insert text before or after the pointer position; and you can delete or replace one or more characters before or after the pointer. Alter mode displays a line of text differently depending upon the kind of terminal you use. On hard copy terminals, SOS displays characters that the pointer passes as you move across the line. When you move the pointer backwards across the line (to the left), characters are displayed in reverse order and are surrounded by backslashes (\ ••• \). Any characters you delete are displayed between pairs of backslashes (\\ ••• \\). (Note that, if you have declared yourself an expert SOS user by typing the command /EXPERT, deleted text is not echoed. See Section 6.2 for a description of the EXPERT switch.) On video display terminals, when you move the pointer to the left, SOS erases any characters that the pointer passes. Characters deleted to the left of the pointer are erased; characters deleted to the right of the pointer are delimited by double backslashes (unless you have specified /EXPERT). The following sections describe Alter mode editing on hard copy terminals, and the examples display Alter mode editing as it appears on hard copy devices. The difference between hard copy and video 5-4 EDIT-MODE COMMANDS display is also true for the other Edit mode commands. Descriptions and examples given for these commands refer to hard copy editing. As shown in Table 5-2, many Alter-mode commands can be preceded by a positive or negative integer. For most commands, the result is to repeat the command the given number of times. The repetition count does not make sense for some commands, and is ignored. Positive repetition counts move the pointer to the right, and negative counts move it to the left {except for <DEL>, for which the reverse is true). Table 5-2 Alter-Mode Commands Command Meaning B Do not print rest of line; recycle to beginning of line with edits incorporated. [-] [n] ex ••• Change next/previous n characters to characters.I [-] [n]D Delete next/previous n characters. E End Alter mode for this line; line. [-] [n] !text~ Insert text after/before pointer; temporary increment n for new lines. [n]J Split line after pointer; for new lines. use increment n [-] [n] Kx Kill {delete) all until nth character x. occurrence of L Print rest of line; recycle to of line with edits incorporated. beginning p Print rest of line; recycle to position with edits incorporated. current Q Quit Alter mode; [-] [n] Rtext ~ Replace next/previous inserted text. n [-] [n] Sx Skip forward/back character x. nth [-] [n]W Skip forward/back n words. [-] [n] X Delete next/previous n words. [-] [n] Invert case of next/previous n characters. A given do not print use restore original line. to characters occurrence with of 1 "Next" if no minus sign is typed; "previous" if minus sign is typed. The other commands that accept a minus sign are presented in similar fashion. {continued on next page) 5-5 EDIT-MODE COMMANDS Table 5-2 (Cont.) Alter-Mode Commands Command Meaning -------------------··--------------- -~---------4 [-] [n] < Convert next/previous uppercase. n characters to [-] [n] > Convert next/previous lowercase. n characters to [-] [n] CW Space back/forward n characters. Leave Alter mode for this line; of line. [-] [n] ©ID print rest Space back/forward n characters. Leave Alter mode for this line; of line. [-] [n] (]f) Space forward/back n characters. [-] Skip to end/start of line. print rest Do not print rest of line; recycle to current position with edits incorporated. Start fresh: discard edits, recycle beginning of line, do not print line. to Figure 5-1 shows on five lines the interactive process of using Alter-mode commands to edit a single line of text. (On your terminal, you would see the single line displayed piece by piece as you gave the commands.) User input is shown in color. Alter-mode commands are not echoed as typed; rather, SOS displays their results on the text line. The arrow (~) shows the position of the intraline pointer at the time the user types the given Alter-mode commands. The resulting printout is shown immediately below each arrow; an underline ( ) marks the new position of the intraline pointer. The five Alter-mode commands used in the figure are described more fully later in this section. If the range specified for an Alter command is empty, SOS error message RANGE GIVEN DOES NOT CONTAIN ANY LINES. 5-6 prints the EDIT-MODE COMMANDS Commands used in this example are: w moves the pointer to the right past one word and its following space(s) and/or tab(s). i inserts the text you type until <ESC> (in the example, the text is active<SP>). moves the pointer to the right one character at a time, and prints the character. changes the following character to the next character yriu type (in the example, q). c prints the rest of the line and ends Alter mode for this line. sos returns to Edit mode, because the Alter command applies to only one line in the example. Each user reauirins CPU time obtains w ' 10200 Each _ iactive ~ ®Q 10200 Each active ·- ~ w ~ ~ 10200 ~ Each active user re~ CGW 4 10200 Each active user reGuirinS _ ITT 10200 Each active user reGuirinS CPU time obtains ~ * Figure 5-1 Alter-Mode Example B (Alter mode) B Do not print rest of line; recycle to beginning of line The B command tells SOS to recycle to the beginning of the line. That is, the line number is reprinted and the pointer is positioned before the first character. All edits made to the line up to this point are incorporated. SOS does not print the remainder of the line (from the current pointer position to the end) before recycling. 5-7 EDIT-MODE COMMANDS C (Alter mode) [-] [n] Cx... Change next/previous n characters to given characters SOS accepts and prints the next n characters typed on the terminal. These characters replace the n characters in the line immediately to the right of the pointer. The pointer moves one character to the right as you type each character. If you type a minus sign before C, the n characters you type replace text to the left of the pointer position. SOS displays two backslashes (\\) followed by the replaced characters (in reverse order). When you type the first replacement character, SOS displays two more backslashes and echoes each replacement character as typed. The following example illustrates this sequence. *P+ 00905 *a• ()0905 The Preliminstw business Plan (attached) 2w ~ The Preliminstw _ ·~·4c 0090~5 ~ The Preliminstw \\ wts_ <:tr~:1 @ i 0090~5 The Preliminstw \\ wts\\arw _ 00905 ~ The Preliminstw \\ wts\\arw business Plan (attached> ~ * The C command is ignored if the pointer is at the end of the line at the beginning of the line for -n). (or Three characters prematurely terminate the C command: <ESC>, <RET>, and <LF>. If you type nC, followed by some replacement characters (fewer than n), followed by one of these three characters, SOS terminates the C command. • After <ESC> or <LF>, SOS is at command level in Alter mode. • After <RET>, SOS continues with the next line in the range the Alter command, or returns to Edit mode if none remain. In each case, n characters have been deleted from line. The character <DEL> is ignored after a C command. 5-8 the original of text EDIT-MODE COMMANDS D (Alter mode) [-] [n] D Delete next/previous n characters Typing D deletes the character that follows the pointer. More than one character is deleted if you precede the D command with a number. On hard copy terminals, the deleted character(s) is (are) displayed, surrounded by pairs of backslashes: \\abc\\. On video display terminals, characters deleted to the left of the pointer are simply erased; characters deleted to the right of the pointer are enclosed in double backslashes. (See the Alter mode command for an explanation of the difference between hard copy and video terminal editing.) If you supply a number, n, that is greater than the number of characters remaining in the line, all remaining characters are deleted. If you precede the command with a minus sign, characters before the pointer are deleted. The D command is ignored if the pointer is at the end of the line (or at the beginning of the line for -n). E (Alter mode) E End Alter mode for this line; do not print line The E command tells SOS to end Alter mode for this line. The rest of the line is not printed. If more lines remain in the range you specified when issuing the Alter command, SOS proceeds in Alter mode. Otherwise, the Edit mode prompt (*) is issued. (The <RET> command is the usual way to exit from Alter mode; <RET> prints the rest of the line before returning to Edit mode, or to the next line in the range.) I (Alter mode) [-] [n] !text ®_g) Insert text after/before increment n for new lines pointer; use temporary The I command moves SOS to Alter/insert mode. SOS accepts characters from the terminal and inserts them into the line beginning after the current pointer position. If you precede the command with a minus sign, characters are inserted before the pointer position. Alter/insert mode is terminated when you type <ESC>; the editor is left in Alter mode. The pointer is then positioned to the right of the inserted text, and points to the same place it did before the insertion. The inserted characters are echoed on the terminal as typed. Both Alter/insert mode and Alter mode are terminated for this line if you type <RET>. In this case the final <ESC> is not needed. SOS prints the rest of the line and returns to Edit mode (or continues in Alter mode if more lines remain). 5-9 EDIT-MODE COMMANDS If you type <DEL> while inserting text, the previous character is deleted. <DEL> echoes as a pair of backslashes followed by the deleted character. Successive <DEL>s delete and echo previous characters in turn. The next non<DEL> character that you type is echoed as a second pair of backslashes followed by the character. If you type more <DEL>s than the number of characters you have inserted with the I command, sos continues deleting characters to the left of the original point of insertion (until it encounters the beginning of the line). SOS remains in Alter/insert mode. If you insert so much text that the overall length of the line exceeds 500 characters, SOS prints the message LINE IS TOO LONG and returns you to Edit mode. Any changes that you may have made to the line up to this point are discarded. You can type a number before the I command. This number is not a repetition count, as it is for most Alter-mode commands. Instead, it acts as a temporary line-number increment if sos creates a new line while inserting text. SOS creates a new line when you split an existing line by inserting <LF>. If you type a negative number, -n, before the I command, SOS uses +n as the temporary increment and inserts characters before the pointer position. If you type <LF> while in Alter/insert mode, SOS creates a new line to receive the rest of the inserted text. The number of this new line is determined as follows: • If you type a number before the I command, this number is taken as a temporary increment and is added to the current line number. • If you do not type a number before the I command, the increment is added to the current line number. • If an existing line intervenes between the current line number and this new number, the new line is numbered halfway in between. • If the next existing line is numbered 1 higher than current line, a bell sounds and no new line is created. After the new line is created, the pointer is positioned beginning of the new line; SOS is still in Alter/insert mode. current at the the In Alter/insert mode, any character you type (with seven exceptions) is inserted into the text line. Many control characters do not have their usual effect when entered in Alter/insert mode. For example, <CTRL/S> and <CTRL/Q> have no effect on terminal output. They are simply inserted into the text line without interpretation. The following seven characters are not treated as text. in Alter/insert mode. ®9 ~ @ID cm mRuq ~ PRLNl ends insertion. ends Alter mode for this line. deletes the previous character. creates a new text line. returns sos to Edit mode. retypes the line. gets the attention of DCL. 5-10 EDIT-MODE COMMANDS J (Alter mode) [n]J Split line after pointer; use increment n for new lines The J command in Alter mode performs the same function as <LF> in Alter/insert mode. When you type J at the pointer position, SOS creates a new line and moves text appearing to the right of the pointer onto this new line. The procedure for determining line numbers of new lines is the same for both the J command and <LF> in Alter/insert mode. See the section on Insert (Alter mode) for a description of this procedure. After the new line is created, the pointer is positioned at the beginning of the line; SOS is still in alter mode. SOS displays the text on the new line when you exit from Alter mode by typing <RET>. For an explanation of how to join lines, see Section 5.8. K (Alter mode) [-] [n] Kx Kill (delete) all until nth occurrence of character x This command tells SOS to delete all text from the pointer position up to, but not including, the next occurrence of the given character x. If you supply n, SOS deletes all text up to the nth occurrence of x. A minus sign causes SOS to delete backwards (to the left) from the pointer position through the given character. Deleted characters are printed within pairs of backslashes (in reverse order for -n). SOS ignores the K command if the given character does not occur in the remainder of the line, or if it occurs fewer than n times. If the EXACT switch is on (see Section 6.2), SOS requires upper- and lowercase match with the given character x. an exact L (Alter mode) L Print rest of line; recycle to beginning of line This command tells SOS to print the rest of the line, from the pointer position onward, and recycle to the beginning of the line. The line number is reprinted and the pointer is positioned before the first character. All edits made to the line up to this point are incorporated. Compare the L command with the P command, described next (and see the following example). 5-11 EDIT-MODE COMMANDS P (Alter mode) P Print rest of line; recycle to current position The P command tells SOS to print the rest of the line, from the pointer position onward, and recycle to the current pointer position. All previous edits are incorporated. The P command lets you get a fresh look at a line you are editing. The example below shows the P command and the L command. *P• 0()240 *a• while the muon sees a cross section of 0.2 barns, wwi ' ~- 00240 while the Pri\\irp\\secondar~ 00240 while the Pri\\irp\\secondarw muon 00240 while the seconda r~ (Qru ' ·- 8@ Wi ' 00240 while the of 0.2 barns, 00240 while the Pri\\irP\\secondar~ secondar~ while the i Mean 00240 *P• ~ secondar~ 5 C§.e) i, p ~ muon •sees a cross section muon • 4(g~p 00240 arns, 00240 (§f) @ ®91 ' muon •sees• a cross section of 0.2 b ®9 e ' Meanwhile, Meanwhile' the 00240 0.2 barnsr secondar~ muon •sees• a cross section of * Q (Alter mode) Q Quit Alter mode; restore original line The Q command immediately returns you to Edit mode. Thus it differs from the E and <RET> commands, which end Alter mode only for the current line. Q returns you to Edit mode even if more lines remain in the range you specified in the initial Alter command. Under most circumstances, Q restores the line to its original state (as it was before editing with the Alter command). Any changes you made to the line are discarded. However, if you have formed new lines by inserting <LF>, the Q command leaves them intact. 5-12 EDIT-MODE COMMANDS R (Alter mode) [-] [n] Rtext text (@ Replace next/previous n characters with inserted The R command behaves exactly like the command [-] [n]D followed by the command Oitext<ESC>. SOS deletes the next n characters after the pointer (before the pointer for -n) and enters Alter/insert mode. The characters deleted are displayed surrounded by pairs of backslashes (in reverse order for -n). (If the EXPERT switch is on, SOS does not display deleted text.) If you type <LF> after an nR command to create a new line, sos does not use the given n to determine the new line number. In other words, the n in nR applies to the delete operation, not to the insert operation. S (Alter mode) [-] [n]Sx Skip forward/back to nth occurrence of character x The S command accepts one character from the terminal, without echoing it, and moves the pointer to the right until the next occurrence of that character. If you supply n, the pointer moves to the nth occurrence of the character.· The pointer moves to the left past the skip character if n is negative. All characters that the pointer moves over are printed. If the pointer moves to the left, the intervening characters are printed in reverse order between single backslashes. The character after the current pointer position is not compared to the skip character. Therefore, you can skip through a line by repeatedly typing, for example, Se. The pointer is advanced each time to the next occurrence of e. If the EXACT switch distinguishes between example: is on (see Section n.2), the S command uppercase and lowercase skip characters. For *lf.~Nact *P:l.l>O 00:1.60 Production manaser Ann Shraft ProJects deficits of *a• f'rc>d• ..1ct:i<:>n m._ sA ()():1.60 ~ Production manaser _ The S command is ignored if the given character does not occur in the rest of the line, or if it occurs fewer than n times. The pointer is not moved. 5-13 EDIT-MODE COMMANDS W (Alter mode) [-] [n]W Skip forward/back n words This command moves the pointer to the right (to the left for -n) until it points to the first character of the next word. The pointer moves over spaces and tabs, then over the next word, then over any following spaces and tabs. If you supply n, the pointer moves to the start of the nth following word (preceding for -n). A "word" is defined as any collection of letters and numbers. X (Alter mode) [-] [n]X Delete next/previous n words The X command acts like the W command, except that it deletes spaces, word(s), and following spaces through the nth word after the pointer (before the pointer for -n). SOS prints deleted characters between pairs of backslashes (in reverse order for -n). (If the EXPERT switch is on, SOS does not print deleted characters.) Typing 99X is an easy way to delete the rest of a line. A (Alter mode) [-] [n].. Invert case of next/previous n characters This command changes the case of n characters after the pointer (before the pointer for -n). Uppercase letters become lowercase, and lowercase characters become uppercase. Nonalphabetic characters are not affected. The cursor moves past the n characters and they are echoed (for -n, the characters are echoed in reverse order between backslashes). < (Alter mode) [-] [n]< Convert next/previous n characters to uppercase This command converts uppercase characiers to lowercase. The pointer moves past n characters (or moves back n characters if -n). All lowercase characters encountered become uppercase; and uppercase characters encountered are not affected. The n characters are echoed (for -n, in reverse order between backslashes). 5-14 EDIT-MODE COMMANDS > (Alter mode) [-] [n]> Convert next/previous n characters to lowercase This command converts lowercase characters to uppercase. The pointer moves past n characters (or moves back n characters if -n}. All uppercase characters encountered become lowercase; any lowercase characters encountered are not affected~ The n characters are echoed (for -n, in reverse order between backslashes}. @§) (Alter mode) [-] [n] (§§) Space back/forward n characters Typing <BS> moves the intraline pointer one space to the left. The characters that the pointer passes over are printed between single backslashes. If you supply n, the pointer moves back n characters. The pointer moves forward if n is negative: -n<BS> is exactly equivalent to n<SP>. If the n (or -n} you supply is greater than the number of characters remaining, the pointer moves to the beginning (end} of the line. SOS ignores the command if the pointer is at the beginning of the line (or at the end of the line for -n}. ffil (Alter mode) IBITl Leave Alter mode for this line; print rest of line This Alter-mode command is the usual way to terminate editing for the current line. <RET> ends Alter mode for this line whether you are in Alter mode or in Alter/insert mode. SOS prints the rest of the line, and either prints the line number of the next line in the range or gives the Edit-mode prompt if no lines remain. ® (Alter mode) [-] [n] ~ Space back/forward n characters <DEL> has the same effect as <BS>: it moves the character pointer one space to the left. <DEL> does not delete characters at Alter-mode command level, it simply moves the pointer. The characters that the pointer passes over are printed between single backslashes. If you supply n, the pointer moves back n characters. Pointer movement is to the right if n is negative: -n<DEL> is exactly equivalent to n<SP>. If the n (or -n} you supply is greater than the number of characters remaining, the pointer moves to the beginning (end} of the line. SOS ignores the command if the pointer is at the beginning of the line (or at the end of the line for -n}. EDIT-MODE COMMANDS @ (Alter mode) till Leave Alter mode for this line ; print rest of line <LF> acts like <RET> to end Alter mode for this line, if sos is at Alter-mode command level. From within Alter/insert mode, however, <LF> signals SOS to create a new line. See the Alter-mode command I, above, for details. WJ (Alter mode) [-] [n] @ Space forward/back n characters Typing <SP> moves the pointer one character to the right and prints the character. The pointer moves n characters if you supply n. Pointer movement is to the left if n is negative; characters are printed in reverse order between single backslashes. If the n (or -n) you supply is greater than the number of characters remaining, the pointer moves to the end (beginning) of the line. SOS ignores the <SP> command if the pointer is at the end of the line (or at the beginning of the line for -n). @.ID (Alter mode) [- ] @ID Skip to end/start of line <TAB> (or <CTRL/I>) moves the pointer to the end of the line and prints characters that the pointer passes over. If you type a minus sign, SOS moves the pointer to the start of the line and prints characters in reverse order between single backslashes. The Edit-mode command X (extend), which invokes Alter mode, is equivalent to the command A followed by <TAB> and I. That is, X prints the line and invokes Alter/insert mode at the end of the line. (CTRL/R) (Alter mode) ~ Do not print rest of line; recycle to beginning The <CTRL/R> command tells SOS to recycle to the current pointer position. All previous edits are incorporated. SOS does not print the remainder of the line (from the current pointer position to the end) before recycling. Thus, in Alter mode CTRL/R> behaves the same as in Edit mode. EDIT-MODE COMMANDS (CTRL/ul (Alter mode) PRL/UJ Start fresh: discard edits, recycle to beginning of line, do not print line This command restarts Alter mode for the current line. Any previous changes you made are discarded. SOS immediately redisplays the line number without printing the rest of the line. If you have formed new lines by inserting <LF>, the <CTRL/U> command leaves previous lines intact. It discards any changes made to the latest <kF>-created line and recycles to the beginning of that line. <CTRL/U> does not have the same effect in Alter/insert mode. In mode, <CTRL/U> is taken as text and is inserted into the line. 5-17 this EDIT-MODE COMMANDS c Copy 5.2 COPY (C) Formats: Cposition,range[,incrementl[,increment2]] Cposition=file-spec[,range[,incrementl[,increment2]]] Cposition=file-spec/C Arguments: position Specifies the destination for the copied lines. If the line number specified by position already exists, the copied lines are inserted after position. If not, the copied lines are inserted beginning at position. range Specifies the source range of the lines to be copied. To specify a range, type the line numbers that delimit the range, separated by a colon {:). If you omit range in the second form, above, the entire file is copied. incrementl Specifies the line-number increment for SOS to use for the copied lines. If the source range contains page marks, incrementl is used only up to the first page mark. If you omit incrementl, SOS uses the current line-number increment. increment2 Specifies the line-number increment for SOS to use for the lines following the final page mark in the source range. If you omit increment2, sos uses the current line-number increment. Signals that text is to come from a second file {the copy file). file-spec Specifies the copy file. Option: /C Tells SOS to enter Copy-file mode: that is, to open the copy file as a read-only file so that you can search it for the text to be copied. Current line: After SOS completes a Copy command, it sets the current last line copied. line to the The Copy command inserts a copy of a block of text at a given position in the file. The block of text can be copied either from somewhere else within the file {the first usage form above) or from another file {the second and third usage forms). In the latter case, if you type /C a~ the end of the Copy command, SOS enters Copy-file mode so you can locate the text in the second file. 5-18 EDIT-MODE COMMANDS When you give a Copy command, SOS acts as if you had given an Input command at the given location, and treats each text line in the specified range as if you had typed it in. SOS takes steps to make sure that line numbers are in proper sequence after a Copy operation. The rest of this section gives details on line numbers before and after a Copy command. For an example of how SOS handles line numbers in this situation, see Section 5.15, Figure 5-2. SOS chooses a small enough line-number increment to allow all the lines in the range to fit after the destination position, using the following protocol: 1. SOS checks whether all the lines will current line-number increment. fit if it uses the 2. If the lines will not fit with the current line-number increment, sos checks whether the lines will fit if it uses the increment you supply {increment!). 3. If the lines will not fit with increment! {or if you have not supplied increment!), SOS tries to find a smaller increment that will make the lines fit. SOS cannot choose a small enough increment if the number of lines to be copied is larger than the numerical difference between the line number at position and the number of the next line in the file. In this case, SOS inserts page marks. First, it copies as many lines as will fit, using either the current increment or your increment! {if supplied), inserts a page mark, and copies the rest of the source lines with their line numbers intact. Then SOS inserts a second page mark. SOS tells you what increment it has used with the message INCl=n. If it inserts a page mark, SOS issues the message INCl=ORDER n AND P/M INSERTED. If the range of lines to be copied already contains page marks, SOS renumbers the copied lines only up to the first page mark. The page mark is copied, and all the lines up to the last page mark in the range are copied with their line numbers intact. For the lines after the last page mark, SOS follows a protocol similar to the one it uses for lines before the first page mark: 1. If the lines will fit, SOS line-number increment. copies them using the default 2. If the lines will not fit with the default line-number increment, SOS uses the increment you specify (increment2). 3. If the lines will not fit with increment2 (or if you have not supplied increment2), SOS chooses a smaller increment. If SOS cannot choose a small enough increment, it inserts another page mark, copies the lines with numbers intact, and inserts a final page mark. If the source range contains page marks, SOS tells you the increment it uses for the lines copied after the final page mark. The message is INC2=n if SOS does not have to insert a final page mark, and INC2=0RDER n AND P/M INSERTED if it does insert one. EDIT-MODE COMMANDS If the specification of the source range A, meaning the first line on a page, precedes the first line before it begins range specification contains *, meaning following page mark as well. contains the shorthand symbol SOS copies the page mark that to copy the text. If the the last line, sos copies the Note that SOS copies the page mark(s) whether you specify the symbol(s) A and/or *, or whether SOS supplies them as defaults. Thus, SOS copies the preceding page mark if you type the range /3:50/4 This is because the initial line number for page 3 defaults to copies the succeeding page mark if you type the range SOS This is because the final line number for page 4 defaults to * If you type only a single page number for the range, SOS copies both the preceding and the succeeding page marks for that page. For example: /5 This is because SOS expands /5 to A/5:*/5. 5.2.l Copy-file Mode This mode allows you not only to copy a block of text from another file, but also to search the copy file to locate the text. You call for Copy-file mode by using the Copy command in the third format given in Section 5.2. For example: *C455/3=CONTROL+OLB/C The equal sign (=) means that text is to be copied from a second file, and the final /C signals Copy-file mode. If you do not type /C (that is, if you use the second usage form given above), the entire file is copied at the point specified. In this example, the file would be copied at or after line 455, page 3, depending on whether or not line 455 exists. If you type the final /C, SOS prompts C* and waits for you to type a Find, Print, List, or Move Position command. Only a limited number of commands are legal in Copy-file mode because the copy file is read-only while it is open. The Edit-mode commands <RET> and <ESC> are legal, because they are essentially abbreviations of the Print command. Also legal, but of limited utility, are Give Parameter, Set Parameter, and Command File. Any other command results in the message COMMAND INVALID FOR READ ONLY FILE. After you locate the desired lines in the copy file, type SOS responds with ENTER RANG£ OF LINES: At this point you complete the Copy command with the range and, if desired, one or two line-number increments. You can use line-number abbreviations ( • A * ) in specifying the range. The values of the current line, current page, last line, and so forth refer to the copy 5-20 EDIT-MODE COMMANDS file, not to the original file. If you type <RET> at the "ENTER RANGE OF LINES" prompt, SOS copies the entire file. SOS completes the copy operation and responds with* (the Edit-mode prompt). If, after scanning the file, you decide that you do not want any lines, type: to copy If you decide to cancel the copy-file command at the "ENTER RANGE OF LINES" prompt, type <CTRL/C>. In both these cases, SOS returns to Edit mode without copying any part of the file. 5-21 EDIT-MODE COMMANDS D Delete 5.3 DELETE (D) Format: D[range] Argument: range Specifies the lines to be deleted. If you omit default is to delete the current line. the range, the After SOS completes a Delete command, it sets the current line to last line deleted (which no longer exists). the Current line: This command deletes the lines in the specified range. If no lines are in the range, SOS prints the error message RANGE GIVEN DOES NOT CONTAIN ANY LINES. Before deleting all lines boundary, SOS requests questions: on a page, confirmation or deleting across a page with one of the following DELETE ENTIRE PAGE? Y OR N: DELETE ACROSS PAGES? Y OR N: SOS then waits for you to type either Y or N (a <RET> is not needed). SOS rejects any character other than Y, y, N, or n and repeats the question. After deleting the lines, SOS reports the results of the deletion with a message such as the following: 81 LINE<S> DELETED (00145/2:0025014>. * If the EXPERT switch is on, SOS neither tells you how many lines were deleted. requests SOS automatically renumbers the remaining pages of delete an entire page. 5-22 confirmation nor the you file if EDIT-MODE COMMANDS E End 5.4 END (E) Formats: E[:file-spec] EB[:file-spec] EQ[:file-spec] ES[:file-spec] ET[:file-spec] Arguments: file-spec If given, specifies the output file. current output file specification. If omitted, SOS uses the B Tells SOS not to create a "back-up" file. The output file has the same version number as the input file, and the input file is effectively deleted. Q Tells SOS to quit without writing an output file. s Tells SOS to write the output file without line numbers, but with page marks. T Tells SOS to write the output file without line numbers marks. or page Current line: Not applicable: after the End command, SOS terminates. The End command terminates the editing session and returns you to DCL. Different arguments combined with the End command modify the way SOS exits from a file. SOS tells you the specification of the output file it writes. It gives no specification if you exit without an output file (EQ). If you have not changed the file since it was last written, SOS appends the note (NO CHANGES) to the file specification, and exits without rewriting the output file. If you do not give a file specification with the E command, SOS writes an output file with the same file specification as given in the last Save World command. If no Save World was given, then the file name and type are the same as those of the input file, but the version number is higher by 1. If you supply a file specification, the output file is written with that specification. When supplying a file specification, you cannot make SOS write its output file over an existing file. If a file already exists with the same name and type as the given file specification, SOS increments the version number before writing the output file. If the given file specification is identical to that of an existing file, including the version number, SOS rejects the command with the message FILE ALREADY EXISTS and requests a new filename with the prompt ENTER NEW FILENAME:. 5-23 EDIT-MODE COMMANDS Use the B argument with the End command to request SOS not to create a back-up file when it exits. The version number of the output file is not incremented. Thus, the information in the original file is lost, unless you have previously given a Save World command that incremented the version number. Adding the S argument to the E command requests SOS to write the output file without line numbers. You can use ES to save disk space, since files without line numbers require less storage space. However, sos requires significantly more processing time to generate a file without line numbers. This is because of the way SOS handles temporary files; see Section 8.1. On VAX/VMS systems, you need not use ES to make allowances for programs that cannot deal with line-numbered files. (This is desirable on some other systems with other implementations of SOS.) On VAX/VMS, the input/output system transparently handles line-numbered files. Therefore, the use of ES should be rare. Use the T argument with the End command to clean up a file that has become messy with uneven line numbers and with page marks scattered randomly throughout. ET tells SOS to write the output file as a textual file, without page marks as well as without line numbers. The next time SOS opens the file, it renumbers it. You can use the symbol-assignment mechanism to control SOS's line-numbering defaults (see Section 6.3). Thus, you can start fresh with the file. One use of the ET form of the End command is in pre·par ing command files to serve as command input to SLP, the batch-oriented editor (see the VAX-11 Utilities Reference· Manual for a detailed description of SLP). You can also use ET to prepare a file for reading by a program that does not recognize line numbers and page marks. If you type E without an argument (B, Q, S and/or T), SOS exits, creates both back-up and output files, and writes line numbers and page marks to the output file. You can use any combination of the B, s, and T options with command, in any order. Some useful forms are given below. the End ESB Write the output file without increment its version number. numbers. Do not EBT Write the output file without line numbers marks. Do not increment its version number. or page 5-24 line EDIT-MODE COMMANDS F Find 5.5 FIND (F) Formats: F[[string] ®9 F [ [stringl ~ string6] ®9 [range] [,A] [,N] [,E] [,n] [,-]] [range] [,A] [,N] [,E] [,n]] Arguments: string Specifies the string of characters (fewer than 200) that SOS is to search for. SOS prints the first line in which the string is found. If you omit string, SOS uses the current find string. range Specifies the range of lines to be searched. If you omit range, SOS searches from the line after the current line to the end of the file. stringl ••• string6 Specifies six or fewer distinct strings that SOS is to search for. The total number of characters in the strings may not exceed 200. Options: ,A Tells SOS to enter Alter mode automatically when the string is found. The intraline pointer points before the beginning of the string in the line. ,N Tells SOS to print only the line which the string is found. number(s) of the line(s) in lowercase letters as ,E Tells SOS not to treat uppercase equivalent in the search string. and ,n Tells SOS to find the next n occurrences of given range. the string in the Tells SOS to print the next line that does not contain string. Current line: After SOS completes a Find command, it sets the current line to the last line found; however, if the search fails, the current line is unchanged. 5-25 EDIT-MODE COMMANDS Common short forms: F Search for the string(s) specified in the previous complete Find command, starting at the line after the current line, and continuing to the end of the previously specified range. F ®C) Search for the previously specified string(s), starting after the current line and continuing until the end of the file. Use the Find command to find a given string of text occurring within a given range of lines. SOS prints the first line containing the string within the range. If the range includes more than one page, and SOS finds the string on a page other than the current one, it prints PAGE n. before printing the line containing the string. If SOS cannot find the string in the given range, it prints STRING NOT FOUND, SEARCH FAILED. The current line is unchanged. To find the first occurrence of a followinq form: *Fisomer @.W word on a given page, use the /4 This form of the command means find and print the first line on page 4 that contains the string "isomer". To locate the next occurrence of the same string you previous Find command, use only the range argument: gave in the This form means find and print the first line on page fi that contains the string "isomer" (from the previous Find command). If you use this form of the Find command before you issue a complete Find command, sos prints ILLEGAL SEARCH STRING GIVEN. If you omit the range specification, SOS begins searching at the line following the current line, and continues through the end of the file. For example: *fdemn:1ribo @.W This form means find the first occurrence of the string "deoxyribo" beginning with the line following the current line through the end of the file. You can give the Find command repeatedly, each time finding the next occurrence of a string in the file. To do this, simply type F. For example: *frandom ®-W 11:1* 00320 but random Perturbations of the lattice structure *f Oi310 a certain de~ree of randomness in the Process. *f PAGE 2. a pseudo-random number in the interval co,1J, chosen 00110 *f STRING NOT FOUND, SEARCH FAILED *=· • :rn AT 00110/2 * 5-2fi EDIT-MODE COMMANDS You can search for as many as six different strings at once by using a special form of the Find command. Instead of typing <ESC> after the first string, type <RET>; SOS prompts you with F* for another search string. After typing all the search strings in this way, type <ESC> and the range and options (if desired). The multiple search strings can contain up to 200 characters in all. An example using two search strings is given below. Note that the user has typed ,99 as an option at the end of the Find command. SOS finds the first 99 (or fewer) occurrences of either search string in the range. *frandom F*stochastic ®9 11:1*,99 00~3:?.0 but random Perturbations of the lattice structure 00760 from the stochastic eGuation (EG+ 4-2>. 01~310 a certain de~ree of randomness in the Process. PAGE 2. 00110 a PSeudorandom number in the interval [0,1], chosen F'AGE 4+ 01210 in the stud~ of stochastic Processes. * A common error in using the Find command is to type <RET> after a search string when you meant to type <ESC>. SOS assumes you intend to specify multiple search strings, and prompts F*. At this point, you can type <ESC> and complete the Find command normally. 5.5.1 Find Options The complete Find command, including options, is shown as the first f0fmat given at the beginning of Section 5.5. You can supply options in any combination and in any order. If you give a Find command with one or more options, these options will still be in effect if you later use the abbreviated form F. The ,n option is an exception: it applies only to the complete Find command. To reset the options while still using an type F<ESC>. abbreviated Find command, If you do not use the ,E option, the command below would indiscriminately find a line containing any of the following: number, Number, or NUMBER. *fnumber ®9 This ambiguity can be useful: for example, when you want to find a word whether it begins a sentence or not. But if you want SOS to distinguish uppercase from lowercase characters when searching, use the ,E option. Using the ,E option is equivalent to turning on the EXACT switch Section 6.2) for Find commands only. (see Use a large number like 999 for the ,n option to find all the strings in a given range. Unlike the other three options, the ,n option applies only to one execution of the Find command. For example, if 5-27 EDIT-MODE COMMANDS you give the command FFIRST<ESC>,2 and later use F, more occurrence of the string FIRST. sos finds only one If you use the ,A (Alter mode) and ,- (do not find) options in the same Find command, SOS enters Alter mode with the intraline pointer positioned at the beginning of the line that was found. Examples: Print the first three lines, from the current line through the last line on page 4, that contain the string cdigi. Do not match a string unless its case (upper or lower) agrees exactly with that of the given string. Print the next line after the current line that contains the string digi. The search starts at the line after the current line and continues to the end of the range last specified (to the end of page 4). An exact pattern match is still required. SOS prints only one matched line; the ,3 option specified in the previous Find command applies only to that one command. Print only the line numbers (and page numbers) of the lines in the rest of the file that contain the string digi. Exact pattern matching is no longer called for. Consequently, SOS matches Digi and DIG!, for example, as well as digi. *=strins FINI!-· disi Sl.JirSTITUTEFORMM * Display the strings currently in effect for the Find and Substitute commands. See Sections ~.l and 5.20, respectively, for details on the STRING parameter and the Give Parameter command (=) • *fMunich F'*Bonn F*B(~T'lin ®CJ • :l*•B•e,999 Find all occurrences of any of the strings Munich, Bonn, and Berlin in the rest of the file. Do not match a string unless it starts with an uppercase letter. As each string is found, enter Alter mode for that line, with the intraline pointer positioned before the start of the string that was found. 5-28 EDIT-MODE COMMANDS H Help 5.6 HELP (H) Format: H [: n] Argument: n Specifies the number of the module in the help package is to start printing. that SOS Current line: The Help command does not affect the current line. The Help command prints a help package on your terminal. This package is composed of a number of modules. A control feature lets you skim quickly through the modules. After the introductory module, the help package contains summaries of SOS features and functions similar to Appendix A, but formatted for printing on a terminal. If you type the Help command with no argument, SOS prints the entire help package. The introductory module contains a list of the other modules and their numbers, plus instructions for printing the help package on the line printer. If you type <CTRL/O> while a module is printing, SOS skips to the beginning of the next module. You can skim through the help package by typing successive <CTRL/O>s. Typing <CTRL/C> returns you immediately to Edit mode. If you type the Help command with an argument n, SOS number n and continues to the end of the help package. prints module As an example of how you can use the Help command, suppose you want to see a list of Alter-mode commands. Proceed as follows: 1. Type H. SOS prints the introductory module. 2. Type <CTRL/C> when you read that module number 6 summarizes Alter-mode commands. SOS prints the Edit-mode prompt * 3. Type H:6. 4. Type <CTRL/C> when SOS begins to print module number 7. prompts with * SOS prints module number 6. 5-29 SOS EDIT-MODE COMMANDS I Input 5.7 INPUT (I -- INPUT MODE) Formats: I [position] [,increment] I [position] [;increment] I [position] [ ; ! n] Arguments: position Specifies the destination for the inserted text; position is the line number of the first inserted line, if a line does not already exist at position. If a line exists at position, the line number is set to position plus the current line-number increment (or the specified increment). If another line exists at or before this new line number, the new line is numbered halfway in between. If you omit the position argument, insertion continues at the position where the last Input command left off. increment Specifies the new current line-number increment, if preceded by a comma. If preceded by a semicolon, the argument is a temporary increment only for this insert. If you omit increment, the current line-number increment is used. n Specifies the number of lines you want to insert. an appropriate temporary line-number increment. SOS calculates Current line: After SOS completes an Input command, it sets the current line to last line inserted. the Common short forms: I. Insert after the current line. I* Insert after the last line on this page. I/*+l Start a new page at the end there. of the file and begin inserting I Continue inserting after the line most recently inserted, using the line-number increment given in the last complete Input command. You must issue a complete Input command before using this form. Use the Input command to enter new lines into are a single position (line/page) and/or Text insertion begins (SOS enters Input mode) number specified by position. SOS accepts from the terminal, and inserts them into the 5-30 a file. Its arguments a line-number increment. at or after the line successive lines of text file. Successive line EDIT-MODE COMMANDS numbers are determined by adding the current increment to the previous line number. The increment argument, if specified with a comma, becomes the new line-number increment. If specified with a semicolon, increment acts as the line-number increment for this command only. Subsequent commands continue to use the default increment (except I without any arguments, which uses the temporary increment). Use the third form of the Input command when you know exactly how many lines you want to insert. In this case, SOS calculates a line-number increment that allows the given number of lines to fit before the next existing line. You can move directly from Input mode to Alter mode by using a special sequence of characters: <CTRL/A> followed by <ESC>. When you type this sequence, SOS switches to Alter mode and positions the pointer at the beginning of the last line you inserted while in Input mode. (Note that the <ESC> character is echoed when you type this special sequence.) Now you can use any of the Alter mode commands to correct the line. When you exit from Alter mode (by typing <RET> or E), SOS returns you to Input mode if, when you left it, you still had a range of lines for input. SOS gives the line-number prompt just as if you had stayed in Input mode and typed <RET> at the end of the line. However, if there were no more empty lines when you entered Alter mode from Input mode, SOS returns you to Edit mode. Exit from Input mode by typing <ESC>. If you type <ESC> at the beginning of a new input line, that (empty) line is not inserted into the file. The last full line inserted becomes the current line. You can also return to Edit mode by typing <ESC> at the end of the last line to be inserted. In some circumstances, SOS returns you to Edit mode automatically. These circumstances are given below, along with ways to recover and continue inserting text: • A line exists whose number is equal to or less than the number that SOS calculates for the next inserted line, and this line is not the first line inserted. (To continue inserting text, issue another Input command, specifying a smaller increment.) • The line number that SOS calculates for the next inserted line is greater than 65535. (Renumber part of the file.) • You try to insert a line longer shorter lines.) than 500 characters. (Use After completing an Input command, when you have returned to Edit mode, SOS remembers the line number and page number of the next line to be inserted. If you type I, text insertion resumes at this point. SOS uses the increment specified in the last complete Input command you typed, even if it was a temporary increment. Thus, in this special case, the temporary increment endures after the Input command in which it was established. If you specify an existing line as position in an Input command, and this line is followed by another line with a number higher by 1, SOS prints the error message INSUFFICIENT LINE NUMBERS FOR INSERTION. In this case, use the reNumber command (N), and then reissue the Input command. 5-31 EDIT-MODE COMMANDS Example: *P• !2 00130 00140 *I. ,2 00:1.42 00144 MOV CLR R5,CNTBL<R3> U.CW2<R5) ;SAVE UCB POINTER ;CLEAR ALL SWITCHES BEQ MOV 10$ I.TCB<R1),R0 ;IF EQUAL YES ;GET REQUESTOR TCB ADDRESS 00146 (ESC) MOV 17o.,u.CNT<R5) ;sET COUNT FOR 170 NULLS BNE 65$ ; IF N. E • DON'T PUNCH TRAILER *IBrn 00150 *I 00146 *=BIG 4 *I*/4 00430 00432 *E VERSION 21A, 2-21-78. GNL. (Est) CDBA1:CLANEYJPPDRV.MAC;18J 5-32 ~ EDIT-MODE COMMANDS J Join 5.8 JOIN (J) Format: J[position] Argument: position Specifies the line to be joined to the following line. If you omit position, the current line is joined to the following line. Current line: After SOS completes a Join command, it sets the current line to the new line made from the two old lines; that is, the current line number becomes the specified position. The Join command joins two lines together. The joined line is given the number of the first line of the pair, that is, of the line at the specified position. It becomes the current line after the Join command completes. The line number that previously belonged to the second line of the pair ceases to exist. SOS refuses to join two lines if the resulting line would be longer than 500 characters. It prints the error message LINE IS TOO LONG. If the line specified by position is the last prints ILLEGAL SYNTAX OF COMMAND. line on a page, Example: *P400!3 The soal is alwaws 00400 PAGE 2. 00610 to write clearr unambisuous 00650 functional specifications that are easw to understand. *J400/1 ILLEGAL SYNTAX OF COMMAND *:lt../2 *J400 *:p. 00400 *a• The soal is alwa~sto write clearr unambisuous ~ i ~ (@ e ~ The soal is alwaws SS 00400 :ii p. 00400 The ~oal is alwa~s to write clearr unambisuous * 5-33 sos EDIT-MODE COMMANDS K Kill Page Mark 5.9 KILL PAGE MARK (K) Format: K/page Argument: /page Specifies the page mark to be deleted. Current line: The Kill Page Mark command does not affect the current line. This command deletes ("kills") a page mark that you have inserted with the Mark command, or that SOS has inserted in the course of a Copy or Transfer command. When a page mark is deleted, the text that was previously on that page appears at the end of the preceding page. (A page mark is considered to be located at the head of its page.) You can delete only one page mark at a time. Deleting a page mark can leave line numbers out of order. SOS warns you with the message LINES OUT OF ORDER. In this case, you must immediately renumber the current page using the reNumber command. If you try to delete a nonexistent page number, SOS prints the message PAGE DOES NOT EXIST. If you try to delete page mark 1 (K/l), SOS responds CANNOT KILL INITIAL PAGE MARK. (SOS considers the text immediately after the start of the file to be on page 1, but it does not insert a physical page mark there.) 5-34 EDIT-MODE COMMANDS L List 5.10 LIST (L) Formats: L[range] [,[S] [,P[=file-spec]]] L [range] [, [S] [ ,F=fi le-spec]] Argument: range Specifies the range of lines to list. lists the entire file. If you omit range, SOS Options: ,s Tells SOS to suppress line numbers in the listing. ,P:file-spec Tells sos to produce a disk file, with specification, formatted for later printing. the given file ,F:file-spec Tells SOS to produce a disk file formatted text file. an ordinary SOS line the as Current line: After SOS completes a List command, it sets the current last line listed. to The List command allows you to generate either a printer listing or a disk file containing all or part of the file being edited. The List command has an advantage over the DCL PRINT command for printing SOS files. The List command generates headings on each page of printer output giving the SOS page number, as well as each listing page's sequential number within the SOS page. The heading contains the specification of the file being listed; the date and time printed; and a page number in the form m-n, where m represents the page number in the SOS file, and n is the sequential number of the listing page within the SOS page. (When n=l, the printing of "-n" is suppressed.). These headings are generated if you specify ,P (whether the output goes to a printer or to a disk file). The headings are also generated if neither ,P nor ,F is specified. The SOS parameter LENGTH controls the page length of listings produced by the List command, ,P option. Its initial value is 55 lines. You can reset this parameter if desired (see Section 6.1). You can specify a particular printer by using the ,P option in the form ,P:LPcn (c is the controller designation and n is the printer number). LPcn is a legal file specification. If you omit file-spec from the ,P option, or if you supply neither ,P nor ,F, the listing is sent to LPAO. The option ,F:file-spec generates a disk file containing the lines in the given range, but without the page headings described above. The disk file thus produced is a normal SOS file. Any page marks in the range are included in the file. The ,S option, if present, tells SOS to suppress line numbers in the disk file. 5-35 EDIT-MODE COMMANDS M Mark 5 .11 MARK (M) Format: M[position] Argument: position Specifies the position (line/page) that is to be the first line on a new page. SOS inserts a page mark before the given position. If you omit position, the current line is assumed. Current line: After SOS completes a Mark command, it sets the current first line on the new page. line to the The Mark command inserts a page mark at a specified point in the and renumbers all subsequent pages. text If the line number in the position specification does not exist, SOS inserts the page mark immediately after the previous, lower-numbered line. If you give the Mark command for the first line on a page, SOS inserts a page mark immediately after the existing page mark. The page that previously existed is then empty. After the completion of a Mark command, the current line is the first line on the new page. Therefore, if you give the Mark command shown below, the current line becomes 300/4. *M300/3 The new line is the same line that you ref erred to in the 300/3, but it is now on page 4. 5-3() command as EDIT-MODE COMMANDS N re Number 5.12 RENUMBER (N) Format: N[increment] [,[range] [,start]] NA[increment] [,[range] [,start]] NP[increment] [,[range] [,start]] Arguments: increment Specifies the line-number increment between the renumbered lines. If you omit it, SOS uses the current line-number increment. range Specifies the range of lines to renumber. renumbers the entire file. If you omit it, SOS Specifies the starting line number for the renumbering. If omit it, SOS starts renumbering at the value of increment. you start A Tells SOS to add increment to every range. line number in the given p Tells SOS to renumber all lines in the range sequentially. SOS does not reset the starting line number at each page boundary. Current line: After SOS completes a reNumber command, it sets the the last line renumbered. current line to This command renumbers the lines in the given range. You must use reNumber whenever SOS prints the message LINES OUT OF ORDER. More commonly, you can renumber upon receiving the error message INSUFFICIENT LINE NUMBERS FOR INSERTION (or at any other time). The first argument, increment, specifies the increment between line numbers. The first line renumbered is given this number, unless you specify the third argument (start). Each succeeding line is given a number that is the sum of the increment and the previously assigned number. If SOS crosses a page mark while renumbering, it assigns the increment number to the first line on the new page (unless you specify NP). For example, you type the following command: Before renumbering, the line numbers on pages 2 shown below. Page 2 Page 3 115 900 126 911 137 952 150 1022 c:_ 'l'7 and 3 might be as EDIT-MODE COMMANDS After renumbering, the line numbers are: Page 2 Page 3 10 10 20 20 30 30 40 40 If you use the NP form of the command, SOS does not reset its numbering when it encounters a page boundary. The entire range is numbered in ascending order. Thus, using NP in the above example produces: Page 2 Page 3 10 20 30 40 50 60 70 80 The NA form of the reNumber command tells SOS to add the specified increment to each line number in the range. If you use NA, the start argument is meaningless. If supplied, it is ignored. If you do not specify a range, SOS renumbers the entire file. If the range is empty, SOS prints RANGE GIVEN DOES NOT CONTAIN ANY LINES. If, while renumbering, SOS assigns a line number larger than 65535, it stops renumbering immediately and prints the message LINE NUMBER STEP TOO LARGE - LINES OUT OF ORDER. At this point, you must reissue the reNumber command using a smaller increment or a smaller starting number. If, after issuing a Kill Page Mark (K) command, you get the error message LINES OUT OF ORDER, renumber using /. as the range (the current page). EDIT-MODE COMMANDS p Print 5 .13 PRINT (P) Format: P [range] [ ,S] Argument: range Specifies the range of lines to print. If you omit range, SOS prints 16 lines (or the number of lines given by the parameter PLINES). Option: ,s Tells SOS to suppress line numbers and to print only the text. Current line: After SOS completes a Print command, it sets the current line last line printed. to the Common short forms: p Print 16 lines (or the number of lines given by PLINES) starting at the current line; cross page boundaries if necessary. P/. Print all lines on the current page. Print the next line. Print the previous line. The Print command prints on your terminal the lines in a given range, including line numbers. If the range includes a page boundary, SOS prints a blank line and PAGE n. to mark it. Use the option ,S to suppress line numbers in the Print command. still prints PAGE n. when it crosses a page boundary. SOS You can interrupt typeout at any time by typing <CTRL/S>. Output pauses until you type <CTRL/Q> to resume where it left off. To suppress all remaining output from a Print command, type <CTRL/O>. There may be a slight pause before SOS gives the Edit-mode prompt * because SOS continues to move output to a buff er area after you type <CTRL/O>. If you type a second <CTRL/O> during this pause, typeout resumes at some later point in the output. 5-39 EDIT-MODE COMMANDS If you use the Print command without arguments, SOS prints a number of lines (initially 16) beginning with the current line. You can change the number of lines printed by P by resetting the SOS parameter PLINES. The command is: *.IF'LINES:n * See Section 5.21 for details on the Set Parameter command /. The Edit-mode commands <RET> and <ESC> act as abbreviated forms of the Print command. They tell SOS to print, respectively, the next line and the previous line in the file. With <RET> and <ESC>, you can step through a file a line at a time in either direction. <RET> and <ESC> operate regardless of page boundaries. For example, suppose the current line is the last line on page 3 when you type <RET>: *::::. • IS AT 1600/3 * mi PAGE 4+ 00100 Guidelines for creatins RUNOFF files online are * These two special abbreviations of the Print command can be defined as follows: P.+l <RET> => { p"'/.+l if P.-1 <ESC> => if if { P*/.-1 if I- * * ., ... Example: *p. --1 ! ~5 00530 00540 0054:7i trade-off involved in usin~ relativelw orsanized files instead of seauentiallw orsanized ones: in most cases, retrieval time is reduced sisnificantl~. 00~5~,)0 However, there maw be unused sPace on the file. * mi * mi PAGE 00010 *p* 00660 ~3. Access Methods: VAX-11 RMS file orsanizations listed in Table 4-1. *=· • IS AT 00600/~3 *==BIG 3 *NO miSUCH LINE EXISTS * 5-40 EDIT-MODE COMMANDS R Replace 5.14 REPLACE (R) Formats: R [range] [,increment] R [range] [;increment] R[range] [; !n] Arguments: range Specifies the range of lines to be deleted and replaced with new text. SOS enters Input mode. The first new line of text is given the number of the first line in the range. If you omit range, the current line is replaced. increment Specifies the new current line increment, if preceded by a comma. If preceded by a semicolon, it is a temporary increment for this command only. If you omit increment, the current line-number increment is used. n Specifies the number of lines you want to insert in place of the deleted range. SOS calculates an appropriate line-number increment. Current line: After SOS completes a Replace command, it sets the current line to the last line inserted. Common short forms: R. Replace the current line with a new line or lines typed in. R Replace the current line. The Replace command acts like a Delete command for the given range, followed by an Input command at the first line in the range. SOS tells you how many lines have been deleted (unless the EXPERT switch is on) and then enters Input mode. You can optionally supply an increment for the Replace command, as you can for the Input command. The increment, if supplied, acts as either a temporary (;) or permanent (,) update of the current line-number increment. That is, use the ,increment argument to change the default line-number increment. Use the ;increment argument to define a temporary increment for this command only. Subsequent Input and Replace commands continue to use the default increment. Use the third form of the Replace command, Rrange;!n, exactly how many lines you have to insert. sos appropriate (temporary) line-number increment. 5-41 if you know calculates an EDIT-MODE COMMANDS The line number of the first inserted line is that of the first line that SOS deleted in the range. Subsequent line numbers are determined by adding the current increment to the previous line number. If you specify a range that crosses page boundaries, or that includes an entire page, SOS asks for confirmation before deleting anything. sos prints one of the following queries: DELETE ACROSS PAGES? Y OR N: REPLACE ENTIRE PAGE? Y OR N: SOS does not request this confirmation before deleting if switch is on. the EXPERT In only one particular does the Replace command differ from an equivalent combination of Delete and Input commands. The Replace command does not define the proper parameters to allow the abbreviated Input command I. You can use this abbreviated form only after typing a full Input command. Examples: *R/2,50 REPLACE ENTIRE PAGE1 Y OR N:Y Replace all lines on page 2 and insert new lines, beginning with the first line deleted. Use an increment of 50; make 50 the current line-number increment. SOS Replace line 150 on the current page with two lines. calculates a temporary increment that allows the two lines to fit. Replace the five lines starting at line 337 with seven new lines. 5-42 EDIT-MODE COMMANDS s Substitute 5.15 SUBSTITUTE (S) Formats: S [ [oldstring S[oldstringl (@ olds tr ingn (@ newstring newstring] (@ newstr ingl ~ [range] [,DJ [ ,N] [ ,E]] ~ (@ ] [range] [ ,D] [ ,N] [ ,E] Arguments: oldstring Specifies any string of characters (fewer than 200). newstring Specifies a string of characters that sos is to all occurrences of oldstring within the range. substitute for range Specifies the range of lines over which SOS is to make the substitution. If you omit range, SOS performs the substitution only on the first match found, starting its search with the current line, proceeding if necessary to the end of the file. oldstringl ••• oldstringn Specifies six or fewer distinct strings that sos is to replace with newstring {l to n). The total number of characters in all the oldstrings cannot exceed 200. newstringl ••• newstringn Specifies six or fewer strings that sos is to substitute for oldstring {l to n). The total number of characters in all the newstrings cannot exceed 200. Options: ,D Tells SOS to enter Decide mode. ,N Tells SOS to suppress printing substitution was made. out the line(s) in which the Tells SOS to accept only an exact match letters must agree) in the oldstring(s). {upper- and lowercase ,E Current line: After SOS completes a Substitute command, it sets the current line to the last line in which a substitution was made. If SOS does not find the string to be replaced, it does not change the current line. 5-43 EDIT-MODE COMMANDS Common Short Forms: You must issue a complete Substitute command before using these forms. s Perform substitution(s} on one line: the first line containing the current oldstring. Search from the current line to the end of the current range. s ®t) Perform substitution(s}, using newstring, on the current line. s the current oldstring and ®t) Perform substitution(s}, using the current oldstring and newstring, on the first line containing oldstring. Search from the current line to the end of the file. This command substitutes an arbitrary string of characters (newstring) for another arbitrary string (oldstring} within a given range of lines, and prints each line in which a substitution is made. An option (,D} invokes Decide mode, in which SOS displays each line for which a substitution is appropriate -- with the change already made -- and asks you to decide the disposition of the line. Decide mode is described fully in Section 5~15.3. SOS remembers the strings you specify in a Substitute command so you can reuse them in a later command. For example: *·sDoctor ®t) Dr. ®t) that /U/2 This command tells SOS to substitute the string Dr. for all occurrences of Dotter on pages 1 and 2. Then, the following command tells SOS to make the same substitution on page 3. *s ~ /3 If you omit the search strings as shown above before you have issued a complete Substitute command, SOS prints ILLEGAL SEARCH STRING GIVEN. A Substitute command with no arguments (assuming you have already issued a complete command) performs the substitution in only one line: the next line, starting from the current line, in which oldstring occurs. The search proceeds, if necessary, until the end of the range specified in the last complete Substitute command. One exception applies: if the last Substitute command operated on the current line, then S without a position tells SOS to search from the line after the current line. Thus, having issued a complete Substitute command, you can perform the same substitution one line at a time throughout the range by repeatedly typing S and then pressing <RET>. SOS prints a blank line and PAGE n. on a new page. 5-44 each time it makes a substitution EDIT-MODE COMMANDS 5.15.1 Multiple Substitutions SOS can perform substitutions for several string-pairs at a time. That is, oldstringl is replaced by newstringl; oldstring2 by newstring2; and so on. Use the second usage form above as follows: 1. Specify all oldstrings first, and follow each oldstring <RET>. with 2. SOS prompts with S* to remind you that Substitute command. the 3. After typing the last oldstring, type <ESC> and the first newstring. Follow each newstring with <RET>. SOS prompts with S*. 4. After specifying the last newstring, type a final <ESC>. 5. Complete the command by typing the desired). you range are (and within options, if The limit for multiple substitutions is six oldstring-newstring pairs. The total length both of all oldstrings, and (independently) of all newstrings, cannot exceed 200 characters. For example, suppose you want to substitute the variable X6 for all occurrences of X in a FORTRAN program, and likewise Y6 for Y. X and Y are always space-delimited. Use the following Substitute command: *s ~ x ~ S* S* ~ ~ y Y6 ~ ~ You can specify fewer newstrings than oldstrings. If you do, SOS substitutes the last newstring for all the extra oldstrings. For example, to substitute the word "sheep" for all occurrences of "goat" and "goats" on page 1, type: *ssoats IBTIJ S*~.\toat @9 sheep @9 /1 Note that in the case of two oldstrings, one of which is a leading subset of the other, you must give the longer oldstring first. 5.15.2 Substitute Options The substitute options (,D ,N ,E) can appear in any order at the end of a substitute command. Any options used in a complete substitute command remain in effect for later S commands. SOS always distinguishes uppercase newstring(s). The ,E option only oldstring (s). For example, suppose you want to routine in the following line: from lowercase characters in affects SOS's interpretation of change the name The utilitw routine EXE is executed bw 5-45 of the utility EDIT-MODE COMMANDS The following Substitute command effects the change: *00330 sEXE XQT 330, e The routine XQT is executed bw * The EXACT switch controls this exact pattern-matching feature. @GJ (ESC) utilit~ If EXACT is on, every Substitute (and Find) command requires an exact pattern match. When SOS is initiated, EXACT is off. Section 6.2 describes the EXACT switch. 5.15.3 Decide Mode SOS enters Decide mode if you type the option ,D after the range in a Substitute command. (SOS also enters Decide mode if the DECIDE switch is on, that is, if you have issued a /DECIDE command.) In this mode you can decide on a line-by-line basis whether or not to make each substitution. SOS prints each line in which it makes a substitution, and prompts with D*. Type one of the eight single characters shown in Table 5-3. No <RET> is needed. If you type any character other than those listed, SOS repeats the prompt. Table 5-3 Decide-Mode Commands .------.---------·-·-----··-------·..---··-··---···-·-··----------· ·-·--···-···-·--------..·• ··-Form Meaning i------+-----------. ·-···-·--·---. - - (§El Yes, make the change as shown. SOS continues Decide mode with the next line to be changed. @ID No, do not make the change. The line remains unaltered. SOS continues in Decide mode with the next line to be changed. When the range is exceeded, sos returns to Edit mode. A Alter: enter Decide Alter mode, with the change already made. Once in Decide Alter mode, you can type any legal Alter-mode commands. When you end Decide Alter mode, SOS continues Decide mode by displaying the next changed line (if any remains in the original range). E End: do not make the change, and immediately leave Decide mode (return to Edit mode). No further substitutions are made in the original range. G Go: yes, make the change, and make all changes in the range automatically, Decide-mode intervention. N Same as Q Quit, same as E: do not immediately to Edit mode. y Same as @ID (§El in further without no, do not make the change. make the yes, make the change. 5-46 change, return EDIT-MODE COMMANDS T Transfer 5.16 TRANSFER (T) Format: Tposition,range[,incrementl[,increment2]] Arguments: position Specifies the destination for the transferred lines. If the line number specified by position already exists, the transferred lines are inserted after position. If not, the lines are inserted beginning at position. range Specifies the source range of the lines to be transferred. incrementl Specifies the line-number increment for SOS to use for the transferred lines. If the source range contains page marks, increment! is used only up to the first page mark. If you omit increment!, SOS uses the current line-number increment. increment2 Specifies the line-number increment for SOS to use for the lines following the final page mark in the source range. If you omit increment2, SOS uses the current line-number increment. Current line: After SOS completes a Transfer command, it sets the the last line moved. current line to The Transfer command moves a block of text from one place in a file to another. When you give a Transfer command, sos acts as if you had given an Input command at the given location, and treats each text line in the specified range as if you had typed it in. The text is deleted from its original place in the file. Contrast this command with the Copy command, which moves a block of text without deleting it {see Section 5.2). SOS takes steps to make sure that line numbers are in sequence after a Transfer operation. The rest of this section gives details on line numbers before and after a Transfer command. Figure 5-2 shows an example of a Transfer command. SOS chooses a small enough line-number increment to allow all the lines in the range to fit after the destination position, using the following protocol: 1. SOS checks whether all the lines current line-number increment. can fit if it uses the 2. If the lines will not fit with the current line-number increment, SOS checks whether the lines can fit if it uses the increment you supply {increment!). 3. If the lines will not fit with increment! {or if you have not supplied increment!), SOS tries to find a smaller increment that can make the lines fit. T20/1, 10/3:40/5, 2, 3([0 LJ LJ LJL_J PAGE 1. 00010 10/1 00020 20/1 00030 30/1 00040 40/1 TranJ command. tI I Destination position. INC1: line-number increment to use before first page mark in range. I ~ :X> I I PAGE 5. 00010 00020 00022 00027 00030 00036 00040 50/5 00050 After Tran sfer PAGE 1. 00010 10/1 00020 20/1 00030 30/1 - - - - - - - - . 00040 40/1 PAGE 1. 00010 10/1 00020 20/1 PAGE 2. 00010 00015 Range of lines to transfer (origin). J1 Before Transfer INC2: linenumber increment to use after last page mark in range. PAGE 3. 00010 10/3 00015 15/3 00020 20/3 00025 25/3 00022 00024 00026 00028 PAGE 4. 00010 10/4 00012 12/4 00014 14/4 00016 16/4 PAGE 2. 00010 10/4 00012 12/4 00014 14/4 00016 16/4 PAGE 5. 00010 10/5 00020 20/5 00022 22/5 00027 27/5 00030 30/5 00036 36/5 00040 40/5 00050 50/5 PAGE 3. 00003 10/5 00006 20/5 00009 22/5 00012 27/5 00015 30/5 00018 36/5 00021 40/5 10/3 15/3 20/3 25/3 30/1 40/1 PAGE4. 00010 10/2 00015 15/2 The above shows the origin and destination of each line in the file before and after the Transfer command, respectively. SOS's line numbering would be the same for an equivalent Copy command, except that a copy of the lines would be left in their original place (before line 50, page 5). Figure 5-2 Transfer Operation to Move Part of a File to Another Location H ~ I 3 0 0 Cz:I (") 0 3: 3: >' 2: 0 en 00030 00040 The Transfer command is issued to move part of the file to another location (as indicated above by the arrow). The file in this example has as its text, for each line, the corresponding line number and page number. Cz:I 0 EDIT-MODE COMMANDS SOS cannot choose a small enough increment if the number of lines to be moved is larger than the numerical difference between the line number at position and the number of the next line in the file. In this case, SOS inserts page marks. First, it transfers as many lines as will fit, using either the current increment or your incrementl (if supplied), inserts a page mark, and transfers the rest of the source lines with their line numbers intact. Then SOS inserts a second page mark. SOS tells you what increment it has used with the message INCl=n. If it inserts a page mark, the message is INCl=ORDER n AND P/M INSERTED. If the range of lines to be transferred already contains page marks, SOS renumbers the transferred lines only up to the first page mark. The page mark is copied, and all the lines up to the last page mark in the range are transferred with their line numbers intact. For the lines after the last page mark, SOS follows a protocol similar to the one it uses for lines before the first page mark: 1. SOS moves them using the default they can fit. line-number increment, if 2. If the lines will not fit with the default line number increment, SOS uses the increment you specify (increment2). 3. If the lines will not fit with increment2 (or if you have not supplied increment2), sos chooses a smaller increment. If SOS cannot choose a small enough increment, it inserts another page mark, moves the lines with numbers intact, and inserts a final page mark. If the source range contains page marks, SOS tells you the increment it uses for the lines copied after the final page mark. The message is INC2=n if SOS does not have to insert a final page mark, and INC2=0RDER n AND P/M INSERTED if it does insert one. If the specification of the source range ~, meaning the first line on a page, SOS precedes the first line before it begins range specification contains *, meaning the following page mark as well. contains the shorthand symbol duplicates the page mark that to move the text. If the the last line, SOS duplicates Note that SOS duplicates the page mark(s) whether you specify the symbols ~ and/or *, or whether SOS supplies them as defaults. Thus, SOS duplicates the preceding page mark if you type the range /3:50/4 This is because the initial line number for page 3 defaults to copies the succeeding page mark if you type the range SOS 20/3:/4 This is because the final line number for page 4 defaults to * If you type only a single page number for the range, SOS copies both the preceding and the succeeding page marks for that page. For example: /5 This is because SOS expands /5 to ~/5:*/5. 5-49 EDIT-MODE COMMANDS w Save World 5.17 SAVE WORLD (W) Formats: W[:file-spec] WB[:file-spec] Arguments: file-spec If given, specifies the output file. If you omit file-spec, uses the current output file specification. SOS WB Tells SOS not to increment the version number of the output file. The previous version of the output file (or the input file, if you have not used W before) is overwritten. Current line: The Save World command does not affect the current line. The Save World command directs SOS to write the current version of a file being edited to disk. SOS tells you the name of the file it has written. After the command, you remain in Edit mode. Use the Save World command frequently as a precaution against system malfunction or against your own errors. If a catastrophe happens, you only lose the work done since the last time you saved "everything in the world." Section 4.3 gives an overview of "defensive editing." Each time you use the W command, the current contents of the file are overwritten on the output file. Thus, if you repeatedly use the W command without giving a different file specification, you are repeatedly updating a single back-up file. To obtain a chronological string of back-up files, use W with a different file specification each time. WB tells SOS not to increment the version number before writing the output file. This option of the Save World command is effective only if it is the first W command given. That is, once a W command has been issued, the version number of the output file has been incremented. All subsequent W or WB commands use that same version number. Only if WB is the first Save World command will it overwrite the original input file; otherwise WB is equivalent to w. SOS overwrites the input file with the current contents of the file you are editing, and returns you to Edit mode. 5-50 EDIT-MODE COMMANDS x Extend 5.18 EXTEND (X) Format: X [range] [ ,N] Argument: range Specifies the range of lines to be extended one at you omit range, the current line is extended. a time. If Option: ,N Tells SOS to print only range. th~ line number of each line in the Current line: After SOS completes an extend command, it sets the current line to the last line in the range that was extended. The extend command adds text to the end of lines. It does this by acting as if you had typed A (to enter Alter mode), <TAB> (to reach the end of the line), and I (to begin inserting text). Alter mode is described in detail with the Alter command in Section 5.1. SOS enters Alter/insert mode for each line in the range that you specify. It prints the line and waits in Alter/insert mode. If you specify ,N, SOS prints only the line number. At any time you can type <ESC> to end insertion and then give any Alter-mode command. For example, typing L moves the intraline pointer to the beginning of the line, so you can make changes before the text you have just inserted. If you type <DEL> while inserting text, the previous character is deleted. <DEL> echoes as a pair of backslashes followed by the deleted character. Successive <DEL>s delete and echo previous characters in turn. The next non<DEL> character that you type is echoed as a second pair of backslashes followed by the character. If you type more <DEL>s than the number of characters you have inserted after the extend command, SOS deletes characters in your original line. If you insert so much text that the overall length of the line exceeds 500 characters, SOS prints the message LINE IS TOO LONG and returns you to Edit mode. Any changes that you may have made to the line up to that point are discarded. If you type <LF> after the extend command (that is, while in Alter/insert mode), SOS creates a new line to receive the rest of the inserted text. The number of this new line is determined as follows: 1. The current line-number increment is line number. 2. If an existing line intervenes between the current line number and this new number, the new line is numbered halfway in between. 5-51 added to the current EDIT-MODE COMMANDS 3. If the next existing line is numbered higher by 1 than current line, a bell sounds and no new line is created. the If no errors occur and the new line is created, the intraline pointer is positioned at the beginning of the new line; SOS is still in Alter/insert mode. After an extend command, while in Alter/insert mode, any character you type (with seven exceptions) is inserted into the text line. Many control characters do not have their usual effect when entered in Alter/insert mode. For example, <CTRL/S> and <CTRL/Q> have no effect on terminal output. They are simply inserted into the text line without interpretation. The following seven characters are not treated as text in Alter/insert mode: (g@ mi @ID @ (CTRL/C) tTRLIR) tTB® ends insertion. ends the extend command for this line. deletes the previous character. creates a new text line. returns SOS to edit mode. retypes the line gets the attention of DCL. 5-52 EDIT-MODE COMMANDS . (period) Move Position 5.19 MOVE POSITION (.) Format: .position Argument: position Specifies the new current position (line/page). Current line: After SOS completes a Move Position command, it sets the current to the line specified by the position argument. line This command resets the current line. If you specify a nonexistent line or page number, SOS prints NO SUCH LINE EXISTS, and does not change the current line. Otherwise, the only response is the Edit-mode prompt * Examples: *.22012 Set the new current position to line 220, page 2. *.. -5 Set the new current position to the fifth line before the present position. Note that, if at present the current line is less than five lines from the beginning of a page, then ~;. is the current position after the command. *.. 1.+2 Set the new current position to the line that has the same number as the current line, on the page that is two pages beyond the current page. 5-53 EDIT-MODE COMMANDS (equal) Give Parameter 5.20 GIVE PARAMETER (=) Format: =parameter Argument: parameter Specifies any legal SOS parameter or switch. Parameters switches are listed in Tables n-1 and 6-2 (see Chapter 6). and Current line: The Give Parameter command does not affect the current line. This command returns the value of SOS parameters and switches. SOS parameters can have values of integers, strings, characters, or positions (line/page). A switch is an sos internal variable that can have one of two values: on or off. The following examples show some useful parameters and switches. Examples: *=bis 4 * Print the page number of the largest page in the file. *=NAME DBB2:CHANNlPAYROLL.HSTJ3 * Print the current specification of the output file. file-spec used by the Save World and End commands. This is the *=STRING FINDi somer SUBSTITUTE- stochastic FORraridom * Print the values of the current Find and Substitute strings. These are handy to know when using these commands repeatedly through a file. The string identified as SUBSTITUTEis newstring, and FOR- is oldstring (see the description of the Substitute command in Section 5.15). 5-54 EDIT-MODE COMMANDS I (slash) Set Parameter 5.21 SET PARAMETER (/) Format: /parameter[:value] Arguments: parameter Specifies any SOS switch or parameter that can be set (see Tables 6-1 and 6-2 in Chapter 6). value Specifies a legal value for that parameter. See the descriptions of the individual parameters in Section 6.1. Current line: The Set Parameter command does not affect the current line. This command sets the value of SOS parameters and switches. You are allowed to set any of the switches, but you can set only nine of the 16 parameters. Table 6-2 shows which parameters you can set. After setting the requested Edit-mode prompt *· parameter or switch, sos prints the The examples below demonstrate setting some of the more frequently used SOS parameters and switches. All are described in Chapter 6. Examples: */i~1ave:10 Perform an automatic Save World added in Input mode. command after every 10 lines The user claims to be an expert at using the editor: issue shorter error messages; do not request confirmation before deleting text; and do not display deleted text in Alter mode. *IF'LINES:23 Print 23 lines of text, starting at the current line, when sos receives P followed by <RET>. This is a useful value of PLINES for users with video display terminals that show 24 lines of text on the screen (especially if the terminal's speed has been set to a high baud rate, for instance 1200 baud or above). 5-55 EDIT-MODE COMMANDS @(at) Execute Command File 5.22 EXECUTE COMMAND FILE (@) Format: @file-spec Argument: file-spec Specifies a file containing SOS commands. Current line: After SOS completes a Command File command, it sets the to the last line modified by a command in the file. current line Command File lets you place a repetitive or frequently used series of commands in a file. SOS executes the commands from the file as if they came from the keyboard. Once SOS begins executing a Command File command, it performs all the commands in the file, returning control to the keyboard only when it reaches the end. However, SOS prints the following items on the terminal: • Error messages • Printouts from the Print command • Lines found by the Find command • Changes made by the Substitute command • Lines altered by the Alter command SOS also requests input from the terminal if the command file contains a Substitute command that places the editor in Decide mode. If the file type field of the command-file specification is can omit the file type when giving the file specification. CMD, you Command files can be nested to a depth of three levels. That is, a command file can contain a Command File command; that file can contain another Command File command. If you attempt to nest command files to a depth of four or more, SOS prints MAXIMUM COMMAND FILE DEPTH EXCEEDED and issues the Edit-mode prompt *· You can use command files to shorten the typing of common commands. For example, you might create two files named L.CMD and W.CMD as shorthand for commonly used Print commands: L... CMD: P*-51*!6 W.CMD! P.-3!6 If these two files are in your directory, you can type @L<RET> to see the last six lines in a file, and type @W<RET> to see a "window" of six lines surrounding the current line. 5-56 EDIT-MODE COMMANDS Another use for Command File is in repetitive editing. Consider the task of deleting the final three characters on each of 400 lines on a page. This task would be tedious to perform by hand, and prone to error as well. The example below shows how to build and use a command file to do the required deletion. Example: In this example, the user (whose name is Lyles) generates a command file named DEL.CMD. The first line contains an X (extend) command with a range of 100 lines. (Lyles gives four Command File commands to delete the 400 lines.) The remaining 100 lines in DEL.CMD contain identical Alter-mode command sequences that perform the deletion on each line in turn. Lyles uses the extend command, instead of the Alter command, to suppress typeout of the lines being altered. The ,N option of extend allows this. Since extend leaves SOS in Alter/insert mode, the first Alter-mode command is <ESC>, which returns SOS to Alter-mode command level. The subsequent command deletes the previous three characters (the last three characters in the line). To get an escape character into the file, Lyles uses the Set Parameter command /ESCAPE to set the logical escape character to the plus sign (+). Thus, when Lyles inserts line 200 and types +, sos inserts an escape character into the file. (For details, see Section n.l.) After entering the line of Alter-mode commands, Lyles uses the Copy command to replicate the line the required 100 times. Note that, after seven copy commands, there are 128 replicated lines; Lyles deletes the excess. $ EDIT DEL.CMD 00100 X. ! 100,N ®9 *IESCAf'E:+ *1* ()0~?.00 +MM3[1 00300 (§9 *C*,200 INCl.=100 *C*'200:* INC1=100 *C*,200:* INC1=100 *C*•200:* INC1=100 *C*•200:* INC1=100 *P* 03300 -3D *C*•200:* INC1=100 *C*,200:* INC1=100 *P* 12900 -3D *D10200:* 28 LINE<S> IIELETEII (10200/1:12900). *E CIIBA2:CLYLESJIIEL+CMil~1J $ 5-57 EDIT-MODE COMMANDS Now Lyles edits the file in which the deletions are needed. The 400 lines are on page 3, numbered 10 to 4010. Because the extend command in DEL.CMD uses the current line (.), Lyles sets the current line to the next unedited line before typing @DEL. Immediately after giving each Command File command, Lyles types <CTRL/O> to suppress all printout. SOS completes the command and issues the Edit-mode prompt. $ EDIT DIREC.COR EDIT:DBA2:rLYLESJDIREC.COR~12 *·13 *@.DEL trn_IJq *f'. ! 2 01010 01020 Gunther, Ja~ ••••••••• Gurska' Andrew ••••••• 22 *@DEL tii\QQJ *P• ! 2 02020 02030 Mosbers, Tom ••••••••• Modeen' Alice •••••••• 41 *@DEL {jTRL/0) *@DEL .. +1 tT~~/O) *F'···"U* 04000 04010 Zosel' Marie ••••••••• Zwsk' Ra~mond •••••••• * 5-58 CHAPTER 6 SOS PARAMETERS AND SWITCHES SOS maintains a number of internal parameters and switches that control different aspects of its operation. You can set and reset some of the parameters and switches from the terminal. Tables 6-1 and 6-2 list the parameters and switches, their initial values, and their minimum abbreviations in upper case characters. A switch in SOS is an internal variable that can have one of two values: on or off. Switches are set with the Set Parameter command (/) and interrogated with the Give Parameter command (=). All switches can be turned off by prefixing NO to their names in a Set Parameter command. A parameter can have a range of values. values: BIG LENGTH START INCREMENT PLINES STEP Most parameters nave integer I SAVE SAVE SUBSTITUTE Four parameters have values that are text strings: ERROR ID NAME STRING Two parameters have values that are positions (line/page pairs): LOCATION Two parameters have values that are single characters: ESCAPE MATCH Some of the parameters and switches can be specified as qualifiers in the initial DCL EDIT command. They can also be specified by using the symbol-assignment mechanism (see Section n.3). The parameters and switches that you can preset in the EDIT command are: INCREMENT I SAVE PL INES SAVE START STEP BAK DECIDE EXPERT LINE LOWER NUMBERS READONLY n-1 SOS PARAMETERS AND SWITCHES TABLE 6-1 SOS PARAMETERS Name 1 Set from F.<lit Mode? Preset viaDCL?2 Initial Value Meaning !---·· BIG n - Displays highest page number ERROr n (null) Displays last error message ESCApe y (null) Sets character for input/output of escapes ID n - INCRement y y 100 ISAVe y y 0 LENGth y LOCAtion n 55 ,.. /1 MATCh y (null) Displays current SOS version number Sets increment for numbering inserted lines Controls auto-Won inserts Sets page size for List command Displays first line in edit buffer Sets special pattern-matching flag character NAME n - Displays output file specification PLINes y y 16 Sets number of lines printed by P~ SAVE y y 0 Controls auto-Won commands STARt y y 100 Sets starting line number STEP y y 100 Sets increment for initial line numbering STRing n (null) SUBStitute n 0 n 1 Displays current position 00000/1 - .. ---· 2 Displays current Find and Substitute strings Displays number of matches in last Substitute __-!.-.._ --~ Minimum abbreviation is given in uppercase letters. You can specify these parameters as qualifiers in the initial DCL EDIT command, or by using the symbolassignment mechanism (see Section 6.3). TABLE 6-2 SOS SWITCHES Initial Value Preset via DCL?2 BAK on y Tells SOS to create back-up file y Sets auto Decide mode on Substitute Name 1 Meaning DECide off EXACt off EXPErt off y Tells SOS to use existing line numbers Requires exact case match for Find, Substitute, contentspecification Declares experienced SOS user LINE on y LOWEr on y Tells SOS to accept uppercase, lowercase as is NUMbers READonly on y Tells SOS to display line numbers off y Starts SOS in Read-only mode SEPArator off Tells SOS to treat_$ . as alphanumeric SEQUence on Leaves output-file line numbers --.. ·1 Minimum abbreviation is given in uppercase letters. 2 You can specify these switches as qualifiers in the initial DCL EDIT command, or by using the symbolassignment mechanism (see Section 6.3). Tum off any switch by using the letters NO before its name; thus, NOLINE turns off the LINE switch. 6-2 • •,_,.J SOS PARAMETERS AND SWITCHES 6.1 PARAMETERS BIG Value: Integer: the largest page number now in the file. Default: Null. Set: Cannot be set by user. SOS resets BIG when you add or delete pages, and (if necessary) when you interrogate it with =BIG Interrogate: Use =BIG When you give the command =BIG for the first time, SOS searches through the entire file, lnserting page marks if it finds lines out of order, until it reaches the end of the file. The following output is typical. *=BIG LINES OUT OF ORDER P/M INSERTED FOR PAGE 2 LINES OUT OF ORDER P/M INSERTED FOR PAGE 5 7 * In this example, SOS returns the value 7 as the highest numbered page in the file. The message LINES OUT OF ORDER might result from concatenating line-numbered files, for example with the DCL command COPY. ERROR Value: String: the last error message SOS printed. Default: Null. Set: Cannot be set by user. error message. SOS resets ERROR each time it prints an Interrogate: Use =ERROR SOS always prints the long form (that is, the NOEXPERT form) of the last error message. It does this even if the EXPERT switch is on. 6-3 SOS PARAMETERS AND SWITCHES ESCAPE Value: Character: when input, causes SOS to insert an escape character into the file; also, the character that SOS prints when it encounters an escape character in text. Default: Initially null. When you do not specify a the default is dollar sign ($). character (/ESCAPE), Set: Use /ESCAPE:x Interrogate: Use =ESCAPE This parameter defines a "logical escape" character that lets you insert an escape character into a text file, and lets sos display escape characters in text that it types out. One reason for inserting escape characters into text files is to use the Find and Substitute commands in command files (see Section 5.22). This parameter is initially null, so you cannot insert escape characters into the text. When you issue the following Set Parameter command, sos uses the default value of $ as the logical escape character. */ESCAPE The logical escape is used in three ways: • SOS inserts an escape character into the text whenever you type $ in Input mode, in Alter/insert mode, or in the newstring of a Substitute command. • sos prints $ whenever it encounters • SOS searches for an escape character when you type $ in a Find command or in the oldstring of a Substitute command. an escape character in text to be typed out. You can select another character by typing: character to act as the */ESCAPE:x where x represents the new logical escape character. NOTE You cannot use any of the following characters as a logical escape: ; : I [ J = characters are meaningful in specifications. Th~se To disable the logical escape feature, type: */ESCAPE: Note that the colon must be typed. 6-4 file logical escape SOS PARAMETERS AND SWITCHES ID Value: String: the current version number of sos. Default: The current version. Set: Cannot be set by user. Interrogate: Use =ID SOS responds to the command =ID with its current version number. If you experience problems with the text editor software, ascertain the version number of SOS so you can report it to DIGITAL service personnel. For example: *=ID SOS V02+04A * INCREMENT Value: Integer: the line-number increment SOS uses to assign line number for input text. the next Default: 100 Set: Append as a qualifier to the EDIT command; or set by the symbol-assignment mechanism; or use /INCREMENT:n. sos changes INCREMENT when you give an Input or Replace command with a second argument (comma-delimited) to update the line-number increment. Interrogate: Use =INCREMENT INCREMENT is the line-number increment SOS uses to calculate line numbers for new lines created in Input or Alter/insert mode. You can set this parameter directly by using the Set Parameter command. However, the more common way to change its value is by supplying an increment argument to the Input or Replace commands. I SAVE Value: Integer: saves. number of lines of input text between automatic file set the Default: 0 (auto-save turned o(f). Set: Append as a qualifier to the EDIT command; symbol-assignment mechanism; or use /ISAVE:n. Interrogate: Use =!SAVE n-5 or by SOS PARAMETERS AND SWITCHES This parameter controls one of SOS's automatic file-saving options (the other is controlled by SAVE). When you set !SAVE -- for example, /ISAVE:lO -- SOS automatically performs a W command each time you insert ten more lines into the file using the Insert or Replace commands. !SAVE initially has the value zero, so auto-saving is disabled inserts. To disable !SAVE once you have set it, reset it to zero. on LENGTH Value: Integer: page length for the List command. Default: 55 Set: Use /LENGTH:n Interrogate: Use =LENGTH LENGTH represents the page length for printer listings generated by the List command. Its initial value is 55 lines. Thus, SOS starts a new page in the printer listing whenever it encounters a page mark, and also whenever it has printed 53 lines without encountering a page mark (the listing heading requires two lines). LOCATION Value: Line/page: the position of the beginning of SOS's edit buffer. Default: ... /1 Set: Cannot be set by user. SOS keeps track of LOCATION as from the input file and writes to its temporary files. it reads Interrogate: Use =LOCATION The edit buffer contains all the text that is immediately accessible to SOS. If you issue a command that affects lines outside this buffer, SOS must read text from the input file before performing the command. (See Chapter 8, "SOS Internals.") For example, if you request the printout of a line earlier in the file than the position LOCATION, sos must write the remainder of the file (after the current position) to its temporary file, and then read from the input file up to the line you requested. 6-n SOS PARAMETERS AND SWITCHES MATCH Value: Character: the flag character for Find and Substitute commands. special Default: Initially null. When you do not specify the default is? (question mark). a pattern-matching character in (/MATCH), Set: Use /MATCH[:x] Interrogate: Use =MATCH This parameter defines a flag character for SOS's special pattern-matching feature (see Section 7.1). MATCH is initially null, so special pattern-matching is disabled. When you issue the following Set Parameter default value of ? as the flag character. command, SOS uses the */MATCH In Find and Substitute strings, certain groups of characters beginning with ? are interpreted in a special way (see Section 7.1). as the special Cannot be set by user. SOS changes NAME when you World command; giving a new file specification. issue a You can select another character to pattern-matching flag character by typing: act */MATCH:x where x represents the new flag character. To disable special pattern-matching, type: Note that the colon must be typed. NAME Value: String: the specification of the output file. Default: The specification of the input file. Set: Save Interrogate: Use =NAME After you issue a Save World command, the parameter NAME contains the file specification that SOS would use for the output file if you gave an End command (without naming a new file). Before you have issued a Save World command, NAME contains the input file specification. However, if you explicitly gave an output file specification when you initiated SOS (/OUTPUT=file-spec), NAME initially contains this specification. 6-7 SOS PARAMETERS AND SWITCHES PL INES Value: Integer: the number of lines SOS prints upon receiving command without arguments. a Print Default: 16 Set: Append as a qualifier to the EDIT command; assignment mechanism; or use /PLINES:n. or set by the symbol Interrogate: Use =PLINES SAVE Value: Integer: saves. number of text-changing commands between automatic file Default: 0 (auto-save turned off) • Set: Append as a qualifier to the EDIT command; symbol-assignment mechanism; or use /SAVE:n. or set by the Interrogate: Use =SAVE This parameter controls one of SOS's two automatic file saving options (the other is controlled by !SAVE). When you issue the command /SAVE:20, for example, SOS automatically performs a Save World command each time you issue the 20th text-changing command (listed below). Commands that do not change the file are not included in this count. Text-changing commands are defined as the commands that are illegal in Read-only mode: Alter Insert Mark Substitute Copy Join reNumber Transfer Delete K1.ll Page Mark Replace extend START Value: Integer: the line number SOS gives to the first line in a and/or to the first line on a page, in an unnumbered file. file, Default: 100 Set: To override SOS's initial default value, append as a qualifier to the EDIT command, or set by the symbol-assignment mechanism; or use /START:n. 1)-8 SOS PARAMETERS AND SWITCHES Interrogate: Use =START If you reset START midw~y through editing a file that was initially unnumbered but that contained page marks, SOS numbers subsequent pages (that it has not yet encountered) using the new starting line number. STEP Value: Integer: the line-number increment numbers to an unnumbered file. SOS uses to assign line Default: 100 Set: To override SOS's initial default value, append as a qualifier to the EDIT command, or set by the symbol-assignment mechanism; or use /STEP:n. Use it as a qualifier to the initial DCL EDIT command or use the symbol-assignment mechanism (see Section fi.3). Interrogate: Use =STEP STEP is the default line-number increment SOS uses to number the lines of an unnumbered input file. sos assigns line numbers as it reads in the lines. Therefore, you can change STEP at any time to affect the line-number increment for the lines that SOS has not yet accessed in an unnumbered file. STRING Value: String: the current Find and Substitute strings. Default: Null. Set: Cannot be set by user. SOS updates STRING whenever you new Find or Substitute command. issue a Interrogate: Use =STRING The parameter STRING contains the values of three search strings: one for the Find command and two for the Substitute command. Any of these search strings can contain multiple strings, if such strings were specified in the last Find or Substitute. For example: *:::STfUNG FI ND·Al te r mode Al te r-nH:>de SUBST:CTUTE·- Find command strings i de mode Substitute command newstrings FDF~".. d f~ C i d f? ITt C:F.:h:~ dee i df~·..·mc:>de Substitute command cldstrinss Df:~c Df?C i de""ITIOd€~ * 6-9 SOS PARAMETERS AND SWITCHES It is sometimes useful to issue =STRING when you are using the Find and/or Substitute commands without arguments; that is, when you are searching for strings specified in a previous complete command. SUBSTITUTE Value: Integer: the number Substitute command. of substitutions performed by the last after every Default: 0 Set: Cannot be set by user. SOS updates SUBSTITUTE Substitute command, whether successful or not. Interrogate: Use =SUBSTITUTE This parameter is useful because it tells you how many substitutions SOS performed in a Substitute command with the ,N option (in which the lines changed are not printed out). If you entered Decide mode with the last substitute command, and if you entered Decide Alter mode for any line, the SUBSTITUTE parameter reflects the total number of possible substitutions for that line. This is true even if, in Decide Alter mode, you undo one or more of the substitutions. • (Period) Value: Line/page: SOS's current position. Default: 00000/l Set: Use .position. SOS updates this parameter that affects a line. after every command All switches can be for example: turned Interrogate: Use =. 6.2 SWITCHES sos switches are summarized in Table 6-2. on with the Set Parameter command; *!BAK Several of the switches can be specified as qualifiers to the initial EDIT command, or by using the symbol-assignment mechanism (see Section 6.3). All switches can be interrogated with the Give Parameter command: *=BAK 6-10 SOS PARAMETERS AND SWITCHES You can abbreviate switch names to four characters. examples below, the full switch names are used. In all the Any switch can be turned off by prefixing NO to its name in the Set Parameter command. For example, to turn off the Decide-mode switch, type: */NODECIDE For compatibility with other implementations of SOS, you can use the minus sign (-) interchangeably with NO to turn off a switch. However, you cannot use the minus sign on the initial DCL EDIT command line. It is best to use NO in all cases. BAK Meaning: Determines whether SOS output file. increments the version number of the Default: BAK is on. Set: Append as qualifier to the EDIT command; or use /BAK (after initialization, SOS does not set this switch). or /NOBAK This switch determines whether SOS increments the version number of the output file when you issue the first Save World command in an editing session, or when you issue End without a previous Save World. If BAK is on, SOS increments the version number. If BAK is off, SOS does not increment the version number, but instead overwrites the input file. The setting of the switch is not meaningful if you give a new file specification with the Save World or End command. This is because the new file specification obviates the question of whether or not you want a back-up file. The setting is also not meaningful after you issue the first Save World command. DECIDE Meaning: Determines whether SOS automatically enters Decide mode for Substitute command. each Default: DECIDE is off. Set: Append as a qualifier to the EDIT command; or set by the symbol-assignment mechanism; or use /DECIDE or /NODECIDE (after initialjzation, SOS does not set this switch). If DECIDE is on, SOS enters Decide mode each time you issue a Substitute command. The effect is as if you issued each Substitute command with the ,D option. The DECIDE switch provides an automatic way of protecting against operator errors. Therefore, a user who is just beginning to learn SOS may want to set this switch. 6-11 SOS PARAMETERS AND SWITCHES EXACT Meaning: Determines whether SOS requires an exact lowercase letters) in pattern searches. match (uppercase and does set Default: EXACT is off. Set: Use /EXACT or /NOEXACT (after initialization, this switch). sos not If EXACT is on, SOS requires an exact pattern match for: • All Edit-mode Find and Substitute command searches • All Alter-mode S and K command searches • All content-specified searches (see Section 7.2) EXPERT Meaning: If EXPERT is on, SOS assumes you are an experienced SOS user. Default: EXPERT is off. Set: Append as a qualifier to the EDIT command; or set by the symbol-assignment mechanism; or use /EXPERT or /NOEXPERT (after initialization, SOS does not set this switch). Declaring yourself an expert SOS user (/EXPERT) has four consequences: • The error and informational messages SOS types are more than those for nonexperts. • SOS does not request confirmation before deleting text across page boundaries, or before deleting all text on a page. • SOS does not report how many lines it deletes when you issue a Delete or Replace command. • In Alter mode, SOS does not display deleted characters between pairs of backslashes (\\ ••• \\). Thus, the appearance of lines as you edit them in Alter mode corresponds more closely to the actual contents of the lines. 6-12 brief SOS PARAMETERS AND SWITCHES LINE Meaning: Determines whether or not SOS present in an input file. uses line numbers that may be Default: LINE is on (that is, SOS uses existing line numbers). Set: Append as a qualifier to the EDIT command; symbol-assignment mechanism; or ·use /LINE initialization, SOS does not set this switch). or set by the or /NOLINE (after If you turn off the LINE switch by the logical name mechanism, or if you initiate SOS with the qualifier /NOLINE, SOS ignores line numbers that may be present in the file it reads. The file is renumbered. SOS does not print the usual message indicating the absence of line numbers (INPUT ASSUMED UNSEQUENCED). LOWER Meaning: Determines whether or not SOS translates from the terminal to uppercase. Default: LOWER is on (that is, lowercase letters uppercase). are lowercase not characters translated to Set: Append as a qualifier to the EDIT command; or set by the symbol-assignment mechanism; or use /LOWER or /NOLOWER (after initialization, SOS does not set this switch). A side effect of turning off LOWER is that if the exact character match options (,E) of the Find and Substitute commands are used, it is impossible to match any lowerca~e character that is already in the file. The EXACT switch, if turned on, has the same side effect. NUMBERS Meaning: Determines whether SOS present in an input numbers in Input mode. prints out line numbers that may be file, and whether it prompts with line Default: NUMBERS is on (that is, SOS lists line numbers when lines in your file). it displays Set: Append as a qualifier to the EDIT command, or set by symbol-assignment mechanism; or use /NUMBERS or /NONUMBERS. the If you turn off the NUMBERS switch by the logical name mechanism, if you initiate SOS with the qualifier /NONUMBERS, or if you type /NONUMBERS at the Edit mode prompt, sos does not print line numbers when it displays lines of text and does not prompt with line numbers in Input mode. 6-13 SOS PARAMETERS AND SWITCHES SEPARATOR Meaning: Determines whether sos treats the three characters ., $, as word delimiters if special pattern-matching is enabled for the Find and Substitute commands. Default: SEPARATOR is off. Set: Use /SEPARATOR or /NOSEPARATOR {after not set this switch). initialization, SOS does By setting the switch SEPARATOR, you can make SOS treat the characters ., $, and as word-delimiters for purposes of special pattern-matching-{see Section 7.1). This feature could be useful in editing a MACRO program, for instance, in which decimal points, dollar signs, and underscore characters appear frequently as parts of symbols. SEQUENCE Meaning: Determines whether SOS leaves line numbers in the output file. Default: SEQUENCE is on. Set: Use /SEQUENCE or /NOSEQUENCE {after initialization, SOS does set this switch). If you turn off the SEQUENCE switch and exit with the E effect is as if you exi~ed with ES. 6.3 command, not the SETTING DEFAULT CONDITIONS USING SYMBOL ASSIGNMENT You can change the parameter and switch values that apply when SOS is initiated by using the DCL symbol-assignment mechanism. You can issue a symbol-assignment command from the terminal to override the initi~l defaults temporarily; or you can include the command in your LOGIN.COM file to override the defaults permanently. SOS's initial default values for parameters and switches are listed in Tables 6-1 and 6-2, and discussed briefly in Section 4.1. You can override these defaults in three ways upon starting the editor. 1. To override the defaults for the current editing session only, use qualifiers to the EDIT command line. For example: $ 2. To override the defaults for all editing sessions within the current job {that is, until you log off the system), issue a symbol-assignment command from the terminal: $ 3. EDIT/INCREMENT:2 file-spec sos:= EDIT/SOS/INCREMENT:2" 1 To override the defaults for all future editing sessions, place a symbol-assignment command {similar to item 2 above) in your LOGIN.COM file. 6-14 SOS PARAMETERS AND SWITCHES The symbol-assignment command associates a character string with a symbol. In item 2 above, the character string EDIT/SOS/INCREMENT:2 is associated with the symbol sos. Typing SOS or SOS file-spec then becomes your own private way of initiating the editor with the qualifier /INCREMENT:2. Such a symbol assignment lasts until you log off the system. To define a symbol that lasts from one job to the next, perform the symbol assignment in the file LOGIN.COM. This command procedure file contains commands that are automatically executed each time you log in (see the VAX/VMS Command Language User's Guide). You can include more than one SOS parameter or switch in a symbol assignment. Use a minus sign (-) in the last character position to continue a long line. As an example, suppose you have the following line in file: your LOGIN.COM sos:=·EDIT/SOS/LOWER/STEP:lO/START:10/INCREMENT:2/PLINES:10· When you type SOS or SOS file-spec to initiate the editor, the parameters and switches specified in the symbol assignment are applied as qualifiers. Therefore, the following conditions hold: • Lowercase input is accepted as is, and uppercase. is not converted f sos reads an unnumbered file, it numbers the lines by • Istarting at 10. • • to lOs, sos uses a line-number increment of 2 for inserted lines. sos prints 10 lines, starting receiving P. 6-15 at the current line, upon CHAPTER 7 SPECIAL CONSTRUCTS AND CHARACTERS The sections within this chapter discuss the pattern-matching constructs used to search for strings, specifying ranges by content rather than line number, and the special characters recognized by sos. 7.1 SPECIAL PATTERN-MATCHING CONSTRUCTS One SOS feature that allows great flexibility in searching for strings using the Find and Substitute commands is special pattern-matching. This feature is initially disabled. You control it by means of the MATCH parameter (see Section 6.1). The Set Parameter command /MATCH:x enables special pattern-matching. The character x acts as a flag to mark the special pattern-matching constructs. A construct is a group of two or more characters beginning with the flag character. When SOS encounters such a construct in a Find or Substitute command, it treats it as a single character with a particular meaning for its pattern search, as detailed below. If you issue the command /MATCH without specifying a flag character, uses the question mark (?) by default as the special-constructs flag. The examples given later in this section use ? as the flag. sos To disable special pattern-matching, and to divest the flag character of any special meaning, type /MATCH:. Note that you must type the colon. Table 7-1 lists the special constructs. Some of the constructs are used in find strings (the string argument of Find and the oldstring argument of Substitute), while others are used in substitute strings {the newstring argument of Substitute). Sections 7.1.1 and 7.1.2 describe these two classes of special pattern-matching constructs. Section 7.1.3 describes combining find-string constructs, and the internal representations of constructs are discussed in Section 7.1.3. 7-1 SPECIAL CONSTRUCTS AND CHARACTERS Table 7-1 Special Pattern-Matching Constructs Construct Internal representation Meaning Find-string constructs: ~ Match any character ?/ ?: I Match any separator ~TAU\) Match a space or tab ?< PAL/El Match any character except x ?%x ~TRL/NJ Match 0 or more of the character x ?)x t:IBQYJ Match 1 or more of the character x ?lx gAL~J Match any alphanumeric character ?9 mAL~J Match any letter (A-Z, a-z) ?! ?& ©I!K~ Match any uppercase letter (A-Z) ?2 ~ Match any lowercase letter (a-z) ?+ ©TAL/PJ Match any decimal digit (0-9) mAL~J Match beginning or end of line ?> ?7c (CTAL/"l Match internal representation of c Substitute-string constructs: ?" tTAL/BJ Substitute next string matched ?*n?* tTAL~ Substitute nth string matched 7.1.1 Find-String Constructs You can use the constructs given below in the Find command, or in oldstring of the Substitute command. ?/ the Match Any Character This construct matches any character. As an example of its use, suppose you want to locate variables that start with B in a MACRO program, but you do not want to see lines with labels that start with B. Since labels start in column 1, they are never preceded by any other character. Thus, the following Find command locates the desired variables: */MATCH *F? /B 00250 (lli) ,A,999 LU MOV The ,A in the Find command tells SOS to enter Alter mode when a match is found. In Alter mode, the intraline pointer points before the first character of the pattern matched. ?: Match Any Separator This construct matches any separator, that is, any character except a letter, a number, or the characters ., $, and (If the switch SEPARATOR is turned on, these three characters als~ are considered separators. See Section 6.2.) The ?: construct is useful in searching for words that, besides appearing in isolation, may be 7-2 SPECIAL CONSTRUCTS AND CHARACTERS imbedded in other words as well. For example, suppose you want to find all occurrences of the word "can"; however, you are not interested in words like incandescent, canonical, and so forth. You can issue the following Find command: The ?: constructs before and after the word are matched by a tab or a space. Note that, unless the command /SEPARATOR was given, this Find command does not match the word "can" if it ends a sentence. SOS does not treat the final period as a separator. The Find command does work if the word "can" begins or ends a line, however, because SOS considers the beginning and end of a line to be separators. ?< Match a Space or Tab This construct matches a space or a tab character. Thus, it represents a subset of the ?: (match any separator) construct described above. The following command has the same effect as the example command in the previous section: This Find command does not match the word "can" if it begins or ends a line, or if it ends a sentence. A Find command that overcomes these limitations is given in Section 7.1.3. ?%x Match Any Character Except x This 3-character construct matches any character except the final character of the construct: any character that x would not normally match. Thus, a?%bc matches aac, ace, adc, and so forth, but not abc. ?)x Match O or More of the Character x This construct matches the character that follows, any number of times that it appears. Thus, a?)bc matches ac, abc, abbc, and so on. SOS matches the first such string it encounters. This construct cannot be used as the last or only element in a search string; ?)x must be bounded on both sides by some character or string of characters. Thus, the command F?)x<ESC> is illegal, and results in the error message ILLEGAL SEARCH STRING GIVEN. Such a construct, if legal, would match every line. ?lx Match 1 or More of the Character x This construct is similar to the one described above, except that it matches one or more occurrences of the given character. Thus, a?lbc matches abc, abbc, abbbc, and so on, but not ac. SOS matches the first such string it encounters. ?9 Match Any Alphanumeric Character This construct matches any character in the ranges A-Z, a-z, and 7-3 0-9. SPECIAL CONSTRUCTS AND CHARACTERS ?1 Match Any Letter (A-Z, a-z) This construct matches any uppercase or lowercase letter. You could use it, for example, to find all lines in a file that contain the strings Mr., Ms., or Dr.: *!match *f ~ ?!?!. l® /U/*,99 This Find command prints all lines that contain a space two letters (of either case), followed by a period. ?& followed Match Any Uppercase Letter (A-Z) This construct matches any uppercase letter. For example, matches 101-A, 101-B, and so on, but not 101-7 or 101-f. ?2 For example, (?2) Match Any Decimal Digit (0-9) This construct finds a number. For example, ?+?+?+-A 203-A, and so on, but not DEF-A. ?> 101-?& Match Any Lowercase Letter (a-z) This construct matches any letter in the range a-z. matches (i), (j), and so on, but not (A) or (4). ?+ by matches 101-A, Match Beginning or End of Line This construct is useful in searching for a string that begins or ends a line. For instance, suppose you want to search a MACRO program for all labels of the form Ln:. You do not want to see lines in which these labels are referred to. Since labels occur at the beginning of lines, the following Find command performs the desired search. *F?>L?+: ®9 I• ,E Here the ?> construct matches the beginning of construct matches any digit. ?7c a line, and the ?+ Match Internal Representation of c This construct matches the character that SOS uses internally to represent the construct c. These internal representations are given in Table 7-1. For example, suppose you need to search for the character <CTRL/F>. As Table 7-1 shows, SOS uses <CTRL/F> internally to represent the construct?& (match any uppercase letter). Thus, to locate <CTRL/F>, use the combined construct ?7?&. The use of the ?7 construct should be rare. Normally, in the infrequent instance when you need to search for an SOS internal representation character, it is easier to disable special pattern-matching and to search for the character directly. That is, type /MATCH: (note the colon) and then issue a Find command such as f<CTRL/F><ESC>. 7-4 SPECIAL CONSTRUCTS AND CHARACTERS The only time you are required to use ?7 is when you must use other special pattern-matching constructs in a search. In that case, you cannot first disable special pattern-matching. One such case would be a Substitute command that searches for <CTRL/F> and then uses it in a Substitute-string construct in the newstring argument (see Section 7 .1.2). 7.1.2 Substitute-String Constructs When you use find-string constructs in the oldstring of a Substitute command, SOS keeps track of the first, second, ••• , nth strings matched within each line by these constructs. The substitute-string constructs let you manipulate the strings matched by the special find-string constructs, without knowing the exact contents of the matched strings. Use these two constructs in substitute strings, newstring arguments of Substitute commands. that is, in the NOTE Do not attempt to use substitute-string constructs to refer to a string matched by ?> (beginning or end of line). A beginning or end of line thus matched is not included in SOS's count of matched strings. ?*n?* Substitute nth String Matched This special construct gives you access to the first, second, ••• , nth strings matched within a line by special find-string constructs. One possible use of this feature is in exchanging arguments of functions. For example, if you want to change all occurrences of FUNCTION (a, b) to: FUN CT ION ( b, a) for any arguments a and b, you command: can issue the following Substitute */MATCH *SFUNCT ION ( '?> '?;,'?>?I) ?• CES9 FU NC TI ON ( '?*2'?*, '?*1 '?*) ®"Q I 1. :I* Substitute Next String Matched This construct is similar to the previous one. When used in a substitute string, it specifies substituting the next string in the series of strings matched by find-string constructs. Thus, if you use the constructs ?*3?*?" in a substitute newstring, sos substitutes the third and fourth strings matched within the line by find-string constructs. 7-5 SPECIAL CONSTRUCTS AND CHARACTERS 7.1.3 Combining Find-String Constructs find-string constructs can be combined in a Find or Substitute command to give even greater versatility to SOS's pattern-searching features. Perhaps the most useful find-string construct to combine is ?%x (match any character except x). For example: with ?%?9 matches any character that is not alphanumeric. ?%?+ matches any character other than a number. ?%?2 matches any character except a lowercase letter. More than two find-string constructs can be combined. others For example: ?%?1?+ matches anything but one or more digits. This combined construct could be useful in searching a data file in which much of the text is multidigit numbers. ?1?%?< matches one or more of any character except spaces tabs. ?%?7?& matches any representation but <CTRL/F>). or character except the internal of the construct ?& (that is, anything sos does not consider the beginning or end of a line a character. Thus, the beginning or end of a line is matched by all of the following combined constructs {among others): ?%?/ anything that is not a character ?%?: not a separator ?%?> not a space or tab ?%?9 not alphanumeric ?%?! not a letter ?%?+ not a number For example, you can search for all occurrences of the word "can" with the following combined construct. This Find command works if "can" begins or ends a sentence (assuming the EXACT switch is not on), or if it begins or ends a line. 7.2 SPECIFYING RANGES BY CONTENT For any Edit-mode command that requires a range of line numbers as argument, you can implicitly specify the range by text content. an For example, instead of requesting that SOS print the lines numbered from 150 through 220, you can request that SOS print all lines from the line in which the string ABC occurs through the line in which the string DEF occurs. {You can do this for any SOS command, not just the Print command.) 7-fi SPECIAL CONSTRUCTS AND CHARACTERS A common way to specify a range of lines is to use the following form: position:position To specify a range by content, replace either or both of the specifications with arguments in the following form: string (lli) ffil @ Terminate the command with a final <RET>. Print command cited above, type: *P : position (lli) A B C (lli) (lli) DEF @ For example, to issue the ffil ffil 00) Note that three carriage returns are required: one each to terminate the two content specifications, and a final one to terminate the Print command. Note also that a colon separates the two halves of the content-specified range. Using this kind of content specification is equivalent to embedding one or two Find commands within whatever command you are issuing. In executing the Print command given above, for instance, SOS performs a search for the string ABC as soon as you type the first <RET>. The search starts at the current line and proceeds to the end of the file. If sos does not find the string, it prints an error message immediately after you type the first <RET>. Assuming ABC is found, SOS performs a second search, starting at the position of ABC, when you type the second <RET> (terminating the range). Again, sos prints an error message if it fails to find DEF. When you type the final <RET>, SOS performs the Print command, using the range of lines it has located in its two searches. Normally, SOS starts its search for a content-specified line at the current line. However, you can specify a range over which SOS is to search with the form: string @ @ range ffil For example, suppose the current line is beyond the first line on the current page that contains the string ABC. Without resetting the current line, you can effect the Print command given above by specifying /. as the range for SOS's content-specified search: *F' (lli) : @ 00) ABC DEF @: @ 1. 00) Content specification is more general still. give options that specify: After the range you • An exact pattern match (upper- and lowercase) • A quasi-Decide mode • The nth occurrence of the given string. can In other words, content specification has options that give it all the generality of a Find or Substitute command. 7-7 SPECIAL CONSTRUCTS AND CHARACTERS The full syntax of a content specification is as follows: I@ [string] @g [range] [{ :~ }][,E] [,-] iBffJ where: string Specifies the pattern SOS is to search for. Note that string is optional. If you omit it, SOS uses the string last used in the same position in a content specification. range Specifies the range over which SOS is to search for the string. If you omit range, SOS searches from the current line to the end of the file. ,D Tells SOS to enter a quasi-Decide mode. SOS prints the first line containing the string, then prompts with ?. You type Y, y, or <SP> if the line printed is the line you intend for the content specification. SOS then continues with the content-specified command. Type <DEL> to reject the line. SOS then prints the next line in the range that contains the string, and again prompts with ?. If you reject all the lines in the range that contain the string, SOS prints an error message and terminates the content-specified command. ,N Tells SOS to enter the same quasi-Decide mode, but instead of printing each line found, SOS prints only the line numb~r, and prompts with ?. Type Y, y, or <SP> to accept the line; type <DEL> to reject it. ,n An integer: tells SOS to use the nth occurrence of the string within the range. N-0te that the meaning of this option differs from its meaning in the Find command. In Find, ,n tells SOS to print the next n occurrences of a string, not its nth occurrence. ,E Tells SOS to accept only an exact pattern match in its search for the string. Upper- and lowercase letters must match. Note: the EXACT switch, which controls exact pattern matching in the Find and Substitute commands, is also effective in content specifications. Turning on the EXACT switch has the same effect as specifying the ,E option. Tells SOS to use the first line in which does not occur. the specified pattern Content specification has still another sort of generality. The range that you can give in a content specification can itself be content-specified; the range in that content specification can also be content-specified. The maximum nesting depth is three levels. 7-8 SPECIAL CONSTRUCTS AND CHARACTERS For example, a file contains the following lines: abc cde fgh ijk lmn opq rst uvw xyz 123 234 uuo 890 00100 00200 00300 00400 00500 00600 00700 00800 00900 01000 01100 01200 01300 J As indicated by the brackets, the user wants to print the lines between the first occurrence of o and the next occurrence of u, with the searches constrained to the range between the first occurrence of f and the next occurrence of 1. The following two-level, content-specified Print command performs this task: *P l@ 0 l@ l@ l@ 1 l@ (BIT) l@ u l@ ~ f (® (BIT) Print lines from o ••• (RET) : ffiITl 00600 ()() '7 ()() Ol~'G ()()(1()() l..IVl...J Start searching at f. .. ••• continue search until 1. ••• through u. Do it. rst * 7.3 SOS SPECIAL CHARACTERS Table 7-2 shows all the nonalphabetic characters that have special meaning to sos. The meaning of some characters depends on the context (for instance, <ESC> can have one of several meanings, depending on the mode SOS is operating in). 7-9 SPECIAL CONSTRUCTS AND CHARACTERS Table 7-2 sos Special Characters Character Meanings Edit mode: Move Position command. In position specifier: means current line or current page. + Edit mode: Give Parameter command. In Copy command: means text is copied from file. another a positive In position specification: signifies line-number offset. Special pattern-matching construct: decimal digit. match any @ Edit mode: I Edit mode: Set Parameter command. In Copy command: /C means enter Copy-file mode. At DCL level: marks beginning of a qualifi~r. In position specifier: separates line number page number. Special pattern-matching construct: match character. and Execute Command File command. In position specifier: means first line on or first page in a file. * a any page, In position specifier: means last line on a page, or last page in a file. Special pattern-matching construct: substitute the nth string matched by a special construct. In End, Save World, List commands: signals beginning of a file specification. In range specification: separates starting and ending positions. In Set Parameter command: signals beginning of parameter value. Special pattern-matching construct: match any separator. In range specification: signals relative number of lines. Special pattern-matching construct: match any letter (A-Z, a-z). In Input, Replace commands: signals new line-number increment. In Copy, reNumber, Transfer commands: separates arguments. In End, Find, List, Print, Substitute, Save World, extend commands: separates command options (,A ,D ,E ,F ,N ,P ,S ,-). '---------------------------~---·-----·---------~------- (continued on next page) 7-10 SPECIAL CONSTRUCTS AND CHARACTERS Table 7-2 (Cont.) SOS Special Characters Character Meanings In Find command and in content specification (all commands): used as a command option. Tells sos to find the first line not containing the specified pattern. In position specification: signifies a negative line-number offset. In Input, Replace commands: signals temporary line-number increment for this command only. ? Default flag character for special pattern-matching. $ Default logical escape character. < Special pattern-matching construct: tab. match a space or > Special pattern-matching or end of line. match % Special pattern-matching construct: character except the given one. construct: Special pattern-matching construct: of the given character. & Special pattern-matching uppercase letter. II Special pattern-matching construct: next sequential string matched construct. begining match any match 0 or more construct: match any substitute the by a special Edit mode: print previous line. Input mode: return to Edit mode. When used after rQIBQ~ , move to Alter mode. Alter/insert mode: return to Alter mode. Decide Alter/insert mode: return to Decide Alter mode. Decide mode: illegal. In Find, Substitute commands: delimits text strings for search and substitution. Alter mode: character. move intraline pointer back one Edit mode: print next line. Alter mode: print rest of line, finish intraline edit for this line. If entered from Input mode by the (CTRL/A) ®9 sequence, return to Input mode. Alter/insert mode: print rest of line, finish intraline edit for this line. Decide Alter mode and Decide Alter/insert mode: print rest of line, return to Decide mode. (continued on next page) 7-11 SPECIAL CONSTRUCTS AND CHARACTERS Table 7-2 (Cont.) SOS Special Characters -------.....----·--------·-·Character Meaning 1---------*------~----·------·----·----·-···----------·-""'----·· Alter mode and Decide Alter mode: move intraline pointer back one character. Decide mode: no, do not make the change. All other modes: delete previous input character. Alter mode and Decide Alter mode: pointer forward one character. Decide mode: yes, make the change. move intraline Alter mode and Decide Alter mode: pointer to the end of the line. move intraline Input mode: when followed by ®]) , change from Input mode to Alter mode and place intraline pointer at beginning of line. Alter mode and Decide Alter mode: discard edits performed so far and place intraline pointer at beginning of line. Alter/insert mode and Decide Alter/insert mode: take trnuui as text and insert it into the text line. 7-12 CHAPTER 8 SOS INTERNALS This chapter describes how SOS performs text editing using temporary files, how the VAX/VMS operating system stores text processed by SOS, and how, with an understanding of SOS internals, you can use SOS more efficiently. 8.1 TEMPORARY FILES Whenever you use the editor, SOS creates one or two temporary files to store changes you make to your file. These temporary files appear in your directory during an editing session. Their names are SOScnn.TMl and SOScnn.TM2, where c represents the terminal device controller and nn represents your terminal number. For example, if you are using terminal device name TTA4, SOS temporary files are named SOSA04.TM1 or SOSA04.TM2. There are two events which, when they occur during an editing session, affect the status of these temporary files: the "wraparound" process and the Save World command. 8.1.1 Wraparound As you edit a file, SOS reads lines into an internal edit buffer. This buffer is a storage area within the image; its size is set when SOS is linked, usually to 10,000 bytes. Lines stored in the edit buffer are immediately available to sos. However, because the storage capacity of the edit buffer is limited, it may not be able to store the entire input file. Thus, the start of the edit buffer (in relation to the beginning of the input file) advances when sos reads in more text than the buffer can store. After it reads lines of text into the edit buffer, sos stores them in the temporary file SOScnn.TMl. Changes you make while editing are incorporated into this file. This process of passing text through the edit buffer to the temporary file continues as long as your editing does not reference a line that is no longer contained in the edit buffer. (You can examine the starting position of the edit buffer by using the =LOCATION parameter described in Section n.l.) When you do call for editing on a line before the start of the edit buffer, SOS performs a wraparound. This means that SOS copies the rest of the file (from the current position to the end) to SOScnn.TMl. At this point, SOScnn.TMl is a complete copy of your original file, with all edits to date incorporated. sos then "rewinds" SOScnn.TMl: it returns to the beginning of the temporary file and starts reading from it. 8-1 SOS INTERNALS Thereafter, SOScnn.TMl serves as the input file for further SOS closes your original file, and does not read it again. editing. After rewinding, SOS creates a second temporary file, SOScnn.TM2, to which it writes lines passed through the edit buffer. SOS continues this pass-through operation until it finds the line referred to in your command. The next time wraparound is necessary, the temporary files switch roles. sos rewinds both files, and uses SOScnn.TM2 (which now contains the most up-to-date copy of the file) for input. sos passes text lines through the edit buffer and writes them to SOScnn.TMl. Neither file is closed. 8.1.2 The Save World Command When you issue a Save World command, the temporary files again effectively switch roles. The temporary file being used for output is renamed to the file specifier given -- or provided by default in the Save World command. SOS closes this renamed file, and then opens it (read-only) for input. The temporary file that was used for input is rewound and thereafter is used for output. If you give another Save World command, or if you give an End command without a new file specification, SOS deletes the file created by the last Save World command before renaming the output temporary file. If you try to recover information from temporary files as described in Section 4.3.4, you may encounter some errors when SOS tries to read data near the end of the file. The errors occur because the file was never closed properly and has no end-of-file mark. You can simply delete the erroneous line(s). 8.2 FORMAT OF TEXT LINES AND PAGE MARKS When stored in a line-numbered file, a line of text generated by SOS is a VAX-11 RMS record. Its type is variable with fixed-length control. The SOS line number comprises the fixed-control access field of the VAX-11 RMS record. The text line has the following format: Byte count n 1 ·Linenum~~r I l·_·. ~~~ char The byte count, a 16-bit integer, is 2 more than the number of characters in the text line. The line number is also a lo-bit integer. The text consists of 500 or fewer characters (represented above by char) that do not include the characters <DEL> or <NU>. No <RET> or <LF> is present to terminate the text line; its end point is implied by the byte count. An sos page mark is represented in a file case of the general format given above: Byte count 3 -1 ·]--] (ff) n•---··-~~- .. .,.,__ ,,,,_<-~-"~~,..~~• 8-2 by the following special SOS INTERNALS When SOS displays such text lines, it prints the line number as a 5-digit ASCII number; prints a <TAB>; prints the n-2 characters of text; and adds a <RET> and <LF> to the line. SOS does not print a page mark as such. Instead, when it displays text on a page other than the current page, it prints PAGE n. first. 8.3 USING SOS EFFICIENTLY In Read-only mode, SOS does not write an output file. The pass-through and wraparound file-writing described above does not occur. For this reason, SOS uses far less system resources in Read-only mode. This is why it is best to use Read-only mode routinely whenever you only need to examine a file. (You might use symbol assignment to define a command such as READ:="EDIT/SOS/READONLY".) The most efficient way to use SOS in Edit mode is to avoid wraparound. You can do this by editing a file sequentially from beginning to end. If you never refer to a line earlier in the file than the position marked by LOCATION, SOS does not wrap the file. You minimize the need for costly and time-consuming file copying. SOS's wraparound behavior explains why writing an output file without line numbers (ES or ET commands) requires more processing time than leaving the line numbers in place (as mentioned in Section 5.4). Suppose, for example, that the current line is in the middle of the file when you issue an ES command. SOS P.asses text through the edit buffer until end of file; rewinds both temporary files; then passes the entire file through a second time, omitting line numbers. SOS then renames the output temporary file to the output name, destroys the other temporary file, and exits. If instead of an ES command you issue an E command, SOS need not pass the file through the edit buffer a second time. After first passing through to end of file, SOS renames the output temporary file to the output name, destroys the other temporary file, and exits. If you want to ignore line numbers, the best approach is to strip them from your input file when you initialize SOS: turn off the SOS switch /LINE by appending /NOLINE as a qualifier to the EDIT command line. With the /LINE switch turned off, SOS ignores any lines already present in the input file and automatically renumbers the file. Use E to exit from the editor; SOS stores the line numbers in the output file (unless you have turned off /SEQUENCE). This method of entering and exiting from SOS avoids using ES to remove line numbers and still produces an input file with uniformly incremented line numbers. The only cost is the small amount of disk space used to store the line numbers in the output file. 8-3 APPENDIX A SUMMARY OF SOS FUNCTIONS AND FEATURES Table A-1 SOS Modes of Operation Mode Prompt Used for Edit * Editing -- adding, changing text Input nnnnn Typing in lines of text Alter nnnnn Editing within a line Alter/insert (none) Inserting text within Alter mode Read-only R* Examining a file without changing it Copy-file C* Searching, copying from another file Decide D* Deciding case by case on substitutions Decide Alter nnnnn (Submode) Like Alter mode (Submode) Like Alter/insert mode Decide Alter/insert (none) A-1 SUMMARY OF SOS FUNCTIONS AND FEATURES Table A-2 Edit-Mode Commands: Function and Fonnat Command Format 1 Function Alter Enter Alter mode for intraline, character-by-character editing. A [range] Copy Copy a range of lines to another place within a file, or from another file. Optionally, enter Copy-file mode. C position[=file-spec] ,range[,incrl [,incr2]] position=file-spec/C Delete Delete a range of lines. D [range] End End SOS, return to DCL. E [BJ [Q) [SJ [T] [:file-spec] Find Search for the occurrence of one or more specified strings of text. F [[string)~ [range] [,A] [,N] [,E] [,n] [,-]] Help Display the help package. H [:n] Input Enter Input mode to insert lines of text. I [position] Join Join two text lines into one line. J [position] Kill Page Mark Delete a page mark. K /page List List a range of lines on the printer or to a file. L [range] [,SJ [ {,P[:file-spec)}) [ { ,F:file-spec }] Mark Insert a page mark. M [position] re Number Renumber a range of lines. N [incr] [, [range] [,start] ] Print Print a range of lines on the terminal. P [range] [,SJ Replace Delete a range of lines and enter Input mode. R [range] [tcr }] ;~~~r [tcr }] ~~~r Substitute Replace one or more text strings with other string(s) in a range of lines. Optionally, enter Decide mode. S [[oldstring~newstring] G ) [range] [,DJ [,NJ [,E]] Transfer Copy a range of lines to a new location and delete the original lines. T position,range[,incrl [,incr2]] Save World Write a new file containing all the changes made so far. W [B] [:file-spec] eXtend Enter Alter/insert mode to add text to the end of a line. X [range] [,NJ Move Position Reset the position of the current line. . position Give Parameter Give the value of an SOS internal parameter or switch. =parameter Set Parameter Reset an SOS parameter or switch. I parameter [:value] Execute Command File Execute the SOS commands contained in a command file. @file-spec ~ Print next line. ~ Print previous line. G) ~ 1 The space after the single-character command is optional. Terminate each command with ~(except the commands ~andG)). A-2 SUMMARY OF SOS FUNCTIONS AND FEATURES Definitions for the Edit-Mode Commands Uppercase letters represent literals that you type verbatim. (SOS accepts either upper- or lowercase letters.) Lowercase terms represent variables, defined below. The symbol => means "is defined as." Brackets ([ ]) indicate optional parts of the argument string (except in directory or file-spec, in which one set of brackets must be typed). Stacked braces ({ }) mean to choose one of the enclosed expressions. Angle-brackets (< >) enclose descriptive terms. And <ESC> represents the escape key (or ALTmode, SELect or PREfix). file-spec =>[device:] [[di rectory]] file name [.type [;version]] increment => <a positive integer line-number increment> l t 1 => <a line number> (less than 05536) line => j 1 * [2: ml m => <an integer line-number off set> n => <a positive integer> p => <a page number> page=>{ : 1[2: q] parameter => <a legal SOS parameter or switch> position line [/page] /page } q => <an integer page-number off set> po s i t ion [ { : po s ~ ~ i on } range =>{ J : position !n start => <a positive integer line number> string=> stringl[ IBITJ [ IBITl string2[ strings[ IBITl IBITl value => <a legal parameter value> A-3 string3 [ IBITJ string~]]]]] string4 SUMMARY OF SOS FUNCTIONS AND FEATURES Table A-3 Meanings of Edit-Mode Command Options Option Commands Meaning ,A Enter Alter mode Find ,D Enter Decide mode Substitute ,D Enter quasi-Decide mode Content specification (a 11 commands) ,E Require exact case match Find, Substitute, content specification (a 11 commands) ,F List to disk file List ,N Type only number, not line Find, extend, content specification with substitute, prints nothing ,P Select printer List ,s Suppress line numbers List, Print Find line in which specified Find, content specification (all pattern does not occur commands) ,n Find n occurrences of specified pattern Find ,n Use nth occurrence of specified pattern Content specification (all commands) , _ __ _ _..&..-_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ~·-- --·-···---····--·--·--------- Table A-4 Alter-Mode Commands Command Meaning ----------·"'··--+-···-··-------------------------------Do not print rest of line; recycle to of line with edits incorporated. beginning [-] [n]Cx ••• Change next/previous characters.l to [-] [n]D Delete next/previous n characters. B [n]J characters End Alter mode for this line; E [-] [n] !text n mJ do not print line. Insert text after/before pointer; increment n for new lines. Split line after pointer; given use temporary use increment n. 1 "Next" if no minus sign is typed: "previous" if minus- sign is typed. The other commands that accept a minus sign are presented in similar fashion. (continued on next page) A-4 SUMMARY OF SOS FUNCTIONS AND FEATURES Table A-4 (Cont.) Alter-Mode Commands Command Meaning [-] [n] Kx Kill (delete) character x. all until nth occurrence of L Print rest of line; recycle to beginning of line with edits incorporated. p Print rest of line; recycle to current with edits incorporated. Q Quit Alter mode; [-] [n] Rtext [-] [n] Sx (@ position restore original line. Replace next/previous n characters with text. inserted Skip forward/back to nth occurrence of character x. [-] [n]W Skip forward/back n words. [-] [n] X Delete next/previous n words. [-] [n],. Invert case of next/previous n characters. [-] [n] < Convert next/previous n characters to uppercase. [-] [n] > Convert next/previous n characters to lowercase. :@ Space back/forward n characters. (8D) Leave Alter mode for this line; line. ® Space back/forward n characters. cw Leave Alter mode for this line; line. [-] [n] ~ Space forward/back n characters. [-] @) Skip to end/start of line. [-] [n] [-] [n] print rest of print rest of ~ Retype line to current position. ©TRL/U) Start fresh -- discard edits, recycle beginning of line, do not print line. to ______________________ A-5 __, SUMMARY OF SOS FUNCTIONS AND FEATURES Table A-5 Decide-Mode Commands Form Meaning or Y Yes, make the change as shown. or N No, do not make the change. A Alter: enter Decide Alter mode already made. with the change E or Q End: G Go: make the change, and make all further changes automatically (leave Decide mode). do not make the change, return to Edit mode. '------------'------------·-·------------·--"""-""-'""--·---·-·------.~~··------ Table A-6 sos Parameters Name 1 Set from Edit Mode? Preset via DCL?2 ! - - - - - - - - ---·-·-·-· ·--·-----" ~" ··- --·- ~·-······-· ..·-·- ~-· ~ Initial Value ... ~.--,..-- Meaning ---- ---·----- ... Displays highest page number BIG n ERROr n (null) Displays last error message ESCApe y (null) Sets character for input/output of escapes ID INCRement y y 100 Sets increment for numbering inserted lines ISAVe y y 0 Controls auto-Won inserts LENGth y 55 Sets page size for List command LOCAtion n "'/1 Displays first line in edit buffer MATCh y (null) NAME n PLINes y y 16 Sets number of lines printed by P~ SAVE y y 0 Controls auto-Won commands STARt y y 100 Sets starting line number STEP y y 100 Sets increment for initial line numbering ST Ring n (null) Displays current Find and Substitute strings SUBStitute n 0 n 00000/1 Displays current SOS version number n Sets special pattern-matching flag character Displays output file specification Displays number of matches in last Substitute Displays current position -------·-1 2 Minimum abbreviation is given in uppercase letters. You can specify these parameters as qualifiers in the initial DCL EDIT command, or by using the symbolassignment mechanism (see Section 6.3). A-6 SUMMARY OF SOS FUNCTIONS AND FEATURES Table A-7 SOS Switches Name 1 Initial Value Preset via DCL?2 BAK DEC Ide on y Tells SOS to create back-up file off y Sets auto Decide mode on Substitute EXACt off EXPErt off y Declares experienced SOS user LINE on y Tells SOS to use existing line numbers LOWEr on y Tells SOS to accept uppercase, lowercase as is NUMbers READonly on y Tells SOS to display line numbers off y SEPArator off Tells SOS to treat_$ . as alphanumeric SEQUence on Leaves output-file line numbers Meaning Requires exact case match for Find, Substitute, contentspecification Starts SOS in Read-only mode 1 Minimum abbreviation is given in uppercase letters. 2 You can specify these switches as qualifiers in the initial DCL EDIT command, or by using the symbolassignment mechanism (see Section 6.3). Tum off any switch by using the letters NO before its name; thus, NOLINE turns off the LINE switch. A-7 ·c- SUMMARY OF SOS FUNCTIONS AND FEATURES Table A-8 Special Pattern-Matching Constructs Construct Internal Representation Meaning Find-String Constructs ?/ ?: ?< ?%x ?)x ?lx ?9 /! ?& ?2 ?+ ?> ?7c tTRL{T) I I tTRL/\) ~ ©TRL/N) ~ tTRL/X) tTRL/A) ©TRL/F) ~ tTRL/P) tTRL/J) tTRL/~) Match any character Match any separator Match a space or tab Match any character except x Match 0 or more of the character x Match 1 or more of the character x Match any alphanumeric character Match any letter (A-Z, a-z) Match any uppercase letter (AZ) Match any lowercase letter ( a-z) Match any decimal digit ( 0-9) Match beginning or end of line Match internal representation of c Substitute-String Constructs ?*l?* The first string matched by a find-string construct ?*2?* The second string so matched ?*n?* The nth string so matched ?" The next string in the sequence matched by a find-string construct Table A-9 Position Shorthand Characters Character /. * I* A-8 APPENDIX B SOS ERROR MESSAGES: NOVICE AND EXPERT FORMS Table B-1 lists the error messages produced by SOS. In the right-hand column are the forms of the messages that SOS prints if the EXPERT switch is on (see Section n.2). All the messages except one are nonfatal: SOS halts the offending command and returns you to Edit mode. The one fatal error is the last one (You confounded SOS. Sorry.). This error does not occur in normal SOS use. If it does occur, SOS returns you to the monitor. See Section 4.3 for possible recovery procedures in this eventuality. Table B-1 SOS Error Messages: Novice and Expert Forms Novice Message Expert Message Bad command file name Cannot access HELP file Cannot access LIST file Cannot delete across pages Cannot kill initial page mark Command invalid for read only file Command line I/O error Failed to open command file Illegal file specification Illegal parameter to switch Illegal search string given Illegal specification in line or page number Illegal specification in range Illegal switch name Illegal syntax of command Insufficient line numbers for insertion Line is too long Line number step too large - lines out of order Lines out of order Maximum command file depth exceeded No such line exists Page does not exist Range given does not contain any lines Search strings exceeded buffer length String not found, search failed Too many search strings given You confounded SOS. Sorry. B-1 Name bad HELP trouble LIST trouble Del no pages K/l bad File RO I/O error Open failure File? Bad param to switch ISS Bad line/page Bad range Bad switch ?? No room Line too long Step too big Order Command files too deep NSL Page? Nothing Too long Not there Too many Internal error INDEX c A Adding lines. See Alter-insert mode, Input mode Alter (A} command, 5-4 Alter-insert mode versus Input mode, 3-8 Alter-insert mode, 2-6, 5-9 Alter mode, 2-6, 5-4 Alter-mode commands B (recycle}, 5-7 <BS>, 5-15 C (change}, 5-8 <CTRL/R>, 5-16 <CTRL/U>, 5-17 D (delete}, 5-9 <DEL>, 5-15 E (end}, 5-9 I (insert}, 5-9 J (split}, 5-11 K (kill characters}, 5-11 L (line}, 5-11 <LF>, 5-16 P (print}, 5-12 Q (quit), 5-12 R (replace}, 5-13 <RET>, 5-15 S (skip}, 5-13 <SP>, 5-16 summary of, 5-5, 5-6 <TAB>, 5-16 W (word}, 5-14 X (delete word}, 5-14 < (convert to uppercase}, 5-14 > (convert to lowercase}, 5-15 "' (invert case}, 5-14 Arithmetic expression in range, 3-6 Asterisk (*}, last line or page, 3-3 At sign (@}, Execute Command File, 5-56 Automatic file saving, 4-2. See also ISAVE parameter and SAVE parameter B Back-up file. See Save World (W} command; End (E} command BAK switch, 6-10, 6-11 BIG parameter, 6-3 Built-in safety features on SOS, 4-2 Caret ("'), first line or page, 3-3. See also Alter mode Characters, control, 1-2 special, 7-9 to 7-12 terminal usage of upper/lowercase, 1-4 Colon (:} , 3-2 Command File (@} command. See Execute Command File (@} command Commands, Alter (A} , 5-4 Copy (C}, 5-18 Delete (D} , 5-22 End (E}, 5-23 Execute Command File (@} , 5-56 extend (X} , 5-51 Find (F}, 5-25 Give Parameter, (=}, 5-54 Help (H} , 5-29 Input (I--Input mode}, 5-30 Join (J}, 5-33 Kill Page Mark (K}, 5-34 List (L}, 5-35 Mark (M} , 5-36 Move Position (.}, 3-4, 5-53, Print (P}, 5-39 reNumber (N}, 5-37 Replace (R} , 5-41 Save World (W}, 4-2, 5-50, 8-2 Set Parameter (/}, 5-55 Substitute (S}, 5-43 to 5-46 Transfer (T} , 5-47 See also Alter-mode; Decidemode; Edit-mode Complete range specification. See Default, line and page number Confirmation before deleting. See Delete (D} command; Replace (R} command Constructs, combining find-string, 7-6 find-string, 7-2 special pattern-matching, 7-1 substitute-string, 7-5 Content, nested, 7-8 specification, range by, 7-6 to 7-8 syntax, 7-8 Index-1 INDEX Control characters, 1-2, 2-6 Conversion of upper/lowercase characters, 5-14, 5-15 Copy (C) command, 5-18 to 5-21 Copy-file mode, 2-5, 5-20 Current line. See Current position Current line-number increment, 3-8 Current position, 3-4 D Decide Alter mode. See Decidemode commands Decide Alter/insert mode. See Decide-mode commands Deaide mode, 2-1, 2-2, 5-46. See also Quasi-Decide mode Decide-mode commands, 2-2, 5-46 Alter (A) mode, 2-2, 5-46 Decide Alter mode, 2-2, 5-46 Decide Alter/insert mode, 2-2, 5-46 DECIDE switch, 6-11 Default, conditions when SOS initiated, 4-1 line and page number, 3-4, 3-5 parameters and switches, n-3 to 6-14 setting by symbol assignment, 6-14 Delete Alter mode and, 5-5, 5-9, 5-10, 5-11, 5-14 Delete (D) command, 5-22 <DEL> character, 1-3 extend command (X) and, 5-51 Kill (K) command and, 5-34 summary of uses, 7-12 Dollar sign ($), 1-3, 6-4 E Edit buffer, 6-6, 8-1 Edit mode, 2-3 Edit-mode commands, 5-1 form and function, 2-4 Efficient use of SOS, 8-3 End (E) command, 5-23 Equal sign (=) , Copy-file mode, 5-20 Give Parameter command, 5-54 Error messages, B-1 ERROR parameter, 6-3 Escape character (<ESC>), as abbreviated Print command, 5-39 use of, 1-3 ESCAPE parameter, 6-4 Execute Command File and, 5-57 EXACT switch, description of, 6-12 substitute options and, 5-46 Execute Command File (@) command, 5-56 Exclamation point (!) 3-2 EXPERT switch, 6-12 error message forms when on, B-1 extend (X) command, 5-51 F Find (F) command, 5-25 Find-string constructs, 7-2 combining, 7-6 Format, internal, of text lines and page marks, 8-2 G Give Parameter (=) command, 5-54 H Help (H) command, 5-29 ID parameter, 6-5 INCREMENT parameter, 6-5 Current-Line Number, 3-8 Initiating SOS, 1-2 Input mode, command (!--Input mode), 5-30 description, 2-2 versus Alter/input mode, 3-8 Inserting lines, Alter/insert mode, 2-6, 5-9 Input mode, 2-2, 5-30 ISAVE parameter, 4-2, 4-3, 6-5 J Join (J) command, 5-33 K Kill Page Mark (K) command, 5-34 Index-2 INDEX L LENGTH parameter, 6-6 Limitations of SOS, 4-1 Line length restriction, 4-1 Line numbers Current, increment, 3-8 defaults for, 3-4 description of, 3-1 how SOS assigns new, 3-7 offsets, 3-6 ranges, 3-2 restrictions, 4-2 when existing line intervenes, 3-8 Line number syntax, 3-7 LINE switch, 6-13 List (L) command, 5-35 LOCATION parameter, 6-6 LOGIN.COM file, 6-14 Lowercase characters, 4-1 uppercase and, 1-4, 5-14, 5-15 LOWER switch, 6-13 M Mark (M) command, 5-36 MATCH parameter, description of, 6-7 Find command and, 7-2 Minus sign (-), Delete command and, 5-9 Find command and, 5-25 line-/page-number offset, 3-6 setting default conditions, 6-14 Modes of operation, Alter, 2-6, 5-4 Alter/insert, 2-6, 5-9 Copy-file, 2-5, 5-20 Decide, 2-5, 5-46 Decide Alter, 2-2, 5-46 Decide Alter/insert, 2-2 description, 2-1 Edit, 2-3, 5-1 Input, 2-2, 5-30 Read-only, 2-3 Modules, Help, 5-29 Move Position (.) command, 3-4, 5-53 Multiple search strings, 5-27, 6-9 Multiple substitutions, 5-45 N NAME parameter, 6-7 Numbers, Line, 3-1 Numbers, (Cont.) new line, 3-7 Page, 3-1 NUMBERS switch, 6-13 0 Offsets, line- and page-number, 3-6 Options, content specification and, 7-7 Decide mode and, 5-46 Find (F) command, 5-27 Substitute (S) command, 5-45 Output file, 1-2 p Page boundary, arithmetic expressions and, 3-6 deleting across, 5-22, 5-42 line-number offset and, 3-6 ranges of line numbers and, 3-2 Page numbers, Copy (C) command and, 5-19 description of, 3-1 format of, 8-2 Mark (M) command and, 5-36 offset, 3-7 syntax, 3-7 Transfer (T) command and, 5-47 Parameters, 6-1 to 6-10 BIG, 6-3 description of SOS, 6-1 ERROR, 6-3 ESCAPE, 6-4 ID, 6-5 INCREMENT, 3-8, 6-5 !SAVE, 4-2, 6-5 LENGTH, 5-35, 6-6 LOCATION, 6-6 MATCH, 6-7, 7-1 NAME, 6-7 PL INES, IS-8 SAVE, 4-2, 6-8 Set Parameter (/) command, 5-55 START, 6-8 STEP, 6-9 STRING, 6-9 SUBSTITUTE, ~-10 Partial range specification. See Default, line and page number Pattern-matching constructs, special, 7-1 Index-3 INDEX Period (.), Move Position (.) command, 5-53 parameter, 6-10 shorthand character, 3-3 PLINES parameter, n-8 Plus sign (+), 3-6 Pointer, current-line, 3-4 intraline, 5-4 Position syntax, 3-2 Print (P) command, 5-39 Q Quasi-Decide mode, 7-8 Question mark, special patternmatching flag, 6-7, 7-1 R Range of line numbers, 3-2 Range, line-number syntax, 3-3 Read-only mode, 2-3 efficiency of, 8-3 ReNumber (N) command, automatic after deletion, 5-22 description of, 5-37 Replace (R) command, 5-41 Restrictions on SOS, 4-1 Return character <RET> as abbreviated Print command, 5-40 s Safety, SOS built-in features, 4-2 SAVE parameter, 4-2, n-8 Save World (W) command, 4-2, 6-8, 8-2 SEPARATOR switch, 6-14 SEQUENCE switch, 6-14 Set Parameter (/) command, 5-55 Shorthand characters, 3-3 Slash (/) file specification qualifiers and, 1-2 line position specification and, 3-2 Set Parameter (/) command, 5-55 Special characters, 7-9 to 7-12 Special pattern-matching, 6-7, 7-1 to 7-9 Specifying ranges by content, 7-6 START parameter, n-8 STEP parameter, 6-9 String length restriction, 4-2 STRING parameter, 6-9 Submodes, 2-2 Substitute (S) command, 5-43 SUBSTITUTE parameter, 6-10 Substitute-string constructs, 7-5 Switches, 6-1, 6-10 to 6-15 abbreviating names of, 6-11 BAK, 6-11 DECIDE, 6-11 EXACT, 6-12, 5-46 EXPERT, 6-12, B-1 LINE, 6-13 LOWER, 6-13 NUMBERS, · 6-13 SEPARATOR, 6-14 SEQUENCE, 6-14 turning off, 6-1, 6-11 Symbol assignment, setting default conditions using, n-14 Syntax, line number, 3-7 page number, 3-7 position, 3-2 range, 3-3 T Temporary files, description of, 8-1 recovering information from, 4-3 Terminating SOS, 1-2 Text line, format of, 8-2 Textual file, 5-24 Transfer (T) command, 5-47 u Up-arrow (+), first line or page, 3-3 See also Alter mode Upper- and lowercase characters, 1-4 conversion, 5-14, 5-15 w World, Save (W) command, 4-2, 6-8, 8-2 Wraparound, 8-1 Index-4 VAX-11 Text Editing Reference Manual AA-D029B-TE READER'S COMMENTS NOTE: This form is for document comments only. DIGITAL will use comments submitted on this form at the company's discretion. If you require a written reply and are eligible to receive one under Software Performance Report (SPR). service, submit your comments on an SPR form. Did you find this manual understandable, usable, and well-organized? Please make suggestions for improvement • . II> c: C) c: 0 ... Did you find errors in this manual? page number • u --------------------------------··-----·--- c :::> If so, specify the error and the II> in c II> L.. Please indicate the type of reader that you most nearly represent. [] Assembly language programmer [] Higher-level language programmer [] Occasional programmer (experienced) [] User with little programming experience [] Student programmer [] Other (please specify) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _~ Organization _ _ _ _ _ _ _ _~------------------------ Ci t Y - - - - - - - - - - - - - - S t a t e - - - - - - - Zip Code _ _ _ _ _ __ or rnnni-ru - - Do Not Tear - Fold Here and Tape II POSTAGE WILL BE PAID BY ADDRESSEE BSSG PUBLICATIONS TW/A 14 DIGITAL EQUIPMENT CORPORATION 1925 ANDOVER STREET TEWKSBURY, MASSACHUSETTS Do Not Tear - Fold Here 01876 No Postage Necessary if Mailed in ti United StatE
Home
Privacy and Data
Site structure and layout ©2025 Majenko Technologies