ED

ED, EDIT

Top  Previous  Next

 

The ED command enters the QM line editor. The synonym EDIT can be used.

 

 

Format

 

ED {DICT} file.name {record.id | CREATING.SEQKEY} {NO.QUERY}

 

where

 

DICTindicates that records from the dictionary portion of the file are to be edited.

 

file.nameis the name of the file holding the record(s) to be edited.

 

record.idis the name of the record to be edited. Multiple record ids may be given in which case each record is edited in turn. Use of CREATING.SEQKEY instead of a record id automatically generates the next sequential key for the file.

 

NO.QUERYsuppresses the confirmation prompt if a select list is used. The NO.SEL.LIST.QUERY mode of the OPTION command can be used to imply this option.

 

If no record.id is specified and the default select list is active, this list is used to identify the records to be edited. If no record.id is specified and the default select list is not active, the ED command prompts for the record.id.

 

A record.id of * either on the command line or as the first record.id entered in response to the prompt will cause ED to select all records of the file and edit each in turn.

 

The editor maintains an update lock on the record that is being edited.

 

When editing a compiled dictionary item (C-type, I-type, or A/S type with a correlative), ED removes the compiled code thus forcing recompilation when the modified item is first referenced in a query.

 

 

Overview

 

The editor takes its commands from the keyboard or the DATA queue. Each command line contains one editor command. Commands are retained in a stack similar to the command processor stack and can be repeated without complete retyping. Commands that take arguments specifying their exact function can be repeated by entering just the command name.

 

ED normally rejects commands and input text that contain non-printing characters. Where a non-printing character is to be entered, it can be typed as ^nnn where nnn is the decimal value of the character, or ^Xnnnn where nnnn is the hexadecimal value of the character. Alternatively, the NPRINT command can be used to enable entry of non-printing characters.

 

The editor operates in two modes; edit and input. In edit mode, commands affect the current line (field). In input mode, new data is entered into the record. The editor numbers lines from one and the line number is displayed as a four digit number followed by a colon whenever lines are displayed or during input. The editor command prompt is four hyphens followed by a colon.

 

 

Positioning Commands

 

The commands listed below alter the position of the current line. In addition, entering a blank line at the command prompt advances the current position by one line, displaying the newly selected line.

 

n

Entering a number at the command prompt positions the current line to line n.

 

+n

Moves the current line position forward by n lines.

 

-n

Moves the current line position backward by n lines.

 

B

The B (bottom) command moves to the last line of the record.

 

F{n} {string}

The F (find) command moves forward to the next line containing string starting at column position n (from one). If n is omitted, string must occur at the start of the line.

 

The string must be preceded by a single space or a delimiter chosen from  

! " # $ % & ( ) * + , - . / : = @ [ ] \ _ ` ' { } |

All characters after the delimiter will be treated as part of the string to be located. The string is case sensitive by default but the CASE command can be used to select case insensitive searches. See the W command for a description of wildcards.

 

If string is omitted, the string used by the most recent F command is used. If no F command has been executed, the editor moves forward by one line.

 

Gn

The Gn (go to) command moves to line n. This is identical to the n command described above.

 

G<

The G< command moves to the first line of the currently defined block.

 

G>

The G> command moves to the last line of the currently defined block.

 

L{n} {string}

The L (locate) command moves forward to the next line containing string which must be preceded by a single space or a delimiter chosen from  

! " # $ % & ( ) * + , - . / : = @ [ ] \ _ ` ' { } |

All characters after the delimiter will be treated as part of the string to be located. The string is case sensitive by default but the CASE command can be used to select case insensitive searches. See the W command for a description of wildcards.

 

The optional line count, n, limits the search to n lines from the current position. If n is present, all occurrences of string in the region to be searched are displayed and the current position is left at the end of the search region.

 

If string is omitted, the string used by the most recent L command is used. If no L command has been executed, the editor moves forward by one line.

 

M {pattern}

The M (match) command moves forward to the next line matching pattern. The pattern argument is any valid pattern as used for the query processor LIKE operator. There must be a space before pattern.

 

If pattern is omitted, the string used by the most recent M command is used. If no M command has been executed, the editor moves forward by one line.

 

POn

The POn (position) command moves to line n. This is identical to the n command described above.

 

T

The T (top) command moves to before line 1. There is no current line after this action.

 

 

Displaying Text

 

Ln

The Ln (list) command displays n lines, moving the current line forward to the final displayed line. It is similar to the P command except that n must be included. Omitting n results in execution of a locate command as described above.

 

P{n}

The P (print) command displays n lines starting at the current line, moving the current line forward to the final displayed line. The value of n defaults to 23 on first use of the P command and to the value of n for the most recently executed P command thereafter. There must be no space between P and n.

 

PL{{-}n}

The PL (print lines) command displays n lines relative to the current line position. Negative values of n print lines before the current line. The value of n defaults to 23 on first use of the PL command and to the value of n for the most recently executed PL command thereafter. There must be no space between PL and n. The current line position is not changed by this command.

 

PP{n}

The PP (print position) command displays n lines surrounding the current line position. The value of n defaults to 23 on first use of the PP command and to the value of n for the most recently executed PP command thereafter. There must be no space between PP and n.

 

 

Inserting Text

 

I {text}

The I (insert) command inserts text after the current line, making this the current line. There must be a single space before text. Any additional spaces are treated as part of the inserted text. To insert a blank line type I followed by a single space.

 

If the I command is entered with no text and no space after the I, the editor enters input mode. It will prompt for successive lines until a blank line is entered at which point it returns to edit mode. Entering a line containing just a single space inserts a blank line.

 

IB {text}

The IB (insert before) command is similar to the I command described above except that text is inserted before the current line.

 

LOAD {{filename} record.id}

The LOAD command inserts part or all of the specified record into the record being edited after the current line position. If filename is omitted, it defaults to the file associated with the current record. After the operation is complete, the current line is the first line of the newly inserted text.

 

The editor prompts for the start and end line numbers to be inserted. These default to the first and last lines respectively.

 

 

Deleting Lines

 

D{n}

The Dn (delete) command deletes n lines starting at the current line position. If n is not specified, only the current line is deleted. The line after the last line deleted becomes current.

 

Dn/string/

Deletes all lines containing string within the next n lines starting at the current line position.

 

DE{n}

Same as Dn described above.

 

 

Commands that Edit the Current Line

 

A {string}

The A (append) command appends string to the current line. A single space must separate string from the command. Any further spaces are treated as part of the inserted text.

 

If string is omitted, the most recent A command is repeated.

 

B string

The B (break) command splits the current line into two after string. The string argument must be present and is preceded by a single space. Any additional spaces are treated as part of string.

 

C/old.string/new.string/{n}{G}{B}

The C (change) command changes old.string to new.string in the current line. The delimiter around the strings may be any of

! " # $ % & ( ) * + , - . / : = @ [ ] \ _ ` ' { } |

The optional n component specifies that n lines starting at the current line are to be changed.

 

G causes all occurrences of old.string to be replaced. Without G only the first occurrence on the line is changed.

 

B applies the change to the currently defined block rather than the current line. B and n may not be used together.

 

The n, G, and B, qualifiers can be placed before the first string delimiter as an alternative to the syntax shown above.

 

Entering C with no strings repeats the last substitution.

 

Searches for old.string are case sensitive by default. See the CASE command for a way to select case insensitive searches. See the W command for a description of wildcards.

 

CAT {string}

The CAT command concatenates the current line, string and the following line to form a single line. Omitting string merges the lines with no intervening characters. There must be a single space between the command and the string. Any additional spaces are treated as part of string.

 

DUP {n}

The DUP command duplicates the current line n times. The value of n defaults to one. The first line added by DUP becomes the current line.

 

R/old.string/new.string/{n}{G}{B}

Identical to C described above.

 

R {text}

The R (replace) command replaces the current line with the specified text. There must be a single space before text. Any additional spaces are treated as part of the replacement text. To replace a line by a blank line, type R with no text. The space may be omitted in this case.

 

 

Working with Multivalued Data

 

EV

The EV (edit values) command enters a mode where each value of the current line becomes a line of its own in a new editable item. To edit subvalues, use the EV command when already in EV mode. Used with a dictionary I-type entry, the EV command breaks compound I-types into separate lines to simplify editing.

 

QV

Exits from EV mode and returns to the previous edit text, discarding any changes made while in EV mode.

 

SV

Exits from EV mode and returns to the previous edit text, saving any changes made while in EV mode.

 

 

Block Edit Commands

 

Blocks are defined by two pointers; the start and end line. Block operations enable the entire block to be deleted, moved or copied.

 

<

Sets the current line to be the start line of the block. When used at the top of the record (above the first line), the < command clears the block pointers.

 

>

Sets the current line to be the end line of the block.

 

<>

Sets the block to be just the current line.

 

BLOCK

Toggles block verification mode. When enabled, COPY, DROP and MOVE commands cause a prompt for confirmation prior to performing the operation. Block verification mode is enabled by default.

 

COPY

Copies the currently defined block to immediately after the current line position without affecting the original block.

 

DROP

Deletes the currently defined block.

 

MOVE

Copies the currently defined block to immediately after the current line position and deletes the original block.

 

PB

The PB (print block) command displays the currently defined block.

 

 

File Handling Commands and Leaving the Editor

 

DELETE

FD

Prompts for confirmation and then deletes the entire record from the file.

 

After the record has been deleted, the editor either terminates, continues with the next record from a select list or prompts for a new record id depending on the way in which it was entered.

 

The confirmation prompt can be suppressed using the ED.NO.QUERY.FD mode of the OPTION command.

 

FILE {{DICT} {filename} record.id}

If no arguments are included, the FILE command (which may be abbreviated to FI) writes the record being edited back to its file.

 

If record.id is specified, the modified record is saved under the new name. A confirmation prompt will be issued if a record of this name already exists.

 

If both filename and record.id are given, the record is saved to the specified file and record. Again, a confirmation prompt will be issued if a record of this name already exists.

 

After the record has been saved, the editor either terminates, continues with the next record from a select list or prompts for a new record id depending on the way in which it was entered.

 

Two extended forms of the FI command are available for use when editing QMBasic programs:

FIB {{filename} record.id}Files the record and then runs the QMBasic compiler.
FIBR {{filename} record.id} Files the record, runs the QMBasic compiler and, if the compilation is successful, runs the compiled program.

 

N

When using a select list, the N command moves to the next record in the list. A confirmation prompt is issued if there are unsaved changes.

 

QUIT

EX

The QUIT command (which may be abbreviated to Q) and its synonym EX terminates editing of the current record. A confirmation prompt is issued if there are unsaved changes.

 

If a select list is in use, the editor will move on to the next record. Use the X command described below to terminate the entire edit in this case.

 

SAVE {{DICT} {filename} record.id}

If no arguments are included, the SAVE command writes the record being edited back to its file.

 

If record.id is specified, the modified record is saved under the new name. A confirmation prompt will be issued if a record of this name already exists.

 

If both filename and record.id are given, the record is saved to the specified file and record. Again, a confirmation prompt will be issued if a record of this name already exists.

 

Unlike the FILE command, editing continues after saving the record. The SAVE command does not change the names associated with the record being edited. A subsequent SAVE or FILE with the file and record names omitted will use the original names, not those of an intermediate SAVE command.

 

UNLOAD {{{DICT} filename} record.id}

The UNLOAD command saves part or all of the record being edited into the named file and record. If filename is omitted, it defaults to the file associated with the current record.

 

The editor prompts for the start and end line numbers to be saved. These default to the first and last lines respectively.

 

X

The X command aborts an edit when a select list is in use without saving any changes made to the record. A confirmation prompt is issued if there are unsaved changes. Any further entries in the select list are discarded and the editor terminates.

 

 

Miscellaneous Commands

 

?

The ? command displays status information about the editor and the record being edited. This includes

The file name and record id

The current line number

The item size (lines and bytes)

Block start and end line positions

The command, if any, which will be reverted by OOPS.

Non-printing character expansion mode status (^)

Non-printing character entry mode status (NPRINT)

Block verify mode status (BLOCK)

The setting of search case sensitivity (CASE)

 

^

Toggles non-printing character expansion mode. When this mode is enabled, non-printing characters are displayed as ^nnn where nnn is the decimal character number. On ECS mode systems, characters outside the 8 bit set will be displayed as ^Xnnnn where nnnn is the hexadecimal character number.

 

CASE OFF

Sets case insensitive mode for the C, F and L commands.

 

CASE ON

Sets case sensitive mode for the C, F and L commands. This is the default mode of the editor.

 

COL

Displays a column number ruler to aid alignment of inserted text

 

HELP {topic}

The HELP command displays a short description associated with the command identified by topic. If topic is omitted, this command enters the full help system. If topic is present but not recognised, ED tries to find a help page on this topic from the full help system.

 

NPRINT

Toggles non-printing character entry mode. When this mode is enabled, non-printing characters may be included in commands and input text. When disabled, non-printing characters are rejected but may still be entered using the ^nnn notation where nnn is the decimal character number. This command is not available on ECS mode systems.

 

OOPS

The OOPS command undoes the most recent function that modified the record. It cannot be used to forget positioning functions.

 

STAMP

The STAMP command inserts a single comment line below the current line indicating the account name, user name, date and time of the modification.

 

SPOOL {lines}

The SPOOL command prints a copy of the record on the default printer. If changes have been made but not yet written to the file, the printed version includes these changes. The optional lines qualifier specifies the number of lines to be printed starting at the current line. If this is omitted, the entire record is printed.

 

W{char}

Specifies a wildcard character that may be used in the C and R text replacement commands or the F and L search commands. Use of char within the search string of these commands will match against any single character. The wildcard character may not be a letter or the caret symbol (^). Use of the W command with no char qualifier turns off the wildcard.

 

XEQ {command}

The XEQ command executes the specified command which may be any command valid at the command prompt. The command may include any of the following items to substitute text into the command:

@FILEThe file name
@IDThe record id
@LINEThe text of the current line
@FMA field mark (to separate multiple commands)
@VMA value mark
@SMA subvalue mark

 

 

Pre-Stored Edit Commands

 

Frequently used sequences of editor commands may be saved in a file and subsequently executed by entering just one command. Pre-stored command sequences can also include loops to repeat a series of commands.

 

 

Command sequences are saved using the .S command. This has several different syntaxes:

.S itemSave the most recent command
.Sn itemSave command n
.S item n,mSave commands n to m
.S item n m Save commands n to m

 

In each case, item may be given as either a record id to be created in the default $ED file or as a file name and record id separated by a space. The values n and m may be given in either order. The commands are always saved in the same sequence as they appear on the editor command stack. The first line in the saved item has a type code of E as its first character followed by text describing when it was created.

 

The $ED file will be created automatically first time that the .S command is used to save commands in this file.

 

Multi-line inserts cannot be repeated from a saved command sequence, will cause the .S command to fail and, if edited into the pre-stored sequence manually, will be cause a warning message to be displayed when the command sequence is executed.

 

Alternatively, a user can create a $ED pre-stored item by using the editor:

ED $ED item.name

The first field of the item must contain E as its first character. Subsequent fields each contain one editor instruction in the sequence that the user requires the operations to be performed.

 

 

A saved command sequence is executed by a command of the form

.X item

where item is either a record id in $ED or a file name and record id separated by a space. Unlike other command stack operations, .X item command is added to the command stack so that .X n can be used to repeat the pre-stored sequence.

 

 

Other useful command stack extensions for use with stored edit commands are:

.D itemDelete the specified item
.L itemList the item. If the record id is given as an asterisk, a list of stored edit sequences in the file is displayed.
.R itemRecall a previously saved set of commands to the stack.

 

 

A stored edit sequence may include the PAUSE command. Execution stops and the user may decide whether to continue by entering .XR or to terminate the sequence by entering .XK. Other editing commands may be executed before either of these responses is entered.

 

 

The LOOP command can be used to repeat a series of steps in the stored commands. The format is

LOOP lineno count

The edit continues with the command on lineno. The LOOP will be jump back to the specified line count times before dropping through to the next command. Both lineno and count default to 1 if omitted.

 

Note that a sequence such as

001  I xyz

002  LOOP 1 3

executes the insert command four times because the LOOP jumps back three times. Note also that although the first edit command is on line 2 of the pre-stored sequence, the first line (type code and description) is discarded by the editor and the edit commands are numbered from one when setting lineno.

 

A loop may validly include use of the FI command to file the record. When processing records from a select list, the pre-stored sequence continues execution from one record to the next.

 

 

Editor Command Stack

 

The following commands manipulate the editor command stack. Unless otherwise stated, the stack position argument, n, defaults to one.

 

.A{n} string

Append string to entry n of the editor command stack.

 

.C{n}/old.string/new.string/

Change old.string to new.string in line n of the editor command stack.

 

.D{n}

Delete line n of the editor command stack.

 

.I{n} string

Insert string as entry n of the editor command stack.

 

.L{n}

List n lines of the editor command stack. The value of n defaults to nine.

 

.R{n}

Recall line n of the editor command stack to the top of the stack.

 

.X{n}

Execute line n of the editor command stack.

 

See also ED Pre-Stored Commands above for additional command stack features.

 

 

External Commands

 

The editor includes a facility whereby users can implement additional commands using catalogued subroutines. External commands are identified by use of pattern matching, comparing the command line with patterns specified in the $ED.OPTIONS record (see below) in a case insensitive manner. Commands defined in this way can override standard ED commands, allowing alternative or extended functionality to be added very easily.

 

When an external command is recognised, the editor calls a user written subroutine with two arguments, INFO and ERROR. The INFO argument is an 8 element dimensioned array containing:

INFO(1) = full file name, including possible DICT prefix

INFO(2) = record id

INFO(3) = data being edited

INFO(4) = current line number, zero if at the top

INFO(5) = block start line number, zero if not set

INFO(6) = block end line number, zero if not set

INFO(7) = command line in casing as typed

INFO(8) = edit value depth (0 = normal, 1 = editing values, 2 = editing subvalues)

 

The ERROR argument is used to return an error status to the editor. It should be set to True if processing of the command fails.

 

If ERROR is not set True, the editor will examine the INFO array on return from the subroutine, updating its own status variables to correspond with changes made by the subroutine to the data in INFO(3) or the position information in INFO elements 4, 5 and 6. Positional data is subject to validation.

 

 

Setting Default Modes

 

On entry, ED looks for an X-type VOC record named $ED.OPTIONS and, if this exists, examines fields 2 onwards of this record for options that set the default modes for the editor. These may be:

BLOCK {ON | OFF}Turn on/off prompting for confirmation on COPY, DROP and MOVE. Default is ON.
CASE {ON | OFF}Turn on/off case sensitivity for searches (C, F, L). Default is ON.
EXTERNAL name cmd        Defines catalogued subroutine name as the handler for external command cmd where cmd is a pattern match template or simple constant value.
FIT.SCREEN {ON | OFF}If on, the default display size of the P, PL and PP commands is chosen to fit the screen size. Default is OFF.
NO.EV.POSITIONSuppress display of higher level line numbers when in edit values mode.
NPRINT {ON | OFF}Turn on/off acceptance of non-printing characters on input. Default is OFF. This option is ignored on ECS mode systems.

 

Unrecognised options or qualifiers are ignored.