|
|
EDIT/3000 Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 3 EDIT/3000 COMMANDSINSERT |
|
The INSERT command inserts character strings or lines of text into the WORK file at a specified position, irrespective of line boundaries. The form of the INSERT command is
The INSERT command is used to insert character strings in a line of text in the WORK file or to insert complete lines of text in the WORK file. In an interactive session, EDIT/3000 prompts by displaying the line number referenced in the position parameter and the contents of the line, then displays an arrow under the column, if a column was specified in the position parameter. (If the Q parameter is included in the INSERT command the prompt is not displayed.) A specific column in a line is specified in the position parameter by enclosing the column number in parentheses. For example,
references the 10th column of line 5. If no column is specified, as in INSERT 5, the leftmost column is assumed by EDIT/3000 as determined by the SET LEFT = colnum option in effect (default = column 1). If a column number that is outside the SET LEFT, SET RIGHT options in effect is specified, the INSERT command will not execute and EDIT/3000 will display an error message. (See paragraph 3-92 for a discussion of the SET command.) If the text generated using an INSERT command consists of more characters than are allowed in a line, new lines are created by EDIT/3000 to accommodate the excess characters (and the existing line). In this case, the Editor attempts to break the line at a blank character. New line numbers are determined by the SET DELTA = increment option in effect. The SET DELTA option can be overridden with the BY increment (or,increment) parameter of the INSERT command. If new lines are being inserted before a particular line in the WORK file, the insert command saves that line. This saved line is then added after the new lines, once control Y has been pressed (see example 2 below). If the SET DELTA-increment option in effect (or the BY increment parameter) does not allow enough new line numbers to be added when new lines are being inserted, EDIT/3000 will insert new lines until it can no longer add new line numbers, then terminate the INSERT mode and print an error message, as well as the saved line which was lost from the work file. See the example of this in paragraph 3-55. In an interactive session, the INSERT command may be terminated with CONTROL Y or // in any one of four ways:
In batch mode, only // may be used either as the last two characters in a line of characters to be inserted or as the only two characters in a record. The results are the same as shown in the preceding examples 3 and 4. Text can only be inserted in a line beginning at a column within the SET LEFT, SET RIGHT margins established for that line. An existing line number must be specified in the position parameter for the INSERT command (unlike the ADD command, which can specify ADD 5.1 to insert the line 5.1 between the existing lines 5 and 6). The following examples show several variations of the INSERT command. The location of the pointer is illustrated after the conclusion of each INSERT command.
The following example illustrates how to insert a line into the WORK file. To insert a new line before line 7, the command INSERT 7 is used. EDIT/3000 prompts with the number 7 and the new line is entered and RETURN is pressed. When 7.1 is displayed by EDIT/3000, // is entered. The pointer is located at the first position of line 7.1, which is the old line 7. The LIST 6/8 command shows the positions of the inserted line and the previous line 7.
The following example illustrates the error message which is printed if the SET DELTA=increment option in effect does not allow new line numbers when new lines are being inserted. TEST is listed and INSERT 1.998 is used to insert two new lines. A carriage return is pressed after each line. Since the SET DELTA= increment option does not allow any more new line numbers, a warning message is printed out, as well as the saved line (the line originally on line 1.998) which is now lost from the WORK file.
To insert text before a position in a line, the position number is specified in parentheses as shown in the next example. The text (HELD,) is entered and // is entered before RETURN.
If you wish to make two lines out of an existing line, use the INSERT command as shown in the following example. The FINDQ FIRST;FIND "OPERATING" commands locate the desired position where the line is to be split. Entering the INSERT 4(28) command and then //after RETURN creates a new line (4.1) and the previous line 4 is now two lines.
Another way to accomplish the same thing is to use the FIND "OPERATING" and INSERT * commands, then enter // after RETURN. For example
When the INSERT linenumber, HOLD form of the INSERT command is used, text is entered from the input file and, when the end of this text is signalled, the contents of the HOLD file are inserted. Note from the example below that EDIT/3000 compresses the contents of the HOLD file by adding words from the next record to the current record. (The word "LINES" from the second record is added to the end of the first record, and "REPLACED" from the third record is added to the end of the second record.) When- ever an insertion from the HOLD file is made, it is similar to a justification process. The EDITOR tries to fill out lines with words up to the RIGHT margin. If the line is longer than the value of the RIGHT parameter, the EDITOR breaks it at a blank and inserts the remainder on the next line. If the new line becomes full, the EDITOR breaks it to continue on the next line and so forth. If the HOLD file contains a blank line, it causes the current line to be completed but no blank line is inserted into the work file. Insertion would then continue to the next line. If the HOLD file has two blank lines, only one blank line gets inserted. If the HOLD file has three blank lines, 2 blank lines are inserted and so on. The original line 5 start sat the end of the last HOLD file record. (The string (MPE/3000)from the original line 5 is appended to the end of the last HOLD file record entered into the WORK file.)
When this form of the INSERT command is used, the HOLD file contents are inserted before the line specified in the linenumber parameter and no text is inserted from the input file first (as it was in the previous example). Note that the HOLD file contents, however, are compressed the same as in the previous example.
|
|