• Aucun résultat trouvé

EDIT Command

Dans le document Digital Equipment tion (Page 147-155)

DEFINEP Continued

5.25 EDIT Command

Function

Invokes the DATATRIEVE Editor to edit a dictionary object.

Format

EDIT object-name [(paSSWd)] [ADVANCED]

(*)

Arguments

object-name

Is the name ofa DATATRIEVE domain, record, procedure, or table definition you want to edit.

(passwd) (*)

Is an asterisk enclosed in parentheses (*) or the password necessary to gain C (control) access to the dictionary object. If you specify a password, you must enclose it in parentheses. If you specify (*), DATATRIEVE prompts for the password, but does not display your response on the terminal. If you omit this argument, DATATRIEVE uses your log-in UIC/PPN to verify that you have C (control) access privilege to the object you want to edit.

ADVANCED

Specifies that you want to edit a domain or record definition. You must include this keyword before you can edit a domain or record definition.

Restrictions

• You must have W (write) access to your current dictionary before you can use the EDIT command.

• To edit a DATATRIEVE domain, record, procedure, or table definition, you must have C (control) access privilege to the dictionary object you want to edit.

Results

• When you use the EDIT command, DATATRIEVE invokes the Editor, loads the specified definition into the main text buffer of the Editor, and prompts with QED>, the editing command mode prompt. You can type any Editor com-mand in response to the prompt. Editor comcom-mands are summarized in Table 5-6.

EDIT

Continued

Table 5-6: Summary of DATATRIEVE Editor Commands

Command Format and Functions

CTRLlZ CTRL/Z

Ends an editing session and returns you to DATATRIEVE command level when typed in response to the QED> prompt. The edited dictionary object replaces the previous version in the data dictionary. When typed in response to the IN> prompt, CTRLlZ exits from insert mode.

DELETE D[ELETE] [range]

Deletes the current line or the specified range and sets the current line as the line following the last deleted line.

EXIT EX[IT]

Ends an editing session and returns you to DATATRIEVE command level; the edited dictionary object replaces the previous version in the data dictionary .

INSERT I[NSERT] [range]

Enters insert mode. You type lines to be inserted before the current line or before the first line of the specified range. Type CTRL/Z to exit from insert mode. If you do not specify a range, th~ current line does not change when you leave insert mode; if you specify a range, the Editor sets the line spe-cified by the range as the current line. Do not use ALL, AND, BEFORE, FOR, REST, or WHOLE when specifying the range in this command.

QUIT QUIT

Returns you to DATATRIEVE command level and leaves the dictionary object unchanged by the editing session.

REPLACE R[EPLACE] [range]

Deletes the current line or the specified range and enters insert mode.

Type CTRLlZ to exit from insert mode. The Editor sets the current line to the line following the last deleted line. You can use all range specifiers with this command.

SUBSTITUTE S/str-1/[str-2][/[range]]

Substitutes string 2 for all occurrences of string 1 in the specified range or in the current line if you omit the range. The Editor sets the line in which the last substitution occurred as the current line. If you omit string 2, the Editor deletes the specified string and makes no substitution. The search for the first occurrence of string 1 starts with the current line and proceeds toward the end of the text buffer except when you specify WHOLE as the range; when you specify WHOLE, the Editor searches and substitutes from the beginning to the end of the text buffer. Do not use END to specify the range in this command.

TYPE [T[YPE]] [range]

Displays the specified range oflines or the line following the current line if you omit the range. Sets the first line displayed as the current line, with one exception: if you specify E[ND] in the range, the Editor sets the cur-rent line at the end-of-buffer marker ([EOB]).

EDIT

Continued

• To end an editing session, type EXIT, CTRL/Z, or QUIT in response to the QED> prompt:

- EXIT or CTRL/Z causes DATATRIEVE to update the definition. If the object name is a procedure, DATATRIEVE does not invoke the procedure.

- QUIT causes DATATRIEVE to ignore the contents of the Editor's text buffer, display the message ~~Execution failed", and return you to DATATRIEVE command level.

• The DATA TRIEVE Editor does not check the syntax of any DATA TRIEVE commands or statements in the text buffer. If you make a syntax error when correcting your definition, DATATRIEVE responds to the error only when it executes the commands or statements after you exit from the Editor, or when you invoke the edited procedure or ready the domain.

Usage Notes

• The DATATRIEVE Editor has two modes: command mode (the edit mode) and insert mode.

- When you use the EDIT command to invoke the Editor, the Editor prompts with QED>, the command mode prompt. In command mode, the Editor interprets all your inputs as commands, and you can display and alter the text of the dictionary object.

- In insert mode, you can enter text directly into the dictionary object. To enter insert mode, use the INSERT and REPLACE commands. The Editor then prompts with IN>, the insert mode prompt. In insert mode, the Editor interprets all your input as new text to be entered into the dictionary object.

To exit from insert mode, type CTRL/Z .

• The Editor uses a line pointer to keep track of the current line. Some editing commands move you through the text from one line to another, thus changing the current line. Other commands display or alter lines at various places in the text but leave the current line unchanged. The line pointer keeps track of your posi tion in the text.

- The line pointer points to the entire current line, not to any part of the line.

To display the current line, type a period (.) and carriage return in response to the QED> prompt.

- The maximum line size you can edit is 132 characters.

- The current line pointed to by the line pointer can be a blank line at the end of the text buffer, thus allowing you to add text to the end of the dictionary object. The symbol [EOB] marks the end of the text buffer.

EDIT

Continued

• The DELETE, INSERT, REPLACE, SUBSTITUTE, and TYPE Editor com-mands strings all contain an optional argument that specifies the range of lines on which the command operates. The range may be a single line, a series of consecutive lines, or a group of nonsequential lines. Table 5-7 summarizes the range specifiers you can use with DATATRIEVE Editor commands. See Chapter 17 in theDATATRIEVE-ll User~s Guide for examples of using range specifiers in Editor commands.

Table 5-7: Range Specifications for Editing Commands

Range Keyword and Format Range Specified

ALL All lines containing the specified string. The

[%]ALL "string" search does not distinguish between upper- and

'string' lowercase letters.

AND All lines as specified by BEGIN, END, and

BE[GIN] BEGIN «string". BEGIN specifies the first line of the E[ND] [%]AND END [, ... ] dictionary object and END specifies the last

"string" , "string" line ([EOB]).

'string' 'string'

BEFORE All lines before the current line and the

cur-[%]BEF[ORE] rent line.

BEGIN First line of the dictionary object.

[%]BE[GIN]

END Last line of the dictionary object.

[%]E[ND]

FOR Number oflines specified by n, starting with

BE[GIN] FOR the the line specified by BEGIN or ((string".

"string" , n BEGIN specifies the first line ofthe dictionary

'string' object.

REST The current line and all remaining lines in the

[%]R[EST dictionary object.

string The current line or the next line containing the

'string' specified string. The search starts with the

cur-"string" rent line and continues toward the end of the text buffer. The Editor does not distinguish between upper- and lowercase letters.

WHOLE All lines of the dictionary object.

[%]WH[OLE]

+ Line that is n lines from the line specified by

BE[GIN] BEGIN or ((string". BEGIN specifies the first

"string" +n line of the dictionary object. When you specify

'string' a string, the command applies to the line that

is n lines from the next occurrence of the spe-cified string.

.

The current line .

.

EDIT

Continued

Note that if you want to display the rest of a dictionary object using the abbre-viated form of the REST specifier without a TYPE command, you must precede the R with a percent sign to distinguish the R from the abbreviated form of the REPLACE command.

• Be careful when editing record definitions:

If you change the length of the record definition, you have to create a new data file and transfer the old information from the old file to the new one.

If you change the name of any fields in a record definition, you have to edit the procedures and reports that refer to those fields.

• DATATRIEVE does not use any new dictionary definitions until you explicitly release control of the domain with the FINISH command. Thus, if you change the definition of a readied domain or its associated record definition, the changes do not have any effect until you enter a FINISH command and ready the domain again.

• See the following sections for more information on DATATRIEVE Editor com-mands. See Chapter 17 oftheDATATRIEVE-ll User's Guide for examples of using the DATATRIEVE Editor.

Examples

Edit a table, display the table with the WHOLE range specifier, search for a line with the TYPE command, display that line as the current line, change the line, and exit from the Editor.

DTR> EDIT DEPT_TABLEOO) QED> WHOLEOO)

CE "COIT1lTlercial En~ineerin~",

PE "Plant Enginee ring", CS: "CustolTler Support",

RD : "Research and Del.leloPITlent", SD : "Sales DepartITlent",

ELSE "UNKNOWN DEPARTMENT"

END_TABLE QED> TYPE "ELSE"OO)

ELSE "UNKNOWN DEPARTMENT"

QED> S IUNKNOWN DEPARTMENT/Urd,nolllln DepartlTlent/OO) ELSE "Un~,nolilin DepartlTlent"

QED> E}<I TOO) DTR>

EDIT

Continued

Edit the PERSONNEL_REC record definition, display the definition with the WHOLE range specifier, set the START _DATE line as the current line with the TYPE command, and change the line with the REPLACE command. Use the QUIT command to exit from the Editor without changing the record definition:

OTR) QED)

ED I T PERSONNEL_REC ADI.JANCEDru WHOLEru

QUERY_NAME IS STATUS QUERY_HEADER IS "STATUS"

I.JALID IF STATUS EQ "TRAINEEIl t"EXPERIENCED".

QUERY_NAME IS NAME.

PIC IS }{(10)

QUERY_NAME IS F_NAME.

PIC IS }((10)

QUERY_NAME IS L_NAME.

PIC IS }{}{}{.

EDIT_STRING IS MMM5DD5Y(LI).illD)

PIC IS 8(5).

PIC IS }-{(11)

QUERY_NAME IS STATUS QUERY_HEADER IS "STATUS"

1.IALID IF STATUS EQ ItTRAINEEIt t"E}-{PERIENCED II • QUERY_NAME IS NAME.

PIC IS }{(10)

QUERY_NAME IS F_NAME.

PIC IS X(10)

QUERY_NAME IS L_NAME.

PIC IS }OO{.

USAGE IS DATE

EDIT_STRING IS MMM5DD5Y(4).

PIC IS 8(5)

EDIT_STRING IS $$$t$$$.

PIC IS 8(5).

EDIT

Continued

5.25.1 DELETE Command

Function

Deletes one or more lines from the dictionary object.

Format

O[ELETE] [range]

Arguments range

Specifies the range of lines to be deleted. If you omit the range, DATATRIEVE deletes only the current line.

Restrictions

You can issue the DELETE command only in response to the QED> prompt.

Results

The Editor deletes the current line or the specified range of lines and sets the line pointer to the line following the last line deleted.

Examples

Display the TEST procedure and the current line, then delete the current line.

Use the QUIT command to exit from the Editor without changing the procedure:

DTR> EDIT TESTlBTIJ QED> WHOLElBTIJ

QED> .lBTIJ

READY PERSONNEL READ

FIND PERSONNEL WITH DEPT = "D98" t "T32" SORTED BY STATUSt DEPT REPORT CURRENT

SET REPORT_NAME = "DETAILED SALARY REPORT"

AT TOP OF DEPT PRINT DEPT AT TOP OF STATUS PRINT STATUS

PRINT ID t FIRST_NAME::" " : LAST_NAME ("NAME") 1 SALARY

AT BOTTOM OF STATUS PR I NT SK I P t COL 42 t STATUS t SPACE t "TOTAL: ' TOTAL SALARY USING $1$$$t$$$1 SKIP

AT BOTTOM OF DEPT PRINT COL 421 DEPT, SPACE, "TOTAL:" t

TOTAL SALARY USING $ t$$$ t$$$ 1 COL 421 "---,, t SK:

AT BOTTOM OF REPORT PRINT COL 42t "GRAND TOTAL SALARY:" t

TOTAL SALARY USING $t$$$t$$$

SET NO DATE

SET COLUMNS_PAGE

=

80 END_REPORT

READY PERSONNEL READ QED> DELETElBTIJ

QED> .@TIl

FIND PERSONNEL WITH DEPT QED> QUIT(@)

Execution failed

"D98" t "T32" SORTED BY STATUS t DEPT

EDIT

Continued

Delete all the AT TOP and AT BOTTOM statements in the TEST procedure. To do this, use two DELETE commands to delete lines that contain the string ((AT"

and lines that contain the string ((TOTAL". Use the QUIT command to exit from the Editor without changing the procedure:

DTR> EDIT TESTru OED> D ALL "AT"m OED> D ALL "TOTAL"ru OED> WHOLEm

READY PERSONNEL READ REPORT CURRENT

SET REPORT_NAME = "DETAILED SALARY REPORT"

PRINT ID, FIRST_NAME::" ":LAST_NAME ("NAME"), SALARY SET NO DATE

Delete the last two SET statements in the TEST procedure. Use the QUIT com-mand to exit from the Editor without changing the procedure.

DTR> EDIT TESTru

SET REPORT_NAME = "DETAILED SALARY REPORT"

OED> CB11)

READY PERSONNEL READ

FIND PERSONNEL WITH DEPT

=

"088", "T32" SORTED BY STATUS, DEPT REPORT CURRENT

SET REPORT_NAME

=

"DETAILED SALARY REPORT"

AT TOP OF DEPT PRINT DEPT

EDIT

Dans le document Digital Equipment tion (Page 147-155)