Trailing-Edge
-
PDP-10 Archives
-
decuslib10-04
-
43,50334/tops7t.gno
There are no other files named tops7t.gno in the archive.
%switch qz false
%if qz
%nocontrolc
%nextlesson pub("TOPQ");
%ifend qz
%TEXT DELETEIT:
Searches and deletions with TECO.
================================
The "D" command of TECO is used to delete a few characters
in a text. The deletion begins at the pointer position.
"nD" deletes n characters from the pointer forwards,
"-nD" deletes n characters backwards from the pointer,
(Where "n" stands for an integer number.)
"D" is the same as "1D" and "-D" is the same as "-1D".
Example: if you have the text "THE SUNNSHINE" and want to
change it to "THE SUNSHINE", and if the pointer initially
is at the beginning of the text, then you can write
to TECO "6CD$$" or "7CD$$" or "7C-D$$" or "8C-D$$".
%QUESTION changing12344445678:
Assume that you have the text "12344445678" and want to
change it to "12345678". The pointer is referring to the
first character in the text. Write the shortest possible
TECO command string to do this including the two final
ESCAPE-s.
%NOEXTRA
%RIGHT 3C3D
%RIGHT 4C3D
%EXTRA
%WRONG CCC
"3C" is a shorter form for "CCC".
%WRONG "DDD"
"3D" is a shorter form for "DDD".
%WRONG $
You pushed the DOLLAR key instead of the ESCAPE key. Both
are printed as "$". If your terminal does not have ESCAPE,
use "CONTROL-#" instead.
%wrong c
No $ is necessary after a "C" command.
%WRONG 3D
"3D" is right, but you did not move the pointer to the right
position first. You should move it three steps forward from
the initial position at the beginning of the text. Use the "C"
command".
%WRONG 3D
You did not push ESCAPE twice after "3D".
%SAME
%WRONG D
To delete three characters, you write "3D".
%WRONG 3C
After moving the pointer, you delete three characters by
"3D".
%WRONG 4C
%SAME
%WRONG C
Since you start at the beginning of the text, you must
move the pointer three positions forward to get to the
section of text to be deleted.
%WRONG I
Use only the "C" and "D" commands of TECO.
%WRONG R
%SAME
%WRONG S
%SAME
%WRONG T
"T" is a printing command. I did not ask you to print anything.
%SAME
%WRONG L
%SAME
%WRONG
A hint: first move the pointer three characters forward, then
delete three characters.
%WRONG
To move the pointer three characters forward you use the "C"
command, and to delete three characters you use the "D" command.
%WRONG
You may need to repeat the lesson tops05. Do do this,
answer the next question with the single character "%".
When you have returned to the monitor, you can write "RUN TOPS05".
%QUESTION IF LASTERRORS > 0 THEN changingabcdef:
Assume that the file contains the text "ABCDEF" and you want to
delete "DEF". How do you do this in the simplest way with TECO?
Assume that the pointer initially is at the beginning of the
file text.
%NOEXTRA
%RIGHT 3C3D
%RIGHT 3C3D
%extra
%wrong 3d
Before the deletion you must use the "C" command to move the pointer
forward, write "3C" before your "D" command.
%wrong d
To delete three characters you write"3D".
%wrong 3c
No ESCAPE is necessary after "3C".
%wrong 3c
After "3C" you write "3D" do delete the next three characters.
%wrong c
To move the pointer three positions forward,
you write "3C".
%WRONG
A hint: first move the pointer three positions forward with
the "C" command, then delete three characters with the "D" command.
%WRONG
%SAME
%WRONG
Time for some repetition.
%GOTO DELETEIT
%text kcommand:
With the DELETE ("D") command you remove a certain number of
characters. There is also a command for removing a certain number
of lines. This is the "K" command.
"nK" will remove n lines from the position of the pointer.
Example: "0LK" will remove the current line,
"0K" will remove the current line up to the position of the pointer,
"K" will remove the part of the current line after the
position of the pointer,
"0L5K" will remove five full lines.
%question qonkcommand:
What will be removed by the command "0KK".
%order
%extra
%right the whole current line
%wrong except
There are no exceptions!!
%wrong 2
Only one line is removed, "0K" and "K" represents removal of
different parts of the same line.
%wrong two
%same
%wrong lines
%same
%right whole current line
%right whole line
%right actual line
%right one line
%right the current line
%right current line
%right line pointer
%right this line
%right 1 line
%noextra
%right a line
%extra
%neutral a line
I am not sure if your answer was right or wrong, please try
to rephrase it without using the article "A".
%wrong line k
"K" is not a line number, it is a deletion command.
%neutral line
I'm not sure if your answer was right or wrong. Try to
rephrase your answer.
%algol extratest; goto repeat;
%wrong page
Much less than a whole page is removed.
(To remove a whole page you write "HK".)
%wrong
A hint: "0K" removes the current line up to the pointer,
and "K" will remove the current line from the pointer.
%wrong
%same
%wrong
The correct answer is: The whole current line.
%TEXT SCOMMAND:
The search "S" command.
======================
The simplest way to move the pointer to the correct place is
usually to use the "S" command, since then you will not have
to count the characters.
The "S" command consists of the letter "S", a search string,
and is ended by the ESCAPE key.
%TEXT
Example: "S4444$" searches for the first occurence of the
string "4444" in the text. The search begins at the current
position of the pointer. After the search, the pointer is placed
at the position immediately following the matching
string in the file.
Thus "S4444$" on the text "012344445678" will position the
pointer at the character "5" in the file.
%QUESTION comment she walked slowly back,;
Assume that the file contains the text
"SHE WALKED SLOWLY BACK, FEELING CONTENTED."
and the pointer is at the beginning of the file. How do you
place it at the ",", using the shortest possible search command.
Include in your answer the two final ESCAPE-s
to cause execution of the command string.
%NOEXTRA
%RIGHT SCK
%RIGHT 2SK
%EXTRA
%WRONG ,
If you want to position the pointer before the ",", you cannot include
the "," in your search string, since the pointer is placed after
the matching string has been found.
%WRONG R
Only use the "S" command, and no other TECO command.
%WRONG ACK
You only have to search for "CK", since there is no "CK"
In the text before the "CK" in "BACK".
%WRONG SK
You cannot search only for "K", since there is a previous "K"
in "WALKED" before the "K" in "BACK" which you are searching
for.
%WRONG
You only need push ESCAPE twice.
%wrong sck
You must push ESCAPE twice after "SCK".
%lack
You did not push "ESCAPE" twice to get the command executed
by TECO.
%lack s
Your answer did not contain any search command "S".
%WRONG
A hint: you search for the string "CK" since then you will
position the pointer after "CK" in back, that is before
the ",".
%WRONG
Use the "S" command, whose format is
"S ... search string ... $".
%SAME
%WRONG
The correct answer is "SCK$$" which means
1) search for the string "CK"
2) position the pointer after the found string
3) execute the previous TECO commands
%GOTO NEXT
%QUESTION IF LASTERRORS > 0 THEN comment 0123 4567 8902 4680 3691;
Assume that the file contains the text
"0123 4567 8902 4680 3691" with the pointer at the beginning.
Write the shortest possible TECO "S" command including
two final ESCAPE-s to cause immediate execution, which
will put the pointer at the "5" in the input text.
%NOEXTRA
%RIGHT S4
%EXTRA
%WRONG 5
Do not search for "5" since that will place the pointer after the
"5", not at the "5".
%lack
You forgot the two final "ESCAPE"s.
%wrong s 4
You need only search for the "4" since there is no previous
"4" in the text to be scanned. Searching for more than the "4"
will not give the shortest possible TECO command, which is
what was asked for.
%wrong 3
%same
%wrong 5
%same
%WRONG
A hint: search for the "4" in front of the "5".
%WRONG
%SAME
%WRONG
The correct answer is "S4$$".
Time for some repetition.
%GOTO SCOMMAND
%QUESTION comment Nicolaus had grown fatter;
Assume that the file contains the text
"NICOLAUS HAD GROWNED FATTER."
and you want to remove the "ED" in "GROWNED". Use first
the "S" command and then the "D" command and then the final
two ESCAPE-s to cause execution of the command string.
Find the shortest correct TECO command string to do this.
%NOEXTRA
%right SEd-d
%right SE-dd
%RIGHT SWN2D
%RIGHT SWNDD
%RIGHT 2SN2D
%RIGHT 2SNDD
%right SWCDD
%right SWC2D
%wrong sed-3d
This is correct, but not the shortest possible
solution. Search for the text immediately before "ED"
instead of searching for "ED".
%EXTRA
%wrong #
You must keep the CONTROL key pushed down while pushing the "#" key
to get ESCAPE.
%wrong {
%same
%wrong sf r
The command string will be shorter if you search for something
in front of the section to be removed, since you can then use
a positive number in front of the "D".
%wrong - d
%same
%wrong sf
After a search command, the pointer will be positioned after, not
in front of what you searched for.
%wrong d2
The number indicating how many characters you want to remove should
be in front of, not after the "D" command.
%lack s
Use the "S" command for searching.
%LACK
You forgot the two ESCAPE:s finishing the command string
to TECO.
%lack
The beginning of a search string is marked with "S" and the end
of the search string with ESCAPE. Did you forget that ESCAPE?
%LACK D
To delete characters in the text, use the "D" TECO command.
%LACK D
The deletion "D" command should come immediately before the
final two ESCAPEs.
%WRONG ED
Do not search for "ED", the command will be shorter if you search
for the text immediately in front of "ED".
%wrong sw2D
Either search for "WN" or else search for "W" and make a "C"
command immediately after "SW$". After "SW$" the pointer refers to
"NED" not to "ED"!
%wrong swD
%same
%WRONG SWN
You forgot the deletion using the "D" command.
%wrong SWN
After "SWN$" you delete the next two characters with "2D".
%WRONG SWN
You forgot the ESCAPE after "SWN". A search string must be delimited by
a "S" in front and an ESCAPE after it.
%WRONG OWN
You do not have to search for more than "WN" to find the right
place to start your deletions from.
%wrong SWN
After "SWN$" delete the next two characters using the "D"
command.
%wrong SN
You cannot search for only "N" since then you will find the
"N" in "NICOLAUS" and not the "N" in "GROWNED".
%lack
You forgot the two final "ESCAPE"s.
%WRONG
A hint: search for "WN" and then delete the two following
characters.
%WRONG
%SAME
%WRONG
The correct answer is "SWN$2D$$".
Time for some repetition.
%GOTO SCOMMAND
%text if lastrights > 0 and percent > 75.0 then
You are doing very well. Congratulations.
%text if lastrights > 0 and percent < 75.0 then
The last question was not simple, but you made it.
Congratulations.
%text
You may precede the "S" command with an integer i. In that
case the computer will look for the i:th occurence of the
string. For example, a possible answer to the previous
question is:
2SN$2D$$
That is, delete two characters after the second occurence of "N".
%TEXT
Sometimes you want to replace a word in the file with another
word. A simple way to do this is the "FS" command which has
two argument strings. The command searches for a match to
the first argument, and replaces the match part of the
file with the second argument.
Example: "FSONE$TWO$$" will search for the first occurence of
the word "ONE" and change it to "TWO".
%QUESTION Bernhard:
Assume that the file contains the text
"SHE IMAGINED THAT BERNHARD MUST BE MADLY IN LOVE."
and you want to change "BERNHARD" to "BEATRICE". How do you do it
with the "FS" command including the two final ESCAPE-s?
%NOEXTRA
%RIGHT FSBERNHARDBEATRICE
A shorter way would be to write "FSRNHARD$ATRICE$$".
%RIGHT FSERNHARDEATRICE
%SAME
%RIGHT FSRNHARDATRICE
%order
%extra
%lack F S
You use the "FS" command to search for a string and then replace
that part with something else.
%lack rnhard
Your answer does not contain the string "RNHARD".
%lack atrice
Your answer does not contain the string "ATRICE".
%wrong #
Keep the CONTROL key down while pushing "#" to get ESCAPE.
%wrong {
%same
%lack
Your answer does not contain the two ESCAPE-s in immediate
succession which mark the end of the command string for execution.
%WRONG
%WRONG
Write "FS", the search string, ESCAPE, the substitution string,
and two final ESCAPE-s.
%WRONG
%SAME
%WRONG
the correct answer is "FSRNHARD$ATRICE$$". "FSBERNHARD$BEATRICE$$"
will also give the same effect.
%GOTO NEXT
%text
If you precede the "FS" commad with an integer i, only the i:th
occurence of the search string will be substituted.
%question qdon1:
Suppose you have the text
LISP EATS LISP
with the pointer referring to the beginning of the line. What
does the line look like after the command
2FSLISP$TRAC$$
has been executed?
%order
%noextra
%right lisp eats trac
You are smarter than I thought...
%extra
%wrong trac eats trac
Only the second occurence of LISP will be substituted.
%wrong trac eats lisp
WHAT! Are you crazy!?!
It was the SECOND occurence, not the first.
%wrong lisp eats lisp
This is the line before it was changed.
%lack lisp
What happened with the word "LISP"?
%lack eats
What happened with the word "EATS"?
%lack trac
You forgot to put in "TRAC".
%wrong
%wrong
A hint: Change the second occurence of "LISP" to "TRAC".
%TEXT
After a search, you often want to check that you have arrived at the
right place before you do any deletions or insertions. This can be
done by "T" to print the text after the pointer or "0T" to print
the text up to the pointer.
Example: to search for "BERNHARD" and then print the text up to the
new pointer position, you write "SBERNHARD$0T$$".
%text if percent < 85.0 then
I know this lesson was difficult, but thank you for your diligence.
%TEXT
Before going on to the next lesson, try out the new
commands "D", "K", "S" and "FS" with TECO.
%if qz
To try them out, you must LOG IN on another project-programmer
number than 66,66.
%ifend qz
%text summary:
Summary
=======
TECO Command Effect
------------ ------
nD Delete n characters
nK Delete n lines starting from the pointer
0K Delete the line up to the pointer
nS<str>$ Search for the n:th occurence of the string
<str> in th text
nFS<str1>$<str2>$
Substitute the string <str2> for the n:th
occurence of the string <str1> in the text.
%END