-*-TAGS-*-  File: Tecomd, Node: commands, Up: (Teco1)Top Prev: (Teco1)Exit From Teco, Next: (Teco1)Additional Documentation TECO COMMANDS TECO offers an extensive set of commands. The subset selected for this publication can be grouped into four fundamental types: * Menu: * Insertion command:: * Type out and pointer commands:: * Deletion commands:: * Search commands::  File: Tecomd, Node: Insertion command, Up: Commands, Next: Type out and Pointer Commands I command This command causes the specified string of characters to be inserted into the text buffer. The string is entered at the current position of the pointer, and the pointer is positioned immediately afer the last character of the insertion. Command format: *Itext$ Where: I is the command character. text is the string of characters to be inserted into the buffer. Note that carriage return characters are also considered as part of 'text'. $ is a single escape () character to signify the end of the string to be inserted. In short, text between the character 'I' and the first escape character will be inserted. A second escape character will actually perform the insertion. Example # 1 The following example illustrates the creation of a file. Although the created file will be a BASIC-PLUS file, other types of ASCII files such as data files, FORTRAN programs, MACRO programs and text can be created in the same fashion. MAKE SAMPLE.BAS Access TECO via 'MAKE' CCL. The .BAS extension must be specified. TECO responds with '*'. *I100 REM EUCLID'S ALGORIM FOR GCD Text following 'I' to be inserted. Note: a carriage return has been typed after each line. 110 READ A, B 120 LET X = A 130 KET Y = B 140 LET Q = INT(X/Y 150 LET R = X - Q * Y 160 IF R = 0 THEN 210 170 LET X + Y 180 LET Y = R 190 GO TO 130 190 GO TO 140 200 REM OUTPUT A, B, AND GCD 210 PRIN A, B, Y 220 DATA 35,, 290 $$ The first escape is to indicate end of text to be inserted; the second escape is to execute the insertion. *EX$$ TECO responds with '*'. EX command to terminate TECO . Two escapes to execute EX command. Ready Back to RSTS/E.  File: Tecomd, Node: Type out and Pointer Commands This section describes commands which will allow the user to inspect part or all of the buffer contents. Some commands also have the capability of moving the pointer within the buffer so that changes can be made at selected locations. * Menu: * Typeout command:: * Verify Command:: * Line Movement Command:: * Character Movement Command:: * Second Example:: * Jump Command:: * Third Example::  File: Tecomd, Node: Typeout command, Up: Type out and Pointer Commands T command This command is used to type or print the contents of the text buffer starting from the current position of the pointer up to and including the next line feed () character. The position of the pointer is left unchanged. Command format: *nT Where n can be negative, zero or positive: If n < 0, the n lines preceding the current pointer position are typed. If n = 0, text from the beginning of the line on which the pointer is located up to the pointer is typed. If n > 0, the n lines following the current pointer position are typed. Omitting n is equivalent to 1T and -T is equivalent to -1T. HT command (H means the wHole thing) Types out the entire content of the buffer regardless of the current position of the pointer. The pointer is left unchanged upon completion of the command. Command format: *HT  File: Tecomd, Node: Verify Command, Up: Type out and Pointer Commands V command This command will type out the entire line in which the pointer is located, regardless of the pointer position. It is a useful command to verify to current line. The pointer's position is left unchanged. Command format: *nV Where n, in this case, can only be a positive number. If n = 1, or omitted, it verifies the current line. If n > 1, the command will verify n-1 line(s) on each side of the current line.  File: Tecomd, Node: Line Movement Command, Up: Type out and Pointer Commands L command Use this command to move the pointer to the beginning of the desired line. Command format: *nL Where n can be negative, zero, or positive. If n < 0, the pointer is moved backwards to the beginning of the nth complete line preceding its current position. If n = 0, the pointer is moved to the beginning of the line in which it is currently positioned. If n > 0, the pointer is advanced to the beginning of the nth line following its current position. Omitting n is equivalent to 1L and -L is equivalent to -1L.  File: Tecomd, Node: Character Movement Command, Next: Example Two Up: Type out and Pointer Commands, Prev: Line Movement Command C command This command is used to move the pointer across characters. It is not limited to characters within a single line of text. Line boundaries, composed of carriage return and line feed characters, can be crossed with the C command. Command format: *nC Where n can be negative or positive. If n < 0, the pointer is moved backward across n characters. If n > 0, then pointer is moved forward across n characters. A value of zero for n will have no effect on the pointer position. Omitting n is equivalent to 1C and -C is equivalent to -1C.  File: Tecomd, Node: Second Example, Up: Type out and Pointer Commands The following example illustrates how to access an existing file and manipulate characters within the buffer. TECO SAMPLE.BAS Access TECO via 'TECO' CCL. *T$$ TECO responds with '*'. Pointer is always positioned before the 1st character in the buffer when TECO is invoked. T command will type out text from the pointer up to and including the terminating line feed character. 100 REM EUCLID'S ALGORIM FOR GCD *V$$ Verify line in which pointer is located. 100 REM EUCLID'S ALGORIM FOR GCD *L$$ Advance the pointer 1 line. Note nothing is printed. *V$$ Verify new current line. 110 READ A, B *2L$$ Advance pointer 2 more lines. *T$$ Type out line. 130 KET Y = B *4C$$ Move pointer across 4 characters. Note nothing is printed. *T$$ Type text from pointer to end of current line. KET Y = B *4L$$ Advance pointer 4 lines. *V$$ Verify line. 170 LET X + Y *2V$$ Verify n-1 = 1 line on each side of current line. 160 IF R = 0 THEN 210 170 LET X + Y 180 LET Y = R *5L$$ Advance 5 lines. *T$$ Print out current line. 210 PRIN A, B, Y *-2T$$ Type out 2 lines preceding current line. 90 GO TO 140 200 REM OUTPUT A, B, AND GCD *EX$$ Exit TECO. Ready  File: Tecomd, Node: Jump Commands, Up: Type out and Pointer Commands J command This command moves the pointer to the position immediately preceding the first character in the buffer, i.e., to the beginning of the buffer. Command format: *J ZJ command (Z is an end of buffer indicator) This command moves the pointer to the position immediately following the last character in the buffer, i.e., to the end of the buffer. A typical use would be to reach the end of the buffer so that new text can be appended or added. Note : This is the first occurrence of using more than one TECO command on a line ( Z and J combined ). Command format: *ZJ  File: Tecomd, Node: Third Example, Up: Type out and Pointer Commands The following example illustrates the features of the J, ZJ, and HT commands. TECO SAMPLE.BAS Access TECO *HT$$ Type out the entire content of the buffer. 100 REM EUCLID'S ALGORIM FOR GCD 110 READ A, B 120 LET X = A 130 KET Y = B 140 LET Q = INT(X/Y 150 LET R = X - Q * Y 160 IF R = 0 THEN 210 170 LET X + Y 180 LET Y = R 190 GO TO 130 190 GO TO 140 200 REM OUTPUT A, B, AND GCD 210 PRIN A, B, Y 220 DATA 35,, 290 *T$$ Use T command to see that the pointer position is still in front of the first charac- ter in the buffer. 100 REM EUCLID'S ALGORIM FOR GCD *ZJ$$ Move pointer to position immediately after last character in buffer. *T$$ Nothing is printed because No text follows pointer. *-LV$$ Move pointer back one line and verify line. Note that commands may be on the same line, forming a command string. 220 DATA 35,, 290 *J$$ Move pointer back to beginning of the buffer. *T$$ Type out the first 100 REM EUCLID'S ALGORIM FOR GCD *EX$$ Exit Ready  File: Tecomd, Node: Deletion Commands, Up: Commands, This section describes commands which delete: . Single characters . Groups of adjacent characters . Single lines . Groups of adjacent lines * Menu: * Delete Characters:: * Kill Lines:: * Example Four::  File: Tecomd, Node: Delete Characters, Up: Deletion Commands Next: Kill Lines Note that the following commands depend entirely on the pointer position before execution. D command (Delete) This command is used to delete CHARACTERS in the buffer. The specified number of characters preceding or following the current pointer position will be deleted. Command format: *nD Where n can be negative or positive. If n < 0, the n characters preceding the current pointer position are deleted. If n > 0, the n characters following the current pointer position are deleted. If n = 0, the command is ignored. oMitting n is equivalent to 1D and -D is equivalent to -1D.  File: Tecomd, Node: Kill Lines, Up: Deletion Commands, Prev: Delete Characters, Next: Example Four K command (Kill) This command is used to delete (kill) LINES in the buffer. Depending on the position of the pointer before this instruction is used, this command will delete partial and/or full line(s) in the buffer. Command format: *nK Where n can be negative, zero, or positive. If n < 0, the n lines preceding the current pointer position are deleted. If n = 0, the content of the buffer from the beginning of the line in which the pointer is located up to the pointer is deleted. If n > 0, the n lines following the current pointer position are deleted. Omitting n is equivalent to 1K and -K is equivalent to -1K. Note: If n is positive, a line is considered to be the characters between the pointer and the end of that physical line. Therefore, if the pointer is located in the middle of a line and a 1K command is used, TECO will delete only the remainder of that line (including the line terminator). If n is negative, however, the text between a line terminating character line feed and the pointer is not included in the count of lines to be deleted but is deleted in the process anyway. The K command, in other words, keeps track of the number of line feed characters (or line terminators) in the process of deletion. Each line feed character and its preceding, not following, line of text counts as one line.  File: Tecomd, Node: Example Four, Up: Deletion Commands, Prev: Kill Lines Based on knowledge we have thus far, actual editing can now be done on the sample file. We introduce the use of deletion commands in our examples. TECO SAMPLE.BAS Call up TECO using CCL. *V$$ Verify current line. 100 REM EUCLID'S ALGORIM FOR GCD *23C$$ Move across 23 characters to correct spelling. *T$$ Check pointer position. M FOR GCD *ITH$$ Insert 'TH' *V$$ Verify current line. 100 REM EUCLID'S ALGORITHM FOR GCD Perfect ! *9LV$$ Advance pointer 9 lines and verify 190 GO TO 130 *K$$ Kill that line. *3V$$ Verify n-1 = 2 lines each side of current line. 170 LET X + Y 180 LET Y = R 190 GO TO 140 200 REM OUTPUT A, B, AND GCD 210 PRIN A, B, Y *3LV$$ Advance pointer 3 lines and verify. 220 DATA 35,, 290 *11CT$$ Move pointer across 11 characters and type the rest of the line. ,, 290 *DV$$ Delete excess comma and and verify. 220 DATA 35, 290 *EX$$ Exit TECO. Ready  File: Tecomd, Node: search Commands, Up: Commands, Prev: Deletion Commands In many instances, it is much easier to position the pointer at a desired location by means of a character string search. Search commands will scan through the text until a specified string of characters is found. A successful search will position the pointer immediately after the string. String searches work in the forward and reverse direction within the buffer. * Menu: * Search:: * Replace:: * Example Five::  File: Tecomd, Node: Search, Up: Search Commands, Next: Replace S command (Search) This command is used to search for a string of characters starting from the current pointer position. If the string is found, the pointer is positioned after the last character in the string. If it is not found, the pointer is positioned immediately before the first character in the buffer and an error message is printed ('?SRH Search failure "string"'). Command format: *nStext$ Where n may be positive or negative If n < 0, it will search for the nth occurrence of the specific 'text' in the reverse direction. If n > 0, it will search for the nth occurrence of the specific 'text' in the forward direction. Values of 1 or -1 may be omitted (i.e. Stext$ or -Stext$ are sufficient). S is the command character. text is the string of characters to be searched for. Needless to say, the user must insure its uniqueness for successful searches. $ is a single escape character to signify the end of the string to be searched for. TECO will attempt to located the string specified between the letter 'S' and the escape character. File: Tecomd, Node: Replace, Up: Search Commands, Prev: Search, Next: Example Five FS command (Search, if found, Replace) This command is a combination of several of the commands we have discussed so far. The FS command will search for a specified string of characters , once the string is found, the FS command will delete it and insert the indicated new text. Hence, the FS command is a combination of the S (search), D (delete), and I (insert) commands. Command format: *FStext1$text2$ Where: FS is the command. text1 is the string to be located and then deleted. Note the single escape character following it, which separates the first text string from the second text string. text2 is the string to be inserted in place of 'text1'. Again, a single escape character is necessary to delimit or signify the end of the string. If 'text2' is omitted, then the overall effect is find the string and delete it .  File: Tecomd, Node: Example Five, Up: Search Commands, Prev: Replace Example # 5 This example uses most of the commands we have discussed so far. In addition, we would like to also show the flexibility they provide when combined as command strings. TECO SAMPLE.BAS *HT$$ Print out buffer contents 100 REM EUCLID'S ALGORITHM FOR GCD 110 READ A, B 120 LET X = A 130 KET Y = B 140 LET Q = INT(X/Y 150 LET R = X - Q * Y 160 IF R = 0 THEN 210 170 LET X + Y 180 LET Y = R 190 GO TO 140 200 REM OUTPUT A, B, AND GCD 210 PRIN A, B, Y 220 DATA 35, 290 *SX/Y$$ Search for string 'X/Y'. *V$$ Search was successful, verify current line. 140 LET Q = INT(X/Y *I)$V$$ Now that the pointer is positioned after the string found, insert a right parenthesis at that position and verify the insertion. 140 LET Q = INT(X/Y) *S170$V$$ Search for string '170' and verify. 170 LET X + Y *FS+$=$V$$ Find '+', substitute it for '=' and verify the change. 170 LET X = Y *4LV$ Advance pointer 4 lines. 210 PRIN A, B, Y *8CIT$V$$ Move across 8 characters, insert a 'T', and verify. 210 PRINT A, B, Y *ZJ$$ Move pointer to end of the buffer. *I230 END Insert a new line at the end $$ *SKET$$ Search for the string 'KET'. ?SRH Search failure "KET" Search starts from current pointer position. Error message indicates search failed. Pointer is now at the beginning of the buffer. *SKET$V$$ Search for string 'KET' again now that the pointer is at the beginning of the buffer. 130 KET Y = B *0L4CDT$$ Move pointer back to the beginning of current line, move across 4 characters, delete 1 character and type remainder of line. ET Y = B *IL$V$$ Insert an 'L' there and verify. 130 LET Y = B *HT$$ Check the entire buffer content. 100 REM EUCLID'S ALGORITHM FOR GCD 110 READ A, B 120 LET X = A 130 LET Y = B 140 LET Q = INT(X/Y) 150 LET R = X - Q * Y 160 IF R = 0 THEN 210 170 LET X = Y 180 LET Y = R 190 GO TO 140 200 REM OUTPUT A, B, AND GCD 210 PRINT A, B, Y 220 DATA 35, 290 230 END *EX$$ All done ! Ready  TAGS: :SGAT commands:15 Insertion command:420 Type out and Pointer Commands:2420 Typeout command:2902 Verify Command:3906 Line Movement Command:4444 Character Movement Command:5100 Second Example:5847 Jump Commands:7277 Third Example:7993 Deletion Commands:9153 Delete Characters:9442 Kill Lines:10191 Example Four:11780 search Commands:12863 Search:13402 Replace:14689 Example Five:15750