• Aucun résultat trouvé

j} includes all text that followed it in the current line. After SB

Dans le document Lt QU (Page 119-125)

has executed, the second of the two new lines is made the cur rent line.

SA/string/ (Split line After string). The SB command searches the current line for the specified text string, and if found, splits the current line in two. The first of the two lines consists of the text in the current line that preceded the found string and the found string itself. The second line consists solely of the text that followed the found string in the current line. After SA has executed, the second of the two new lines is made the current line.

CL/string/ (Combine Lines and string). The CL com mand combines the current line and the line which follows it into a single line; string is optional, and if specified, inserts the text string in the middle of the combined line. If the length of the combined line exceeds the current maximum line width al lowed by EDIT, the rightmost characters of the line are trun cated. Take a look at these examples.

Consider the line of text I would gladly pay you Tuesday for a hamburger today.

SB/ for/

or

SA/sday/

results in the line being split in two:

J would gladly pay you Tuesday for a hamburger today

If you started with a current line Time for all good men, followed by the line to aid their lemon lobby:

CL/ and clones /

EDIT, the Line Editor

the result is

Time for all good men and clones to aid their lemon lobby

Note: The SA, SB, and CL commands also accept string qualifiers (B, E, L, P, and U). See the previous section "Find Command Qualifiers" for further information on their uses.

Global Operations

EDIT's global operation commands let you automatically insert and replace text in lines which match specified search criteria.

Global commands set up editing "phantoms" that constantly look over EDIT's shoulder as lines of the From file are pro cessed. Multiple global commands may be in effect during the course of an EDIT session. The global commands are

• GA/stringl/string2/ (Global insert string! After string!)

• GB/stringl/string2/ (Global insert string! Before string!)

• GE/stringl/string2/ (Global Exchange string! with stringl) Once a global command is issued, EDIT applies the asso ciated A, B, or E command to every line as it passes the cur rent line marker.

Canceling Global Operations

When a global command is issued, EDIT displays an identi fication number associated with that particular global phantom.

An individual global phantom may be canceled by issuing the CG (Cancel Global) command followed by the phantom's ID number. For instance, to cancel a global command that's been issued the ID number G4, type

CG4

To stop all current global operations, simply type CG

If you can't remember what the active global operations are, the SHG (SHow Globals) command will refresh your

memory.

Command Groups

EDIT commands that have been strung together on a single line, separated by semicolons, may be grouped together by enclosing the commands in parentheses. The resulting

ex-EDIT, the Line Editor

pression is called an EDIT command group. Command groups are normally used when you wish to repeat a group of com mands several times. One command group may be nested within another, such as in

2(25(B /red/blue/;lT);501O

This replaces the text red with blue in the current line and all lines within 24 lines of the current line. The current line marker is then moved ahead 50 lines. Occurrences of the text red are replaced with blue in the new current line and in the following 24 lines. Finally, the current line marker is again moved ahead 50 lines.

If you instruct EDIT to execute a command or command group zero times, the command continues to execute until the end-of-file is encountered or until CTRL-C is used to issue a BREAK.

EDIT Command Files

When EDIT is invoked, it accepts commands from the key board or from an AmigaDOS file specified by the WITH key word in the DOS command line which started the editing session.

You can also dynamically invoke the execution of EDIT commands stored in AmigaDOS files from within EDIT by using the C command.

C .:my/stored/commands.

starts execution of the EDIT commands contained in the file my/stored/commands in the root directory of the current drive.

Command execution continues until a Q (Quit) command is encountered in the command file or until the command file's end-of-file is reached. The filename must be enclosed by a valid EDIT delimiter. (Notice that in the above examples, peri ods were used to delimit the filename.) Command files may call other command files.

Suppose you want to set up an AmigaDOS command se quence file that will create a nicely sorted list of the contents of the current directory. The following command sequence file, when used in conjunction with a simple EDIT command file, does the trick:

LIST > mylist

EDIT mylist WITH df0:unwanted

EDIT, the Line Editor

u

U

SORT mylist TO finlist

TYPE finlist TO prt: L—'

The contents of the filename unwanted are

D U

M*

D W

When the above AmigaDOS command sequence file is

executed, an unsorted list of the contents of the current direc- I j

tory is directed to the file called mylist. EDIT is invoked using *■—'

the WITH option to pull in the commands in the file un wanted. These commands remove the first and last lines of the LIST output (since they contain information about the current directory rather than the file or directory names in it). The edited file is saved and you're returned to the command se quence file. The edited file is then sorted and sent to the sys tem's printer.

Merging Selected Parts of Files/Outputting Multiple Files

It's also possible to use EDIT to merge selected parts of dif ferent files together and to create multiple versions of the edited text. This is accomplished in a somewhat roundabout way, using facilities within EDIT that allow you to change the current From and To files on the fly from within EDIT.

fROM/filename/. The lines that follow the current line are replaced by the contents of the new From file. The original From file remains open and the lost lines may be accessed again by issuing a FROM command with no filename. A file opened by FROM may be closed by the CF (Close File) com mand, which has a format of CF/filename/.

The following sequence of EDIT commands merges the first 15 lines of three different files into one:

EDIT onefile TO myfile 14N

FROM ,twofile, 1BN

FROM ,threefile, 18N

D*

CF onefile

EDIT, the Line Editor

CP twofile W

TO/filename/. The TO command lets you dynamically switch EDIT's destination, or To, file. TO writes EDIT's existing output buffer to the To file before the switch is made and then clears the buffer. TO leaves the previous To file open. Issuing a subsequent TO command with no filename results in the orig inal To file being reselected.

The following example outputs lines 1-100 of the file bigfile to a file called firsthundred, and lines 101-200 of bigfile to a file called secondhundred.

EDIT bigfile TO firsthundred 100N

TO .secondhundred.

100U CP D*

W

The Rewind Command

REWIND scans the remaining lines from the current line for ward, executing any global commands in effect as it proceeds, until it reaches the last line of the From file. The contents of the output buffer are written, and the To and From files are closed. The To file is then reopened as a new From file.

The Halt Command

H (Halt) lets you set a line number as a brick wall which the current line marker cannot be moved past.

H134

prevents EDIT from moving past line 134 of the From file. If a command causes line 134 to be reached, the operation is halted and the message Ceiling reached displays.

Point Before and After

PB (Point Before) and PA (Point After) move the position op erational window pointer in the current line.

PA/string/ moves the operational window pointer im mediately after string in the current line.

FB/string/ moves the operational window pointer im mediately before string in the current line.

Lt U Q

U

EDIT, the Line Editor

Dans le document Lt QU (Page 119-125)