• Aucun résultat trouvé

THIS IS THE FIRST LINE OF RECORD

Dans le document HP 2000 SERIES (Page 166-172)

>?PF S

>?C

THIS IS THE FIRST LINE OF RECORD 1

1 THIS IS THE FIRST LINE OF RECORD 1

>?PF

>?C

THIS IS THE FIRST LINE OF RECORD 1

>?L $E

THIS IS THE FIRST LINE OF RECORD 1 N 12

N 13 N 14

THIS IS THE FIRST LINE OF RECORD 2 N 22

N 23 N 24

>?L 2 R 1 2

THIS IS THE FIRST LINE OF RECORD 1 N 12 R= 1

>?L 3 S

R= 1

R= 1

1 THIS IS THE FIRST LINE OF RECORD 1

2 N 12 3 N 13

>?MG 1L?l

>?L$E

DONE

THIS IS THE FIRST LINE OF RECORD 1 N 12

N 13 N 14

THIS IS THE FIRST LINE OF RECORD 2 N 22

N 23 N 24

DATA EDITING COMMANDS

The third and final group of the basic commands handle the actual editing functions with the use of the C.D. as their reference point.

The I command INSERTS new data elements after the C.D. Its format is:

>71 -7

The new data is added exactly as the data is added on a new file. When the ZC is entered, the insertion is completed, and the new C.D. is set at the old C.D.+k+l, where k is the number of new data elements that have been added. This is shown in the example which follows this section.

The second command of this group is R. This command REPLACES the CD. with one or more data elements.

Its fo rma tis:

>7R -7

The replacement operation is identical to the new data addition for I. On completion of the replacement (a Ze was entered), the new C.D. is set at the old C.D.+k, where k is the number of new data elements entered.

In both of the above commands, there is no limitation on the data types of the new elements.

The 0 command DELETES the C.D. Its format is:

>70

Following the execution of this command, the file pointer is left unchanged so that the new C.D. is the next element in the file.

Below is an example showing the use of these three commands.

RUN

OLD OR NEW FILE?NEW -?THIS IS THE FIRST LINE -?AND THIS IS THE SECOND LINE·

-?AND THIS IS THE THIRD LINE·

-?FINALLY THIS IS THE LAST LINE.

-?

1 =LAST WRITTEN RE(ORD

>?I

-?******************

-?

>?R

-?$,$$$,$$$$$$$,,$$$$'4 -?

>?D

>?($8

>?L $E

THIS IS THE FIRST LINE

******************

$$$$$$$$$$$$$$$$$,$$4

FINALLY THIS IS THE LAST LINE.

>?I

-?$$$$$$$$$$$$$$$$$$$

-?####################

-?#####################

-?

>?($8

>?L$E

THIS IS THE FIRST LINE

!~$$$$$$$$$$$$$$$$$$

###################

####################

*****************

1~$$$$$$$$$$$$$$$$$$4

f::-INALLY THIS IS THE LAST LINE.

>?E ])ONE

MACRO. page 9

The A c()mmand (for ALTER) is the last member of this group. It allows individual character editing on the C.D. (if it is a string type datum) by putting the user into alter mode. The command format is:

>?A

An attempt at altering numeric data will result in the printing of a diagnostic message which leaves the C.D. unchanged. When this corrrnand is entered, the system will print out the C.D. and then print a "*?"

signifying that it is ready to accept one of the following sub-corrrnands.

E This command EXITS the user from alter mode. The C.D. is then set to the next data element of the file.

C This command causes printing of the C.D. in its current state of editing.

P character n This command POSITIONS the first occurrence of the given character at the numbered position in the line (left-most character =1). This corrrnand is mainly used for such things as centering titles.

S character This command SKIPS a character pointer to the first occurrence of the given char-acter in a line, and then prints out a vertical arrow to show the position of the pointer. To set the pointer at later occurrences of a character in the line,

repeat the command. To reset this pointer before the beginning of the line, give the command with a character not in the line. This command must be used before character insertion, replacement, or deletion can occur.

I character string

This command inserts the given character string after the character which the pointer indicates.

R character string

This command replaces the character denoted by the pointer with the given cha racter s tri n g.

After the use of either the I command or the R command, the S command must be used to reset the character pointer before another I,R, or D command will be accepted.

D This deletes the character pOinted to by the linepointer. The pointer is set to the following character in the line after the execution of this command.

Below is an example involving these alter sub-group commands.

OLD OR NEW FILE?NEW

-?THIS IS THE ONLY LINE OF THE FILE, EXCEPT FOR THE SECOND.

-?THIS IS THE SECOND LINE OF THE FILE.

-?

1 =LAST WRITTEN RECORD

>?A

THIS IS THE ONLY LINE OF THE FILE, EXCEPT FOR THE SECOND.

*?1*****

*?C

THIS IS THE ONLY LINE OF THE FILE,***** EXCEPT FOR THE SECOND.

*?S.

*?R.

*?C

THIS IS THE ONLY LINE OF THE FILE,***** EXCEPT FOR THE SECOND.

*?S*

THIS IS THE ONLY LINE OF THE FILE, EXCEPT FOR THE SECOND.

*?SN

*?S

*?D

*?PT 1~

*?C

*?E

>?C

2

>?E DONE

THIS IS THE ONLY LINE OF THE FILE, EXCEPT FOR THE SECOND·

THIS IS THE SECOND LINE OF THE FILE. R= 1

r'1ACRO. page 11

FILE ORGANIZATION AND INTEGRITY

The r~ACRO system is designed so that the integrity of a record-oriented file is preserved. However. the

systE~m cannot prevent the user from overflowing a record during the editing process. When this occurs, the record overflow will be contained on another record directly following the overflowed record. The origiinal contents of that record are moved to the next record and so forth through the rest of the file.

Thus" the .overflow record contains overflow and nothing else. The following example shows the use of the

con~and to force this overflow.

1 2 3 4

****************************************************

*************************

R= 1

*****************************************************

>?CR 2

>?I

**************************

-?$$$$$$$$$$$$$$$$$$$$$$4 -?$$$$$$$$$$$$$$$$$$$$$$$

-?

>?C$8

>?L $E R

R= 2

1

****************************************************

2

*************************

R= 1 3 $$$$$$$$$$$$$$$$$$$$$$4 R= 1

4 $$$$$$$$$$$$$$$$$$$$$$$ R= 2 ~ OVERFLOW RECORD 5

6

>?E

*****************************************************

**************************

R= 3

R= 1 R= 2

R= 1

R= 3

There is only one limitation in the type of file that this system will edit. It is the fact that the file can have only one end of record mark. This is a requirement, as MACRO cannot differentiate between a physical end of file and a software end of file.

Because of its abil ity to handl e record-oriented fil es, optimum data packing does not always occur in a sequential file. The following command can rectify this situation.

>?PS

This command causes optimum packing of data elements on a sequential basis. A related command controls the block'ing of data into fixed length records. Its form is:

>?PR n

This command causes the file to be packed into records with n data elements per record. Diagnostic mes-sages will be printed on the terminal in the case of file or record overflow. When either of these com-mands is finished execution, the C.D. is set to the first element of the file.

TEXT EDITING FEATURES

The J command causes a file consisting solely of strings to be left JUSTIFIED word by word into lines less than or equal to a specified length. This command will not break up strings of blanks. Its format is:

>?J n where n specifies the line length

Two control words, "$LINE" and "$PAGE" exist to produce blank lines and paging when listing text. $LINE causes 1 blank line to be spaced, and $PAGE causes 6 blank lines to be spaced. These control words are

only converted into linefeeds under two conditions, first when the C command is given when the PF command has preceded. it, and when the L command is used without the S or R options. If a line starts with one of these control words, it will be expanded into linefeeds under these conditions. The J command recog-nizes these control words only if they are alone in a line (i.e. individual string) and will then not pack them into lines of fixed length. Thus, when wishing to use these control words for formatting a text file, one must use an entire line for them.

ADVANCED EDITING FEATURES

FIND COMMANDS

These commands search the C.D. and the following data in the file for the first occurrence of a given sub-string or number. When the subsub-string or number is found, the C.D. is set to that element of the file.

If on the other hand, an end of file is encountered before the substring or number is found, then the search is stopped and the C.D. is set to the first data element of the file.

The NF (NUMBER FIND) command searches for a particular number in the file. Its form is:

>NF n where n is the number that the user wishes to find.

The SF (STRING FIND) command is identical to the NF command except that it searches for a particular sub-string in the file. A match will occur if this sub-string equals one in the file, or if this subsub-string is a substring of some string in the file. Its format is:

>SF character string

Any spaces following the SF are considered to be part of the string for which the user wishes to find a match.

SUBSTITUTE COMMANDS

These commands are identical to the find commands except that once the datum is found, a substitution is made as directed by the command. The C.D. is then set to the datum that is found after the sUbstitution is made. If no match was found, then the C.D. is set to the first data element of the file, and the search is stopped.

The NSUB (NUMBER SUBSTITUTE) command will substitute one number for another. Its form is:

>?NSUB nl \ n2

Here, n, will be substituted for the first occurrence of n2, The backslash character (\ ) which can be read as "for" is the character shift-L on the terminal.

The second substitute command (STRING SUBSTITUTE) will substitute one substring for another. Its format is:

>?SSUB sl \ s2

Here, sl is substituted for the first occurrence of s2. Any spaces occurring after the SSUB will be con-sidered to be either part of sl' if on the left side of the backs1ash, or part of s2 if they occur to the right of the backs1ash.

MUL TI PLE COMMANDS

Severa.l commands may be written on one 1 ine in the following manner:

>? C$B ZC PF ZC C ZC A

t1ACRO, page 13

Note the use of the ZclS to separate the individual commands. The only comnands allowed in such a multiple command 1 ine are those which may be entered after a "?" If an unrecognized comnand occurs in a string of corrmands, the error will be noted and control of the editing process will return to the terminal key-board. The following example shows the use of a line of commands to justify, margin and list a piece of text and then exit from MACRO.

>?J 2B MG 25 L$E E

DONE

THIS IS THE FIRST LINE OF A FILE THAT WILL BE JUSTIFIED~

AND THEN LISTED USING THE MULTIPLE COMMAND FORMAT OF THE EDITING SYSTEM, 'MACRO' .

The fo'llowing example shows the use of the find and substitute commands.

>?C$B

>?L$E

THIS IS THE FIRST LINE OF A NEW FILE.

N 12 N 24 N 32

AND THIS IS THE SECOND LINE OF IT.

FINALLY THIS IS THE THIRD LINE OF THIS FILE.

>?NF 24

>?C

3 N 24

>?C$B

>?SFFINALLY

>?C

Dans le document HP 2000 SERIES (Page 166-172)