Model 204 line editor

From m204wiki
Revision as of 21:46, 7 April 2016 by ELowell (talk | contribs) (→‎Syntax)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Overview

The Model 204 line editor allows you to edit procedures on line-at-a-time terminals.

Two editors

Model 204 provides the following editors, which you can use to enter, change, or add text to Model 204 requests and procedures:

Full-screen editor

Available for full-screen terminals.

Line editor

Available for line-at-a-time terminals. Optionally, you can invoke this editor from a full-screen terminal.

Editing capabilities

The line editor provides the following editing functions:

  • Positioning a pointer at any character or line in the text
  • Displaying a line number or a specified portion of the text
  • Replacing lines or characters in the text
  • Inserting lines or characters
  • Deleting lines or characters
  • Combining several procedures into a new procedure

Invoking the line editor

You can invoke the line editor in the following ways:

  • Directly from Model 204 command level
  • Indirectly in a SOUL request

Entering the EDIT command

For full-screen terminals, invoke the line editor by using a special option of the EDIT command (see Invoking the editor).

After invoking the line editor, you can execute any of the commands described in this topic.

For line-at-a-time terminals, to invoke the line editor, enter:

EDIT

Optionally, you can specify the name or number of the text to be edited. The system responds by displaying:

M204.0526: EDITING INTO name

The use and construction of line editor names and numbers are discussed below.

EDIT command restrictions

The following restrictions apply to line editor input and commands:

  • You can issue the EDIT command within a procedure, but you must not included it within a request in the procedure. That is, the command must not fall within the scope of a BEGIN;...END sequence. Furthermore, an EDIT command cannot modify the procedure in which it occurs.
  • If you include the EDIT command within a SOUL request entered at a terminal, invoking the editor closes any USE ddname data sets that you have open.
  • EDIT is recognized in ad hoc requests even when the editor is not included in the system. If the line editor is not available, the following message appears:

*** M204.1039: FEATURE NOT LINKED IN

Calling the line editor indirectly

If you call the editor while entering a request, the word EDIT followed by a space must be the first five characters of a line. This line is not included in the request. Note that this affects the use of EDIT in field names. The following lines do not generate a valid request:

FIND AND PRINT COUNT TITLE = WUTHERING HEIGHTS TYPEFACE = GOTHIC EDIT = PENDING

(space after EDIT)

However, the following line is valid as part of a request:

EDIT=PENDING

(no space after EDIT)

Uppercase and lowercase in procedures

You can enter lowercase characters in a procedure. However, Model 204 does not necessarily process these characters as lowercase. Unless the Model 204 command, *LOWER, was specified before entering the line editor, characters are translated automatically into uppercase when they are transmitted to Model 204. For more information about lowercase and uppercase usage, see *UPPER command and *LOWER command.

Editing an existing request, procedure, or other text

The format of the EDIT command is the following:

Syntax

EDIT [n | name]

where n or name indicates the number or the name of the request, procedure, or other text to edit.

Follow these guidelines:

  • If you specify EDIT or EDIT 0, temporary procedure 0 is edited.
  • If n is a negative number (-n), temporary procedure -n is edited. -n can also represent a previous request.
  • If name is an alphanumeric string, the named permanent procedure is edited. The alphanumeric string can contain any letter, number, or other symbol, except:
    • Space
    • Comma
    • Semicolon
    • Minus sign
    • Equal sign
    • Single quote
    • Carriage return

    Note: Most of the above characters are permitted if CUSTOM=42 is turned on.

    A procedure name cannot begin with a minus sign. And in version 7.6 and lower, a name cannot begin with a zero. The maximum length of a name is 255 characters.

For more information about permanent and temporary procedures, see the EDIT command.

Defining new procedures

Use the following form of the EDIT command to indicate that a new name is being defined for the edited text:

Syntax

EDIT [name1 [,m |,name2]]

where:

name1 Represents either a temporary or a permanent procedure that you want to change.
m Is the new temporary procedure number.
name2 Is the new permanent procedure name.

Follow these guidelines:

  • If m is 0, temporary procedure 0 is defined.
  • If m is a negative number (-m), temporary procedure or previous request -m is defined.
  • If name2 is an alphanumeric string, permanent procedure name2 is defined.

If name2 already exists, the system verifies that you want to replace it by responding:

M204.1076: DO YOU REALLY WANT TO EDIT INTO EXISTING PROCEDURE?

Respond with Y (yes) or N (no). If your response is N, the existing procedure is not affected and the system returns to command level. If your response is Y, the system replaces the existing procedure (name2) with the new definition. This message is not displayed for temporary procedures; the editor simply stores the new text in place of an earlier temporary procedure or previous request.

After replacing a procedure, the new definition of procedure name2 is an edited copy of procedure name1. The original procedure name1 is not changed. This form of the EDIT command allows a procedure to be copied, with or without changes.

For example:

EDIT -2, TEST

In this example, you want to edit temporary procedure -2, and to save the edited result under the procedure name, TEST. Temporary procedure -2 is not altered by the editing.

When you create a new procedure with the editor, be aware that, if a procedure already exists under that name, you must satisfy the security rules for updating the procedure. If you do not have the appropriate privileges to update an existing permanent procedure, the system displays the following message:

M204.1176: CAN'T EDIT INTO name

where name identifies the existing procedure.

For more information about security and file privileges, see LOGCTL command and PRIVDEF parameter.

Setting the end-of-line character

Use the LINEND parameter to set the logical end-of-line character to any single character. The default value of LINEND is a semicolon.

When you issue the PROCEDURE command to create a procedure, the current value of LINEND is stored as part of the procedure and becomes the procedure's physical end-of-line character. This character is carried through all editing.

If a procedure that was created with LINEND set to semicolon is edited by a user who has set LINEND to some other character, any semicolon inserted during editing is treated as an end-of-line character the next time the procedure is included.

If a procedure that was created with a LINEND semicolon is included by a user who has a LINEND of some other character, both characters are treated as end-of-line characters (semicolon for physical lines and the user's LINEND for logical lines).

Using line editor commands

This section describes some key concepts involved in using the line editor, as well as general guidelines for using line editor commands.

This section describes how to enter, repeat, and cancel line editor commands. It also provides a summary of editor restrictions.

Pointer

All commands to the editor utilize a pointer that points to one character in the character string. Some of the commands position this pointer; others add, delete, or print characters based on its position. When the pointer is at any character other than the first character of a line, the system prints a pound sign (#) in front of that character when printing the line. In the examples used in this section, the pointer is represented as an underscore ( _ ) where the pound sign would not appear at the terminal. The underscore itself does not appear at your terminal.

When you invoke the editor, the pointer is positioned initially at the beginning of the text that is being edited.

Character strings

A procedure can be considered not only as a series of statements and commands, but also as a string of characters, each line ending with a carriage return character, which is sometimes represented by a semicolon (;) as shown in the following examples.

For example, you enter the following text:

BUICKS: FIND ALL RECORDS FOR WHICH MAKE = BUICK

This text appears to the editor as the following character string:

BUICKS: FIND ALL RECORDS FOR WHICH; MAKE = BUICK;

Entering line editor commands

Enter line editor commands one after another, with one or more commands on a line. Commands are performed one line at a time. You can separate commands with blanks, but this spacing is not required. The following two command strings are equivalent:

JL2T J L 2T

Commands are summarized in the line-editor command summary. A sample procedure using line editor commands is provided in the Line editor example section.

Repeating commands

When the editor encounters a command, it normally executes the command just once. However, if a sequence of editor commands is included in parentheses, the editor performs these commands as many times as you specify. The format of this repetition is as follows:

Syntax

n(commands)commands

where n indicates the number of times that the parenthesized commands are to be executed and can be any positive number.

If you omit n, a value of 100 is assumed and the sequence is executed 100 times. The commands outside the parentheses are executed only once.

As with a regular execution of a search or replace command, the editor displays the following message if the specified string cannot be found or if the editor cannot locate n occurrences of the string in the text:

M204.0529: NOT FOUND. WILL IGNORE REST OF LINE

If you do not specify n outside the parentheses, this message appears if there are fewer than 100 occurrences of the specified string.

You might want the editor to find and replace as many occurrences of a string as there are in the text. If you do not want to specify the precise number in the command, append a colon (:) to repeat S and R commands and to suppress the printing of the NOT FOUND error message.

Canceling line editor commands

The editor ignores the current command if the following phrase is entered in the first seven columns of an input line:

*CANCEL

If the current command already was completely entered, *CANCEL functions as a comment and has no effect on editor operations. For example:

Y.NEW LINE (command already completed)
*CANCEL

However, if the current command was not completely entered, *CANCEL causes it to abort:

R/END/AND (user has not entered final delimiter)
*CANCEL

The system responds with the following message:

M204.0528: REST OF LINE IGNORED. CANCELED OPERATION = R

Line editor restrictions

The following restrictions apply to line editor input and commands:

  • Trailing blanks immediately preceding the carriage return are deleted from every input line.
  • Any character after the last carriage return in a procedure is ignored outside the editor.
  • Input and command strings in parentheses cannot be longer than 255 characters.
  • Single lines read from a procedure cannot be longer than 255 characters outside the editor. The length can be further restricted by the setting of the LIBUFF parameter. There is no restriction on the length of a line that is being edited. Usually this condition is not detected until an attempt is made to use the edited procedure.
  • The total number of characters inserted by a single editing session cannot exceed the value of an installation's PAGESZ parameter minus 40 (just over 6000 for most installations).

Controlling the pointer and displaying text

The line editor pointer and display commands perform the following functions:

  • Position the pointer at the beginning or end of a procedure or other text, or at a specified position, character, line, or string
  • Display the current line number or a portion of the text that is being edited

Pointer and display commands are text retrieval commands; they are not used to modify text.

This section describes the commands that perform the following tasks:

  • Initializing the pointer
  • Positioning the pointer at the end
  • Spacing the pointer by character
  • Spacing the pointer by line
  • Displaying the current line
  • Displaying text

Initializing the pointer (J)

The J command positions the pointer at the first character of the text. The format of the J command is as follows:

Syntax

J

For example, a procedure consists of the logical lines:

NOW IS THE TIME FOR ALL GOOD MEN TO COME

The J command positions the pointer at the first character of the text:

NOW IS THE TIME;FOR;ALL GOOD MEN;TO COME;

If a number precedes the J, nJ, the pointer is moved n lines forward (if n is positive) or backward (if n is negative) within the text. The nJ command is equivalent to JnL. See Spacing the pointer by lines for details.

Positioning the pointer at the end (Z)

The Z command positions the pointer immediately past the last character in the string (the carriage return). Use the Z command to add new lines to the end of the existing text.

The format of the Z command is as follows:

Syntax

Z

For example, the pointer is positioned as shown in the following example, when you issue the Z command:

NOW IS THE TIME;FOR;ALL GOOD MEN;TO COME;_

Spacing the pointer by character (C)

The C command moves the pointer a specified number of characters to the left or right within the text. The format of the C command is as follows:

Syntax

nC

where n is the number of characters that the pointer is moved.

The direction of movement is based upon the value of n, as follows:

  • If n is negative, the pointer is moved n characters to the left.
  • If n is positive, the pointer is moved n characters to the right.
  • If n is omitted from the command, n = 1 is assumed and the pointer is moved one character to the right.

For example, the pointer is set to the beginning of the string:

NOW IS THE TIME;FOR;ALL GOOD MEN;TO COME;

Then either of the commands, C or 1C, moves the pointer as follows:

N#OW IS THE TIME;FOR;ALL GOOD MEN;TO COME;

From this position, the command 15C results in:

NOW IS THE TIME;FOR;ALL GOOD MEN;TO COME;

The editor treats the carriage return as any character in the character string. To move the pointer back again, issue the following command:

-3C

This command moves the pointer as follows:

NOW IS THE TI#ME;FOR;ALL GOOD MEN;TO COME;

Spacing the pointer by lines (L)

The L command moves the pointer one or more lines forward or backward within the text. The format of the L command is as follows:

Syntax

nL

where n is the number of lines to be moved.

The direction of movement is based upon the value of n, as follows:

  • If n is negative, the pointer is moved to the (n+1)th previous carriage return.
  • If n is positive, the pointer is moved past the nth carriage return.
  • If n is omitted from the command, n = 1 is assumed and the pointer is moved just past the next carriage return.

For example, suppose that you do not know where the pointer is positioned and want to point to the beginning of the third line of the text. To reset the pointer to the beginning of the text (J), and then move the pointer forward or down past two carriage returns to the beginning of the third line (2L), enter:

J2L

The following command now advances the pointer to the beginning of the next line:

L

Including zero as n results in a special use of the L command:

0L

This command moves the pointer to the beginning of the current line.

Displaying the current line number (=)

The = command returns the line number of the line at which the pointer is currently positioned. For example, when you enter the following text:

AUTOS: FIND ALL RECORDS FOR WHICH MAKE = BUICK AND COLOR = BLUE END FIND FOR #EACH RECORD IN AUTOS PRINT MAKE AND YEAR TO 45 END FOR

If you issue the = command, the current line number appears as follows:

3

The number displayed is the number of lines past the first line in the text. If the pointer is currently positioned at the first line, the = command displays a 0.

If the pointer is at the line past the last line, the = command prints the number that the line would have if it existed. For the previous text shown, the sequence Z= positions the pointer past the last line and displays:

6

Displaying text (T)

The T command displays one or several lines of text or an entire procedure. The formats of the T command are as follows:

T Displays one line
nT Displays n lines
HT Displays all of the text being edited
nHT Displays n surrounding lines

where n can be any integer.

To display the entire line on which the pointer is currently positioned, enter:

T

For example, to display the first line of text, enter:

JT

Using the example from the previous section, the editor would respond with:

AUTOS: FIND ALL RECORDS FOR WHICH

You can use the nT form of the T command to display more than the current line; n can be any number greater than 1. For example:

J2T

This command causes the editor to print two lines: the current line and the one following:

AUTOS: FIND ALL RECORDS FOR WHICH MAKE = BUICK AND COLOR = BLUE

If n is greater than the number of lines in the text, the editor displays all lines from the current line to the end.

The HT command displays all the text that is currently being edited. The nHT command displays the n lines surrounding the line at which the pointer is currently positioned. nHT displays a group of n consecutive lines; the line currently pointed at is near the middle of the group.

The T command does not change the position of the pointer. After the previous example is performed, the pointer is still at the beginning of the text.

To display the lines preceding the pointer without resetting the pointer, use a negative number in the command, as follows:

-nT

This form of the T command displays the previous n lines, up to the pointer in the current line. For example:

2LT-2T

This command moves the pointer down two lines, prints the third line, and then prints the previous two lines:

_ END FIND AUTOS: FIND ALL RECORDS FOR WHICH MAKE = BUICK AND COLOR = BLUE

Using the numbers 0 and 1 with T result in special action by the editor, as follows:

  • 0T displays the part of the line before the pointer.
  • 1T displays the part of the line after the pointer, beginning with the character at which the pointer is positioned. Thus, 1T is not equivalent to T.

With the pointer positioned as in the above example, the commands 13CT1T0T move the pointer 13 characters to the right and then display:

END F#IND IND END F#

The 1T and 0T commands determine the location of the pointer in the text.

Searching for and replacing text

You can search for text strings, and, if desired, replace them with a different text string.

These commands provide another method for moving the pointer around in a procedure. For more information on repositioning the pointer, see Controlling the pointer and displaying text.

Searching for characters (S)

The S command searches the text by starting at the current position of the pointer and moving the pointer just past the next occurrence of a specified string. The format of the S command is as follows:

Syntax

SdXYZd

where:

XYZ Is the string to be found. The search string XYZ can be up to 255 characters in length and can contain carriage returns.
d

Is any character (except a blank) that does not occur in the string XYZ. The d character delimits the string being searched for and ends the command.

Suppose that the text to be edited consists of the following lines:

AUTOS: FIND ALL RECORDS FOR WHICH MAKE = BUICK AND COLOR = BLUE END FIND FOR EACH RECORD IN AUTOS PRINT MAKE AND YEAR TO 45 END FOR

You want to add another condition to the FIND statement. For example:

MAKE = BUICK OR DODGE AND COLOR = BLUE

First, position the pointer immediately past MAKE = BUICK. There are several ways to do this. One positioning method requires counting lines and characters to the desired position, and entering one of the following:

JL23C

or

J L 23C

These commands reset the pointer to the start of the text, move down one line, and then space 23 characters (including the eleven blanks at the beginning of the line and the blanks surrounding the equal sign) into the second line.

An easier way to accomplish the same result, however, would be to use the S command in one of the following ways.

Note that the J command is included in these examples to ensure that the search begins at the beginning of the text:

JS/MAKE = BUICK/ (Slashes are delimiters.) JS.E = BUICK. (Periods are delimiters.) JS=BUICK= (Equal signs are delimiters.)

All these commands result in the positioning of the pointer as follows:

MAKE = BUICK# AND COLOR = BLUE

When an S command is performed, the editor searches for the first occurrence of the character string enclosed by the delimiters. The search begins at the current pointer position.

Setting a delimiter

You can use any character as a delimiter. However, the delimiter character cannot be included in the string.

The previous examples illustrate the use of three different delimiters. In the third example, an equal sign (=) is used as the delimiter. This is acceptable because = is not a part of the character string (BUICK). = could not be used in either of the first two examples, because it is included as a character in the string. Thus, the following command is not valid:

JS=MAKE = BUICK =

In this example, the editor assumes that the first and second occurrences of = are the delimiters and searches for MAKE (that is, everything up to the second occurrence of the delimiter). The text after the second =, BUICK, is recognized as a possible repetition factor, not as a part of the string. The final = is treated as a request for the line number. See Displaying the current line number (=).

Searching for other occurrences (nS)

The previous examples searched for only the first occurrence of a character string; however, the S command is not limited to searching for only the first occurrence. You can search for the nth occurrence of the string XYZ by prefixing the S command with a counter number, n. The format is as follows:

Syntax

nSdXYZd

where n is any positive number.

Consider the following example:

AUTOS: FIND ALL RECORDS FOR WHICH MAKE = BUICK AND COLOR = BLUE END FIND FOR EACH RECORD IN AUTOS PRINT MAKE AND YEAR TO 45 END FOR

Suppose that you want to position the pointer immediately past MAKE in the PRINT statement. This is the second time that MAKE occurs in the text, so you enter:

J2S/MAKE/

J is entered to ensure that the search starts at the beginning of the text. If the desired string does not occur between the point at which the search was begun and the end of the text, the following error message is displayed:

M204.0529: NOT FOUND. WILL IGNORE REST OF LINE

The pointer is reset to its position just before the unsuccessful invocation of the S command.

You enter the following:

J3S/MAKE/

The pointer remains positioned after the second occurrence of MAKE, because there is not a third occurrence of MAKE.

The S command does not find overlapping occurrences of the specified character string. Consider the situation in which the editor searches for occurrences of AA in the string AAAA. The S command finds AAAA and AAAA, but not AAAA.

Replacing a character string (R)

The R command replaces one or more occurrences of a specified character string with another character string. The format of the R command is as follows:

nRdXYZdABCd

where:

n Is a repetition factor.
XYZ Is the string to be replaced.
ABC Is the new string.
d Is the delimiter.

Starting at the current pointer location, R searches for the next n occurrences of XYZ and replaces all those occurrences with ABC. If n is omitted from the command, n = 1 is assumed, and only the first occurrence of XYZ is replaced. Both of the strings, XYZ and ABC, can be up to 255 characters in length and can contain carriage returns. The delimiter, d, can be any character (except a blank) that does not occur in the strings.

After the R command is executed, the pointer is set to just past the last character of the last substitution of ABC. If the string to be replaced cannot be found in the text, the following error message is displayed:

M204.0529: NOT FOUND. WILL IGNORE REST OF LINE

The pointer remains where it was. This message also appears if you include n in the command, and the editor finds at least one, but not n, occurrence of the string to be replaced. In this case, after execution of the R command, the pointer is left positioned just past the last successful substitution.

All occurrences of XYZ that are found by the editor are properly replaced by ABC. For example, you enter:

3R 'FINE'FIND'

The editor finds only two occurrences of FINE in the text. The following events occur:

  • Two occurrences of FINE are replaced by FIND.
  • NOT FOUND message is displayed.
  • Pointer is positioned just past the D of the second substituted FIND.

In the following text, the word COLOR is incorrectly typed as COLPR:

BUICKS: FIND ALL RECORDS FOR WHICH MODEL = BUICK END FIND FOR EACH RECORD IN BUICKS PRINT MODEL AND COLPR END FOR

To correct the mistake, enter:

JR.COLPR.COLOR.

This command searches the text from the beginning for the string COLPR and, upon locating it, replaces it with the string COLOR. The resulting line is:

PRINT MODEL AND COLOR

The replacement string need not have the same length as the original string. The following command successfully changes both occurrences of MODEL to MAKE:

J2R/MODEL/MAKE/:

The text then consists of:

BUICKS: FIND ALL RECORDS FOR WHICH MAKE = BUICK END FIND FOR EACH RECORD IN BUICKS PRINT MAKE AND COLOR END FOR

Editing text

You can replace, insert, and delete lines, characters, and character strings by using the change commands. Most of these commands require that the pointer be properly positioned at the text to be changed before you issue the change commands. Several of the commands explicitly reposition the pointer after making the specified change.

In addition to editing characters, lines and strings, you can use change commands to combine several existing procedures into a new procedure.

Replacing a line (X)

The X command replaces the entire current line with the line that you enter following the X. The format of the X command is as follows:

Syntax

Xline

The command sets the pointer to the beginning of the next line. Consider the following sample text:

AUTOS: FIND ALL RECORDS FOR WHICH MAKE = BUICK AND COLOR = BLUE END FIND FOR EACH RECORD IN AUTOS PRINT MAKE AND YEAR TO 45 END FOR

To replace the second line of this example, position and check the pointer as follows:

JLT _ MAKE = BUICK AND COLOR = BLUE

Enter:

X YEAR = 82

This command replaces the entire original line with:

YEAR = 82

You can enter the entire command string on a single line as:

JLTX YEAR = 82

Note: To have these spaces appear in the line, enter spaces before a string.

The text now consists of the following lines:

AUTOS: FIND ALL RECORDS FOR WHICH YEAR = 82 END FIND FOR EACH RECORD IN AUTOS PRINT MAKE AND YEAR TO 45 END FOR

Inserting a line (Y)

The Y command inserts a line between existing lines in the text. The format of the Y command is as follows:

Syntax

Yline

The line that you enter following the Y is inserted after the previous carriage return (that is, just before the line at which the pointer is positioned). The pointer is positioned at the beginning of the line after the inserted line.

For example, you want to add the following text to the FIND statement of the original example:

YEAR = 82

You can insert the new condition either before or after the existing line by entering:

J2LY YEAR = 82 -2L3T

The above command places the new condition after the existing line. The T command displays the following lines:

MAKE = BUICK AND COLOR = BLUE YEAR = 82 END FIND

You can include a line number before the Y to insert text before a line other than the current line.

The effect of the command n Y is identical to that of n LY. n defaults to zero if it is not present in the command.

Deleting a line (K)

The K command deletes one or more lines or part of a line. The formats of the K command are as follows:

This format... Performs this action...
K Deletes the entire current line.
1K Deletes from the current pointer location to the end of the line, including the carriage return.
0K Deletes from the beginning of the line up to the current character. The pointer is not moved and is left positioned at the character immediately after the deleted string.
nK Deletes from the current pointer location to the end of the line, including the carriage return, and the n -1 following lines.
-nK Deletes from the beginning of the line up to the current character, and the preceding n lines as well.
HK Deletes all the text that is being edited.
nHK Deletes the group of n lines surrounding the current line.

If n is even, nHK deletes n/2 lines before the current line, the current line, and (n/2) -1 lines after the current line.

If n is odd, nHK deletes (n-1)/2 lines before the current line, the current line, and (n-1)/2 lines after the current line.

The text deleted by this method is the same text that would be printed by nHT.

For example, the following commands return the sample text to its original form and display:

J2LK-1L2T

The result of these commands is:

_ MAKE = BUICK AND COLOR = BLUE END FIND

Inserting a character (I)

The I command inserts a specified character or string of characters just before the current pointer location. The format of the I command is as follows:

Syntax

IdXYZd

where:

XYZ Is the character string to be inserted. The inserted string, XYZ, can be as long as 255 characters in length and can contain carriage returns.
d Is any character (except a blank) that does not occur in the string XYZ. The d character delimits the string that is being inserted and ends the command. Its function is identical to that of the delimiter in the S command.

After the I command is executed, the pointer is reset to just past the last character of the inserted string.

Suppose that you want to change the following statement:

PRINT 'EMPLOYEE ADVANCES TO DATE'

to

PRINT 'EMPLOYEE CASH ADVANCES TO DATE'

To make this correction, issue the command:

S/EMPLOYEE/I/ CASH/

The I command is not limited to adding characters within a line; you can also use it to insert any number of lines. Consider the following lines:

AUTOS: FIND ALL RECORDS FOR WHICH MAKE = BUICK END FIND FOR EACH RECORD IN AUTOS

You can add additional retrieval conditions to the FIND statement. For example, you want to add:

OR MAKE = DODGE AND YEAR = 82 AND COLOR = BLUE

Enter the following command string:

S/BUICK/I/ OR DODGE YEAR = 82 COLOR = BLUE/J99T

This command string results in:

AUTOS: FIND ALL RECORDS FOR WHICH MAKE = BUICK OR DODGE YEAR = 82 COLOR = BLUE END FIND FOR EACH RECORD IN AUTOS

Note: The action of the S, I, and R commands is controlled by the delimiter, not by the carriage return. Thus, when the editor encounters I/ (or I followed by any delimiter), it treats carriage returns as part of the character string until the second delimiter is encountered.

Deleting a character (D)

The D command deletes the character at which the pointer is currently positioned and resets the pointer to the next character. The format of the D command is as follows:

Syntax

D

The command also has the following forms:

nD -nD

These formats delete the next (n) or previous (-n) characters in the text. Thus, to remove the second retrieval condition (that is, AND COLOR = BLUE) from the previous example, enter the following commands:

23C17DJ99T

Combining procedures

The I command combines several existing procedures, saved requests, or other text into a single new procedure. The format of this command is as follows:

Syntax

[n |'name'] I

where:

n Can be zero or a negative integer.
name Is the name of a procedure, enclosed in single quotes.

The editor inserts temporary procedure -n or procedure name just before the character at which the pointer is currently positioned. The procedure that is being included remains unchanged. A carriage return included in the procedure name is ignored, but any other invalid character causes an error to occur.

In the following example, three procedures are defined, and then combined and defined as a new procedure.

First, a temporary procedure is defined:

PROCEDURE -2 *** M204.1144: DEFINE PROCEDURE BEGIN CATEGORY.A: FIND ALL RECORDS FOR WHICH TOTAL PREMIUM IS GREATER THAN 300 AGENT = GOODRICH OR BATEMAN CITY = SACRAMENTO END FIND END PROCEDURE *** M204.1146: PROCEDURE DEFINITION ENDED

Next, the two procedures that are to be permanently retained are defined:

PROCEDURE SUBSET *** M204.1144: DEFINE PROCEDURE COUNTER: COUNT RECORDS IN CATEGORY.A PRINT COUNT IN COUNTER END PROCEDURE *** M204.1146: PROCEDURE DEFINITION ENDED PROCEDURE AGENTPRINT *** M204.1144: DEFINE PROCEDURE FOR EACH RECORD IN CATEGORY.A PRINT FULLNAME AND AGENT AT 30 END END PROCEDURE *** M204.1146: PROCEDURE DEFINITION ENDED

Finally, the procedures are combined by means of the editor. First, enter:

EDIT -2, SACRAMENTO

This command invokes the line editor and indicates that editing is to be performed on temporary procedure -2 and that the result is to be stored as procedure SACRAMENTO.

The following command sets the pointer to the end of procedure -2, then attaches procedure SUBSET, and leaves the pointer set just past the new end:

Z'SUBSET'I

Use the following command to attach procedure AGENTPRINT:

'AGENTPRINT'I

The END command terminates line editor operations and stores the result in procedure SACRAMENTO:

END *** M204.0542: EDIT COMPLETE - END

Use the following command to display the combined procedure:

DISPLAY SACRAMENTO BEGIN CATEGORY.A: FIND ALL RECORDS FOR WHICH TOTAL PREMIUM IS GREATER THAN 300 AGENT = GOODRICH OR BATEMAN CITY = SACRAMENTO COUNTER: COUNT RECORDS IN CATEGORY.A PRINT COUNT IN COUNTER FOR EACH RECORD IN CATEGORY.A PRINT FULLNAME AND AGENT AT 30 END

Leaving the line editor

Use the following commands to exit from the line editor:

END Saves the results of the editing and returns to command level.
GO Saves the results of the editing and performs an INCLUDE command.
QUIT Stops without modifying any text and returns to command level.

END and GO commands

The following commands cause the editor to save the results of the editing:

Syntax

[m |'name'] END [m |'name'] GO

where:

m Can be 0 or a negative number.
name Is an alphanumeric string (for example, TEST).
END Returns control to command level, which implies that the next line entered must be a system control command.
GO Causes the system to take the next line of input from the edited text.

The system responds with either:

M204.0542: EDIT COMPLETE - END

or

M204.0542: EDIT COMPLETE - GO

If m or name is included in END or GO, the effect is the same as calling the editor with the following command:

EDIT [name1 [,m |,name2]]

In both the END and GO commands, m can be zero or a negative integer, and name is the name of a procedure. The editor saves temporary procedure m or procedure name before it exits. A carriage return included in the procedure name is ignored, but any other invalid character causes an error to occur.

If procedure name already exists, the system displays the confirming message shown for EDIT in the preceding discussion.

After an END or GO command that specifies a procedure name or number is executed, m or name is an edited copy of the procedure that was just edited. The original procedure is not changed.

The m or name argument included in END or GO overrides the m or name included in the EDIT command. This is useful if a user who has no update privileges tries to edit a permanent procedure. In this case, entering END or GO causes the following message to be displayed:

M204.0539: CAN'T EDIT INTO PROCEDURE

The user remains in the editor. The user can then save the edited copy as a temporary procedure or under a new name. The name is shown in the message only if a name was specified in the END or GO command.

Line editor example

The following example illustrates an edit session using the line editor. This example uses the CLIENTS file:

EDIT POLICY *** M204.0526: EDITING INTO POLICY HT BEGIN GET.POL: FIND ALL RECORDS WHICH POLICY NO = 100035 STATE - OHIO END FIND FOR EACH RECORD IM GET.POL. PRINT FULLNAME AND DATE OF BIRTH

The procedure has various errors in it, including typing errors, omissions, and incorrect specifications. Correct the following errors:

  • Omission of the word FOR in the first statement
  • Keying of - instead of = on the third line
  • Misspelling of IN (as IM) on the fifth line
  • Inclusion of a period after GET.POL

Set the pointer to the beginning of the procedure using the following command:

J

Correct the errors as follows:

32CT Space 32 characters to position the pointer and display the line.

GET.POL: FIND ALL RECORDS# WHICH

I/ FOR/ Insert FOR before WHICH. R/-/=/ Replace occurrence of - with =. R/IM/IN/ Replace occurrence of IM with IN. 8CD Space eight characters and delete the period. -5T Display the previous four lines plus the current line (up to the pointer) for verification.

GET.POL: FIND ALL RECORDS FOR WHICH POLICY NO = 100035 STATE = OHIO END FIND FOR EACH RECORD IN GET.POL#

Next, insert additional retrieval conditions to:

  • Change STATE = OHIO to STATE = OHIO OR NEW YORK.
  • Insert SEX = M.

JS/OHIO/ Search for occurrence of OHIO. I/ OR NEW YORK/ Insert words after OHIO. LY SEX = M Skip to next line and insert new condition. J5T Display the first five lines of the procedure for verification.

BEGIN GET.POL: FIND ALL RECORDS FOR WHICH POLICY NO = 100035 STATE = OHIO OR NEW YORK SEX = M

Make additional changes to the procedure to:

  • Print all key information from the record, not simply FULLNAME and DATE OF BIRTH.
  • Skip between printed lines.

HT Display the entire procedure for verification.

BEGIN GET.POL: FIND ALL RECORDS FOR WHICH POLICY NO = 100035 SEX = M STATE = OHIO OR NEW YORK END FIND FOR EACH RECORD IN GET.POL PRINT FULLNAME AND DATE OF BIRTH

J7LK Skip to and delete the seventh line.

Next, insert three new lines:

Y PRINT ALL INFORMATION Y SKIP 1 LINE YEND

Finally, insert the appropriate commands to open and close the file against which this retrieval is processed.

OPEN and CLOSE commands are inserted, respectively, at the beginning and end of the current text:

JYOPEN CLIENTS Start at beginning and insert line. ZYCHOSE CLIENTS Skip to end and insert line. -LXCLOSE CLIENTS Replace incorrectly entered line. HT Display all text for the final time.

OPEN CLIENTS BEGIN GET.POL: FIND ALL RECORDS FOR WHICH POLICY NO = 100035 SEX = M STATE = OHIO OR NEW YORK END FIND FOR EACH RECORD IN GET.POL PRINT ALL INFORMATION SKIP 1 LINE END CLOSE CLIENTS

END Exit from editor, saving edited procedure

*** M204.0542: EDIT COMPLETE - END

Enter the final END statement after the procedure is printed to exit from the editor and to save the procedure. It is not part of the procedure.