Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-11 - 43,50537/sed03.gno
There are no other files named sed03.gno in the archive.
%NOCONTROLC
%VARIABLES INTEGER ANSWER1, ANSWER2, ANSWER3, DUMMY;
%VARIABLES string answer4;
%variables boolean mime;
%ALGOL EXTERNAL PROCEDURE NOECHO,XECHO,NOCRLF,INCH,TTOPEN;
%INITIALIZE stopkc; f10call(nocrlf); INPUT(0,"TTY");
%TEXT
This lesson describes the screen editor SED as used on a MIME-2A
or VT-100, in VT-52 mode.
You shouldn't be running this lesson on any other terminal.

%QUESTION  mime2a:
Are you using a MIME-2A?
%neutral yes
%algol mime := TRUE;
%GOTO continue;
%neutral YES
%algol mime := TRUE;
%GOTO continue;
%neutral Yes
%algol mime := TRUE;
%GOTO continue;
%neutral Y
%algol mime := TRUE;
%GOTO  continue;
%neutral y
%algol mime := TRUE;
%GOTO  continue;
%neutral no
%GOTO vt100;
%neutral NO
%SAME
%neutral N
%same
%neutral n
%same
%neutral No
%Same
%neutral
Please answer yes or no.
%goto mime2a;
%QUESTION  vt100:
Are you using a VT-100?
%neutral yes
%algol mime := FALSE;
%GOTO continue;
%neutral YES
%algol mime := FALSE;
%GOTO continue;
%neutral Yes
%algol mime := FALSE;
%GOTO continue;
%neutral Y
%algol mime := FALSE;
%GOTO  continue;
%neutral y
%algol mime := FALSE;
%GOTO  continue;
%neutral no
Well then, please try again when you're on a MIME or VT-100.
%GOTO endoflesson;
%neutral NO
%SAME
%neutral N
%same
%neutral n
%same
%neutral No
%Same
%neutral
Please answer yes or no.
%goto vt100;
%TEXT continue: pause;
The text of this lesson is taken mostly from the
document DOC:SEDMAN.DOC (by Christopher Hall).
The SED lessons do not give you a complete description of SED,
but will give you enough knowledge to get you started.
If you want to learn the more complicated commands, you should
read the document DOC:SED.DOC, but it is not recommended that you
read it until you're comfortable with the commands you learn
in the lessons.
%TEXT outsymbol(12);
Purpose of this Lesson
======================
     In this lesson, you will learn
	-how to position yourself at any point in the file,
	-how to find any text-string, and
	-how to move or copy any part of the file to another
	 location in the file.
%TEXT outsymbol(12);
Moving a given percentage of the way through the file
=====================================================
     You can get to a given percentage of the way through
a file by using the <PERCENT-GOTO> command: Control-P.
For example if you want to get half way through the file,
that is, fifty percent (50%) through the file,
you would give the command:

        <ENTER-PARAMETER>50<PERCENT-GOTO>

That is <BLUE or PF1 KEY>50<CONTROL-P>.
The beginning of the file is 0% and the end of the
file is 100%. You can give any integer between 0 and
100 as a parameter to this command.
%TEXT outsymbol(12);
     Since this command is used very often to get to
the end of the file, there is a shorthand way of asking
for the end of the file, which is to type:

        <ENTER-PARAMETER><PERCENT-GOTO>

That is, just the Blue or PF1 key, and the command (CTRL-P),
with no parameter.
%ALGOL
begin dummy:=0; qcount:=qcount+1; COMMENT initialize dummy (counts the number
of times a question is tried over), increment qcount (counts questions
attempted);
question3:
COMMENT clear screen, cursor home;
outsymbol(27); outsymbol(72); outsymbol(27); outsymbol(74);
write("Pretend you are in SED, and this is the text of the file.");
write("[N]You want to get 75% through the file.");
write("[N]What command do you give to SED?");
breakoutput;
f10call(noecho);
outsymbol(27); outsymbol(61); COMMENT enter alternate keypad mode;
breakoutput;
getenter3: COMMENT position cursor last line, blank it out, cursor home;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
outsymbol(27); outsymbol(75); outsymbol(27); outsymbol(72);
breakoutput;
dummy := dummy + 1; COMMENT increment dummy;
f10call(inch,answer1,answer2,answer3); COMMENT input character;
COMMENT if ESC, see next char, if "P", go get parameter;
if answer1 = 27 then
  begin
     if answer2 = 80 then
          goto getparam3
  end;
COMMENT if control-C or "%" allow user to exit question;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT3;
COMMENT if not ESC P, error message and start over;
write("[6N]"); outsymbol(27); outsymbol(75);
if MIME then
     write("No! The <ENTER-PARAMETER> command is the BLUE key")
else
     write("No! The <ENTER-PARAMETER> command is the PF1 key");
write("[N]Please try over.                    ");
goto getenter3;
getparam3: COMMENT position cursor bottom left, reverse video, output
parameter prompt, unreverse video;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
if MIME then
  begin
     outsymbol(27); outsymbol(83); outsymbol(66)
  end
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(50); outsymbol(52); outsymbol(59);
     outsymbol(48); outsymbol(72); comment position to last line;
     outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(109);
     comment reverse video;
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
  end;
write(">");
if MIME then
  begin
     outsymbol(27); outsymbol(83); outsymbol(64)
  end
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(48); outsymbol(109);
     comment unreverse video;
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
  end;
breakoutput;
f10call(inch,answer1,answer2,answer3); COMMENT input char;
COMMENT if control-C or "%" allow user to exit;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT3;
COMMENT if "7" then type it and get the rest of the parameter ("5");
if answer1 = 55 then
  begin
     outsymbol(55);
     breakoutput;
     goto getmoreparam;
  end;
COMMENT if ESC see next char, if "?",output error message;
if answer1 = 27 then
  begin
     if answer2 = 63 then
       begin
	  outsymbol(27); outsymbol(72);
          write("[4N]"); outsymbol(27); outsymbol(75);
          write("Keep in mind that the numerical keypad keys");
          write("[N]"); outsymbol(27); outsymbol(75);
	  write("are commands for SED, not characters")
       end
  end;
COMMENT if printable, print it;
if answer1 > 31 then
     outsymbol(answer1);
outsymbol(27); outsymbol(72); COMMENT cursor home;
COMMENT error message, start over;
write("[6N]"); outsymbol(27); outsymbol(75);
write("The parameter you want to enter is the number 75.");
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter3;
getmoreparam: f10call(inch,answer1,answer2,answer3); COMMENT input next part of parameter;
COMMENT if control-C or "%";
if (answer1 = 3) or (answer1 = 37) then goto KCOUT3;
COMMENT if "5" then go get command;
if answer1 = 53 then
  begin
     outsymbol(53);
     breakoutput;
     goto getcommand3;
  end;
COMMENT same deal as above for ESCAPE;
if answer1 = 27 then
  begin
     if answer2 = 63 then
       begin
	  outsymbol(27); outsymbol(72);
          write("[4N]"); outsymbol(27); outsymbol(75);
          write("Keep in mind that the numerical keypad keys");
          write("[N]"); outsymbol(27); outsymbol(75);
	  write("are commands for SED, not characters")
       end
  end;
COMMENT if printable, print it;
if answer1 > 31 then
     outsymbol(answer1);
outsymbol(27); outsymbol(72); COMMENT cursor home;
COMMENT error message, start over;
write("[6N]"); outsymbol(27); outsymbol(75);
write("The parameter you want to enter is the number 75   ");
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter3;
getcommand3: f10call(inch,answer1,answer2,answer3); COMMENT input char;
COMMENT if control-C, allow user to exit ("%" might be an attempt by user to
use  "%" for indicating percentage, in this case);
if answer1 = 3 then goto KCOUT3;
COMMENT if control-P, right answer, get out;
if answer1 = 16 then
	goto outCP;
COMMENT error message if control char, not control-P, start over;
if answer1 < 27 then
  begin
     outsymbol(27); outsymbol(72);
     write("[6N]"); outsymbol(27); outsymbol(75);
     write("<PERCENT-GOTO> command is control-P.");
     write("[N]Please try over, from the beginning"); breakoutput;
     goto getenter3
  end;
COMMENT if printable, print it;
if answer1 > 31 then
     outsymbol(answer1);
outsymbol(27); outsymbol(72); COMMENT cursor home;
COMMENT error message if user puts "%" at end of parameter;
if answer1 = 37 then
  begin
     write("[4N]"); outsymbol(27); outsymbol(75);
     write("You should not put a percent sign (%)");
     write("[N]"); outsymbol(27); outsymbol(75);
     write("in the parameter.");
     outsymbol(27); outsymbol(72);
     breakoutput
  end;
COMMENT error message if not a control-character, start over;
write("[6N]"); outsymbol(27); outsymbol(75);
write("Give the command after you give the parameter");
write("[N]Please try over, from the beginning"); breakoutput;
goto getenter3;
OUTCP: COMMENT position cursor bottom left, blank out parameter;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
outsymbol(27); outsymbol(75);
COMMENT clear screen, cursor home, write text;
outsymbol(27); outsymbol(72); outsymbol(27); outsymbol(74);
write("This is the text which is located at the point");
write("[N]seventy-five percent through the file");
write("[N]Note that it does not matter where you were");
write("[N]when you issued the command.");
write("[N]The 75% point will not change until you add");
write("[N]or delete lines in the file.");
write("[NN]Let's see if you can answer the next question");
if dummy < 3 then write("[N]as well as ")
        else write("[N]better than ");
write("you did this last one.");
breakoutput;
COMMENT update scores, get out;
latescore := latescore + 1; if dummy = 1 then score := score + 1;
goto question3out;
COMMENT go here if control-C or "%";
KCOUT3: outsymbol(27); outsymbol(72); outsymbol(27);
outsymbol(74);
write("Type BACK to try this question over");
write("[N]     SKIP to go to the next section");
write("[N]     STOP to end this lesson");
write("[N]--->");
breakoutput;
getline;
POS:=1;
if anywhere("STOP") then goto endoflesson;
POS:=1;
if anywhere("BACK") then goto question3;
POS:=1;
if anywhere("SKIP") then goto question3out;
goto KCOUT3
END;
%TEXT QUESTION3OUT: outsymbol(27); outsymbol(62); COMMENT exit alternate keypad;

%ALGOL
begin dummy:=0; qcount:=qcount+1; COMMENT initialize dummy, increment qcount;
question4:
COMMENT clear screen, cursor home;
outsymbol(27); outsymbol(72); outsymbol(27); outsymbol(74);
write("Pretend you are in SED, and this is the text of the file.");
write("[N]You want to get to the end of the file with as few");
write("[N]keystrokes as possible.");
write("[N]What command do you give to SED?");
breakoutput;
f10call(noecho);
outsymbol(27); outsymbol(61); COMMENT enter alternate keypad mode;
breakoutput;
getenter4: COMMENT position cursor bottom left, blank line, cursor home;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
outsymbol(27); outsymbol(75); outsymbol(27); outsymbol(72);
breakoutput;
dummy := dummy + 1; COMMENT increment dummy;
f10call(inch,answer1,answer2,answer3); COMMENT input char;
COMMENT if control-C or "%" allow user to exit question;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT4;
COMMENT handle ESCapes as usual;
if answer1 = 27 then
  begin
     if answer2 = 80 then
          goto getcommand4
  end;
COMMENT if not ESC P, error message, try over;
if MIME then
     write("[NNNNNN]No! The <ENTER-PARAMETER> command is the BLUE key")
else
     write("[NNNNNN]No! The <ENTER-PARAMETER> command is the PF1 key");
write("[N]Please try over.                    ");
goto getenter4;
getcommand4: COMMENT position cursor bottom left, reverse video, type
parameter prompt, unreverse video;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
if MIME then
  begin
     outsymbol(27); outsymbol(83); outsymbol(66)
  end
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(50); outsymbol(52); outsymbol(59);
     outsymbol(48); outsymbol(72); comment position to last line;
     outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(109);
     comment reverse video;
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
  end;
write(">");
if MIME then
  begin
     outsymbol(27); outsymbol(83); outsymbol(64)
  end
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(48); outsymbol(109);
     comment unreverse video;
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
  end;
breakoutput;
f10call(inch,answer1,answer2,answer3); COMMENT input char;
COMMENT if control-C or "%" allow user to exit;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT4;
COMMENT if control-P, right answer, get out;
if answer1 = 16 then
	goto outCP2;
COMMENT if real character (not control, or esc, etc) user is probably trying to
use a parameter, error message and try again;
if answer1 > 31 then
  begin
     outsymbol(answer1);
     outsymbol(27); outsymbol(72);
     write("[NNNNNNN]You don't need a parameter.                    ");
     write("[N]Please try over, from the beginning");
     breakoutput;
     goto getenter4
  end;
COMMENT if control character, not control-P, wrong command, error message;
if answer1 < 27 then
  begin
     outsymbol(27); outsymbol(72);
     write("[NNNNNNN]<PERCENT-GOTO> command is control-P                     ");
     write("[N]Please try over, from the beginning"); breakoutput;
     goto getenter4
  end;
COMMENT if none of the above (probably ESC), error message, try again;
outsymbol(27); outsymbol(72);
write("[NNNNNNN]Give the command after you type <ENTER-PARAMETER>           ");
write("[N]Please try over, from the beginning"); breakoutput;
goto getenter4;
OUTCP2: COMMENT position cursor bottom left, blank out parameter;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
write("                           ");
COMMENT clear screen, cursor home, write text;
outsymbol(27); outsymbol(72); outsymbol(27); outsymbol(74);
write("This is the text located at the end of the file.");
write("[NN]Note that when you are at the end of the file");
write("[N]SED puts out a message at the bottom of the");
write("[N]screen indicating that you have reached the");
write("[N]end of the file. To show that it's not part of");
write("[N]the file, it will be typed in reverse video.");
COMMENT position cursor bottom left, reverse video, type "fence" message,
unreverse video, cursor home;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
if MIME then
  begin
     outsymbol(27); outsymbol(83); outsymbol(66)
  end
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(50); outsymbol(52); outsymbol(59);
     outsymbol(48); outsymbol(72); comment position to last line;
     outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(109);
     comment reverse video;
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
  end;
write("   *** This FENCE marks the last page of the file but is NOT a part of it ***  ");
if MIME then
  begin
     outsymbol(27); outsymbol(83); outsymbol(64)
  end
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(48); outsymbol(109);
     comment unreverse video;
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
  end;
outsymbol(27); outsymbol(72);
breakoutput;
COMMENT position cursor so "push return" message won't overwrite anything;
write("[NNNNNNNNNN]");
breakoutput; pause;
COMMENT update scores, get out;
latescore := latescore + 1; if dummy = 1 then score := score + 1;
goto question4out;
COMMENT go here if control-C or "%";
KCOUT4: outsymbol(27); outsymbol(72); outsymbol(27);
outsymbol(74);
write("Type BACK to try this question over");
write("[N]     SKIP to go to the next section");
write("[N]     STOP to end this lesson");
write("[N]--->");
breakoutput;
getline;
POS:=1;
if anywhere("STOP") then goto endoflesson;
POS:=1;
if anywhere("BACK") then goto question4;
POS:=1;
if anywhere("SKIP") then goto question4out;
goto KCOUT4
QUESTION4OUT: outsymbol(27); outsymbol(62);
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
outsymbol(27); outsymbol(75)
END;
%TEXT outsymbol(12);
Searches
========
     You can search for any text string by typing

        <ENTER-PARAMETER><text-string><SEARCH-FORWARD>
or
        <ENTER-PARAMETER><text-string><SEARCH-BACKWARD>

where <text-string> is your search key (without the brackets),
<SEARCH-FORWARD> is control-R, and <SEARCH-BACKWARD> is control-E.
In the first case, the file will be searched from the cursor position
to the end (if necessary), and the cursor will be positioned at
the start of the next occurrence of <text-string>. In the second
case, the file will be searched from the cursor position to the
beginning (if necessary), and the cursor will be positioned
at the start of the previous occurrence of <text-string>.
     The search parameter is shared by both <SEARCH> commands.
%TEXT
     The next question is difficult. Give the terminal time to
react after each of your keystrokes. Watch after each keystroke
to make sure you didn't get an error message, before continuing
to type.
%ALGOL
begin dummy:=0; qcount:=qcount+1; COMMENT initialize dummy, increment qcount;
question5:
COMMENT clear screen, cursor home;
outsymbol(27); outsymbol(72); outsymbol(27); outsymbol(74);
write("Pretend you are in SED, and this is the beginning of the file.");
write("[N]You want to find the first occurrence of the word ""snark"".");
write("[N]What command do you give to SED?");
breakoutput;
f10call(noecho);
outsymbol(27); outsymbol(61); COMMENT enter alternate keypad mode;
breakoutput;
getenter5: COMMENT position cursor bottom left, blank line, cursor home;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
outsymbol(27); outsymbol(75); outsymbol(27); outsymbol(72);
breakoutput;
dummy := dummy + 1; COMMENT increment dummy;
f10call(inch,answer1,answer2,answer3); COMMENT input char;
COMMENT if control-C or "%" allow user to exit;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT5;
COMMENT handle ESCapes as usual;
if answer1 = 27 then
  begin
     if answer2 = 80 then
          goto gets
  end;
COMMENT if not ESC P, error message and start over;
if MIME then
     write("[6N]No! The <ENTER-PARAMETER> command is the BLUE key")
else
     write("[6N]No! The <ENTER-PARAMETER> command is the PF1 key");
write("[N]Please try over.                    ");
goto getenter5;
gets: COMMENT cursor bottom left, reverse video, parameter prompt, unreverse
video;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
if MIME then
  begin
     outsymbol(27); outsymbol(83); outsymbol(66)
  end
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(50); outsymbol(52); outsymbol(59);
     outsymbol(48); outsymbol(72); comment position to last line;
     outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(109);
     comment reverse video;
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
  end;
write(">");
if MIME then
  begin
     outsymbol(27); outsymbol(83); outsymbol(64)
  end
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(48); outsymbol(109);
     comment unreverse video;
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
  end;
breakoutput;
f10call(inch,answer1,answer2,answer3); COMMENT input char;
COMMENT if control-C or "%" allow user to exit;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT5;
COMMENT if "s" type it out and go get an "n";
if answer1 = 115 then
  begin
     outsymbol(answer1);
     breakoutput;
     goto getn
  end;
COMMENT if printable, print it;
if answer1 > 31 then
     outsymbol(answer1);
outsymbol(27); outsymbol(72);
COMMENT if "S" error message for case, otherwise other error message;
if answer1 = 83 then
  begin
     write("[NNNNN]Searches are case-dependant: use lower-case        [N]");
     outsymbol(27); outsymbol(75)
  end
else
     write("[6N]The word you are searching for is ""snark"".         ");
COMMENT if wrong parameter, start over;
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter5;
getn: f10call(inch,answer1,answer2,answer3); COMMENT input char;
COMMENT if control-C or "%" allow user to get out;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT5;
COMMENT if "n" type it, go get an "a";
if answer1 = 110 then
  begin
     outsymbol(answer1);
     breakoutput;
     goto geta
  end;
COMMENT if character is printable, print it;
if answer1 > 31 then
     outsymbol(answer1);
outsymbol(27); outsymbol(72);
COMMENT if wrong parameter, error message, start over;
if answer1 = 78 then
  begin
     write("[5N]Searches are case-dependant: use lower-case        [N]");
     outsymbol(27); outsymbol(75)
  end
else
     write("[6N]The word you are searching for is ""snark"".         ");
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter5;
geta: f10call(inch,answer1,answer2,answer3); COMMENT input char;
COMMENT if control-C or "%" allow user to exit;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT5;
COMMENT if "a" print it, go get an "r";
if answer1 = 97 then
  begin
     outsymbol(answer1);
     breakoutput;
     goto getr
  end;
COMMENT if character is printable, print it;
if answer1 > 31 then
     outsymbol(answer1);
outsymbol(27); outsymbol(72);
COMMENT error message, start over;
if answer1 = 65 then
  begin
     write("[NNNNN]Searches are case-dependant: use lower-case        [N]");
     outsymbol(27); outsymbol(75)
  end
else
     write("[6N]The word you are searching for is ""snark"".         ");
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter5;
getr: f10call(inch,answer1,answer2,answer3); COMMENT input char;
COMMENT if control-C or "%" allow user to get out;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT5;
COMMENT if "r" print it and get a "k";
if answer1 = 114 then
  begin
     outsymbol(answer1);
     breakoutput;
     goto getk
  end;
COMMENT if character is printable, print it;
if answer1 > 31 then
     outsymbol(answer1);
outsymbol(27); outsymbol(72);
COMMENT error message, start over;
if answer1 = 82 then
  begin
     write("[NNNNN]Searches are case-dependant: use lower-case        [N]");
     outsymbol(27); outsymbol(75)
  end
else
     write("[6N]The word you are searching for is ""snark"".         ");
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter5;
getk: f10call(inch,answer1,answer2,answer3); COMMENT input char;
COMMENT handle control-C or "%";
if (answer1 = 3) or (answer1 = 37) then goto KCOUT5;
COMMENT if "k", print it and get the command;
if answer1 = 107 then
  begin
     outsymbol(answer1);
     breakoutput;
     goto getcommand5
  end;
COMMENT if printable, print it;
if answer1 > 31 then
     outsymbol(answer1);
COMMENT error message, start over;
outsymbol(27); outsymbol(72);
if answer1 = 75 then
  begin
     write("[NNNNN]Searches are case-dependant: use lower-case        [N]");
     outsymbol(27); outsymbol(75)
  end
else
     write("[6N]The word you are searching for is ""snark"".         ");
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter5;
getcommand5: f10call(inch,answer1,answer2,answer3); COMMENT input char;
COMMENT handle control-C or "%";
if (answer1 = 3) or (answer1 = 37) then goto KCOUT5;
COMMENT if control-R, correct answer, get out;
if answer1 = 18 then
	goto outCR;
COMMENT control-E (search backward) gets special error message, start over;
if answer1 = 5 then
  begin
     outsymbol(27); outsymbol(72);
     write("[6N]Control-E is <SEARCH-BACKWARD>.                 ");
     write("[N]Please try over, from the beginning");
     goto getenter5
  end;
COMMENT error message for wrong control-character, start over;
if answer1 < 27 then
  begin
     outsymbol(27); outsymbol(72);
     write("[6N]<SEARCH-FORWARD> command is control-R                  ");
     write("[N]Please try over, from the beginning"); breakoutput;
     goto getenter5
  end;
COMMENT if printable, print;
if answer1 > 31 then
     outsymbol(answer1);
COMMENT error message (for non-control character), start over;
outsymbol(27); outsymbol(72);
write("[6N]Give the command after you give the parameter              ");
write("[N]Please try over, from the beginning"); breakoutput;
goto getenter5;
OUTCR: COMMENT cursor bottom left, blank parameter, cursor home;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
write("                           ");
outsymbol(27); outsymbol(72);
COMMENT write message;
write("[NNNNN]"); outsymbol(27); outsymbol(75);
write("[N]Ok. The cursor is now at the first occurrence of ""snark"".");
write("[N]Push RETURN to continue            ");
COMMENT position cursor on "s" of "snark", wait for carriage-return;
breakoutput; outsymbol(27); outsymbol(89); outsymbol(33); outsymbol(83);
breakoutput; getline;
COMMENT update scores;
latescore := latescore + 1; if dummy = 1 then score := score + 1;
goto question61;
COMMENT go here if control-C or "%";
KCOUT5: outsymbol(27); outsymbol(72); outsymbol(27);
outsymbol(74);
write("Type BACK to try this question over");
write("[N]     SKIP to go to the next section");
write("[N]     STOP to end this lesson");
write("[N]--->");
breakoutput;
getline;
POS:=1;
if anywhere("STOP") then goto endoflesson;
POS:=1;
if anywhere("BACK") then goto question5;
COMMENT if skip this question, skip next too, since it depends on this one;
POS:=1;
if anywhere("SKIP") then goto question6out;
goto KCOUT5;
question61: dummy := 0; qcount:=qcount+1; COMMENT initialize dummy, increment
qcount;
question6:
write("[NNNNNNN]You have just found the first occurrence of");
write("[N]the word ""snark"", and now you want to find the last");
write("[N]occurrence of ""snark"". So you should go to the end");
write("[N]of the file, and search backward.");
write("[N]Try to do this.");
breakoutput;
outsymbol(27); outsymbol(61); COMMENT enter alternate keypad mode;
breakoutput;
getenter6: COMMENT position cursor bottom left, blank line, cursor on snark;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
outsymbol(27); outsymbol(75);
outsymbol(27); outsymbol(89); outsymbol(33); outsymbol(83);
breakoutput;
dummy := dummy + 1; COMMENT increment dummy;
f10call(inch,answer1,answer2,answer3); COMMENT input char;
COMMENT if control-C or "%" allow user to exit;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT6;
COMMENT handle ESCapes as usual;
if answer1 = 27 then
  begin
     if answer2 = 80 then
          goto getcommand6
  end;
COMMENT if not ESC P, error message, start over;
if MIME then
     write("[14N]No! The <ENTER-PARAMETER> command is the BLUE key")
else
     write("[14N]No! The <ENTER-PARAMETER> command is the PF1 key");
write("[N]"); outsymbol(27); outsymbol(75);
write("Give the command to get to the end of the file.");
write("[N]Please try over.                    ");
goto getenter6;
getcommand6: COMMENT position cursor bottom left, reverse video, parameter
prompt, unreverse video;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
if MIME then
  begin
     outsymbol(27); outsymbol(83); outsymbol(66)
  end
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(50); outsymbol(52); outsymbol(59);
     outsymbol(48); outsymbol(72); comment position to last line;
     outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(109);
     comment reverse video;
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
  end;
write(">");
if MIME then
  begin
     outsymbol(27); outsymbol(83); outsymbol(64)
  end
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(48); outsymbol(109);
     comment unreverse video;
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
  end;
breakoutput;
f10call(inch,answer1,answer2,answer3); COMMENT input char;
COMMENT handle control-C or "%";
if (answer1 = 3) or (answer1 = 37) then goto KCOUT6;
COMMENT if control-P, great, go continue;
if answer1 = 16 then
	goto outCP3;
COMMENT if not control char, and not escape (normal printable character), print
it, output error message, and start over;
if answer1 > 31 then
  begin
     outsymbol(answer1);
     outsymbol(27); outsymbol(72);
     write("[15N]You don't need a parameter.                             ");
     write("[N]"); outsymbol(27); outsymbol(75);
     write("Give the command to get to the end of the file.");
     write("[N]Please try over, from the beginning");
     breakoutput;
     goto getenter6
  end;
COMMENT if control character other thatn ctrl-P, error message, start over;
if answer1 < 27 then
  begin
     outsymbol(27); outsymbol(72);
     write("[15N]<PERCENT-GOTO> command is control-P                     ");
     write("[N]"); outsymbol(27); outsymbol(75);
     write("Give the command to go to the end of the file.");
     write("[N]Please try over, from the beginning"); breakoutput;
     goto getenter6
  end;
COMMENT if none of the above (probably ESC), error message, start over;
outsymbol(27); outsymbol(72);
write("[15N]Give the command after you type <ENTER-PARAMETER>          ");
write("[N]"); outsymbol(27); outsymbol(75);
write("Give the command to go to the end of the file.");
write("[N]Please try over, from the beginning"); breakoutput;
goto getenter6;
OUTCP3: COMMENT position bottom left, blank parameter;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
outsymbol(27); outsymbol(75);
COMMENT clear screen, cursor home, type 'last page';
outsymbol(27); outsymbol(72); outsymbol(27); outsymbol(74);
write("Good! You are now at the end of the file.");
write("[NN]Now you must try to find the last occurrence of");
write("[N]the word ""snark"". Keep in mind that you have");
write("[N]already searched for that word once before");
write("[N]so you don't need to enter it again as a parameter.");
COMMENT position bottom left, reverse video, type 'fence', unreverse video;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
if MIME then
  begin
     outsymbol(27); outsymbol(83); outsymbol(66)
  end
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(50); outsymbol(52); outsymbol(59);
     outsymbol(48); outsymbol(72); comment position to last line;
     outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(109);
     comment reverse video;
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
  end;
write("   *** This FENCE marks the last page of the file but is NOT a part of it ***  ");
if MIME then
  begin
     outsymbol(27); outsymbol(83); outsymbol(64)
  end
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(48); outsymbol(109);
     comment unreverse video;
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
  end;
COMMENT position cursor at 'end of file';
outsymbol(27); outsymbol(89); outsymbol(45); outsymbol(32);
breakoutput;
getKE: f10call(inch,answer1,answer2,answer3); COMMENT input cursor;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT6;
COMMENT if control-E, good, get out;
if answer1 = 5 then
	goto outCE;
COMMENT if esc P, tell user not to use parameter;
if answer1 = 27 then
  begin
     if answer2 = 80 then
       begin
          outsymbol(27); outsymbol(72);
          write("[8N]You don't need to reenter the parameter        ");
          write("[NN]Please try over                    ");
          write("[NN]");
          breakoutput;
          goto getKE
       end
  end;
COMMENT error message, try again (with the <SEARCH-BACKWARD> command);
if answer1 > 31 then
  begin
     outsymbol(27); outsymbol(72);
     write("[9N]Type the <SEARCH-BACKWARD> command             ");
     write("[N]Please try over                    ");
     write("[NN]");
     breakoutput;
     goto getKE
  end;
COMMENT error message for wrong control-character, try over;
if answer1 < 27 then
  begin
     outsymbol(27); outsymbol(72);
     write("[9N]<SEARCH-BACKWARD> command is control-E                  ");
     write("[N]Please try over                    ");
     write("[NN]");
     breakoutput;
     goto getKE
  end;
outsymbol(27); outsymbol(72);
write("[9N]Give the <SEARCH-BACKWARD> command                         ");
write("[N]Please try over                    ");
write("[NN]");
breakoutput;
goto getKE;
OUTCE: COMMENT write message, position cursor at "snark";
outsymbol(27); outsymbol(72);
write("[8N]"); outsymbol(27); outsymbol(75);
write("[N]Ok. The cursor is now at the last occurrence of the search-key.");
write("[N]Push RETURN to continue            ");
breakoutput; outsymbol(27); outsymbol(89); outsymbol(35); outsymbol(42);
breakoutput; getline; COMMENT get carriage return;
COMMENT update score;
latescore := latescore + 1; if dummy = 1 then score := score + 1;
write("[8N]");
outsymbol(27); outsymbol(62);
goto question6out;
COMMENT go here if control-C or "%";
kcout6: outsymbol(27); outsymbol(72); outsymbol(27);
outsymbol(74);
write("Type BACK to try this question over");
write("[N]     SKIP to go to the next section");
write("[N]     STOP to end this lesson");
write("[N]--->");
breakoutput;
getline;
POS:=1;
if anywhere("STOP") then goto endoflesson;
POS:=1;
if anywhere("BACK") then goto question6;
POS:=1;
if anywhere("SKIP") then goto question6out;
goto KCOUT6
QUESTION6OUT: outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
outsymbol(27); outsymbol(75)
end;
%TEXT outsymbol(12);
Copying or moving lines of text
===============================
     SED has two buffers which hold text from the file: the delete
buffer and the pick buffer. "Deleting" text means removing it from
the file and putting it in the delete buffer; "picking" text means
loading it into the pick buffer without changing the edited file.
The contents of either buffer can be inserted anywhere in the file.

%TEXT
     You have already seen the <DELETE-LINES> command: control-F.
Its parameter is the number of lines to remove. You can put those
lines back in the file by positioning the cursor at the point you
want the lines inserted, and typing:

        <ENTER-PARAMETER><PUT>

where the <PUT> command is control-G.

%text
     To pick up lines of the file, that is, to load the pick buffer
but not affect the file, use the <PICK> command, control-V. As with
<DELETE-LINES>, the parameter is the number of lines to pick. To
insert the lines back in the file, position the cursor and issue
the <PUT> command (without the <ENTER-PARAMETER>).

%text
     Thus, <PUT> is the command which writes out the pick or delete
buffer. <PUT> writes the pick buffer and <ENTER-PARAMETER><PUT>
writes the delete buffer. Use the <PICK> and <PUT> commands
to duplicate lines from your file; use <DELETE-LINES> and
<ENTER-PARAMETER><PUT> to move lines from one place to another.
%ALGOL
begin dummy:=0; qcount:=qcount+1; COMMENT initialize dummy, increment qcount;
question8:
COMMENT clear screen, cursor home;
outsymbol(27); outsymbol(72); outsymbol(27); outsymbol(74);
write("Pretend you are in SED, and this is the text of the file.");
write("[N]In the text below the first two lines are reversed.");
write("[N]The cursor is positioned at the beginning of the first");
write("[N]line. 1) Delete the first line, and ");
write("[N]      2) put it back, after the second line.");
write("[NN]In the midst of his laughter and glee,");
write("[N]In the midst of the words he was trying to say,");
write("[N]He had softly and suddenly vanished away,");
write("[N]For the snark WAS a Boojum, you see.");
breakoutput;
f10call(noecho);
outsymbol(27); outsymbol(61); COMMENT enter alternate keypad mode;
breakoutput;
getenter8: COMMENT position cursor beginning of 6th line;
outsymbol(27); outsymbol(89); outsymbol(38); outsymbol(32);
breakoutput;
dummy := dummy + 1; COMMENT increment dummy;
f10call(inch,answer1,answer2,answer3); COMMENT input char;
COMMENT take care of control-C or "%";
if (answer1 = 3) or (answer1 = 37) then goto KCOUT8;
COMMENT if control-F, great! go take care of that;
if answer1 = 6 then goto OUTCF;
COMMENT handle ESC;
if answer1 = 27 then
  begin
     if answer2 = 80 then
          write("[NNNNNN]You don't need a parameter.                         ")
  end;
COMMENT cursor at 6th line;
outsymbol(27); outsymbol(89); outsymbol(38); outsymbol(32);
COMMENT special message if control-D;
if answer1 = 4 then
  begin
     write("[NNNNNNN]Control-D is <INSERT-LINES>.                          ");
     write("[N]Please try over.                             ");
     goto getenter8
  end;
COMMENT error message if control-character, not F;
if answer1 < 27 then
  begin
     write("[NNNNNNN]<DELETE-LINES> is control-F.                          ");
     write("[N]Please try over.                             ");
     goto getenter8
  end;
COMMENT non-control character error message;
write("[NNNNNNN]Just type the <DELETE-LINES> command.                    ");
write("[N]Please try over.                              ");
goto getenter8;
OUTCF: COMMENT make sure cursor is at 6th line, delete it;
outsymbol(27); outsymbol(89); outsymbol(38); outsymbol(32);
if MIME then
     outsymbol(23);
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(59);
     outsymbol(50); outsymbol(51); outsymbol(114); comment set top and bottom margins;
     outsymbol(27); outsymbol(91); outsymbol(50); outsymbol(51); outsymbol(59);
     outsymbol(48); outsymbol(72); comment position to last line;
     outsymbol(27); outsymbol(69); comment scroll up;
     outsymbol(27); outsymbol(91); outsymbol(49); outsymbol(59);
     outsymbol(50); outsymbol(52); outsymbol(114); comment reset margins;
     outsymbol(27); outsymbol(91); outsymbol(48); outsymbol(109);
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
     outsymbol(27); outsymbol(89); outsymbol(38); outsymbol(32)
  end;
breakoutput;
outcf2:
f10call(inch,answer1,answer2,answer3); COMMENT input char;
COMMENT take care of control-C or "%";
if (answer1 = 3) or (answer1 = 37) then goto KCOUT8;
COMMENT if carriage-return (control-M), get next command;
if answer1 = 13 then
     goto getPUT;
COMMENT if ESC B, get next command;
if answer1 = 27 then
  begin
     if answer2 = 66 then
          goto getPUT
  end;
COMMENT position cursor, type error message;
outsymbol(27); outsymbol(89); outsymbol(38); outsymbol(32);
write("[NNNNN]                                                   ");
write("[N]To position cursor type a <RETURN> or down arrow          ");
write("[N]Please try over, from the beginning");
COMMENT position cursor, insert blank line, replace deleted line, position
cursor again, and start over from the beginning;
outsymbol(27); outsymbol(89); outsymbol(38); outsymbol(32);
if MIME then
     outsymbol(1)
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(59);
     outsymbol(50); outsymbol(51); outsymbol(114); comment set top and bottom margins;
     outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(59);
     outsymbol(49); outsymbol(72); comment position cursor;
     outsymbol(27); outsymbol(77); comment scroll down;
     outsymbol(27); outsymbol(91); outsymbol(49); outsymbol(59);
     outsymbol(50); outsymbol(52); outsymbol(114); comment reset margins;
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
     outsymbol(27); outsymbol(89); outsymbol(38); outsymbol(32)
  end;
breakoutput;
write("In the midst of his laughter and glee");
outsymbol(27); outsymbol(89); outsymbol(38); outsymbol(32);
breakoutput;
goto getenter8;
getput:  COMMENT position cursor 7th line;
outsymbol(27); outsymbol(89); outsymbol(39); outsymbol(32);
breakoutput;
f10call(inch,answer1,answer2,answer3); COMMENT input char;
COMMENT take care of control-C or "%";
if (answer1 = 3) or (answer1 = 37) then goto KCOUT8;
COMMENT if ESC P, go get a control-G;
if answer1 = 27 then
  begin
     if answer2 = 80 then
          goto getCG
  end;
COMMENT error message, replace deleted line (as above), start over;
write("[NNNN]                                                     ");
write("[N]To replace deleted lines, type <ENTER-PARAMETER><PUT>");
write("[N]Please try over, from the beginning.");
outsymbol(27); outsymbol(89); outsymbol(38); outsymbol(32);
if MIME then
     outsymbol(1)
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(59);
     outsymbol(50); outsymbol(51); outsymbol(114); comment set top and bottom margins;
     outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(59);
     outsymbol(49); outsymbol(72); comment position cursor;
     outsymbol(27); outsymbol(77); comment scroll down;
     outsymbol(27); outsymbol(91); outsymbol(49); outsymbol(59);
     outsymbol(50); outsymbol(52); outsymbol(114); comment reset margins;
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
     outsymbol(27); outsymbol(89); outsymbol(38); outsymbol(32)
  end;
breakoutput;
write("In the midst of his laughter and glee");
outsymbol(27); outsymbol(89); outsymbol(38); outsymbol(32);
breakoutput;
goto getenter8;
getCG: COMMENT position cursor bottom left, reverse video, parameter
prompt, unreverse video;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
if MIME then
  begin
     outsymbol(27); outsymbol(83); outsymbol(66)
  end
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(50); outsymbol(52); outsymbol(59);
     outsymbol(48); outsymbol(72); comment position to last line;
     outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(109);
     comment reverse video;
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
  end;
write(">");
if MIME then
  begin
     outsymbol(27); outsymbol(83); outsymbol(64)
  end
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(48); outsymbol(109);
     comment unreverse video;
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
  end;
breakoutput;
f10call(inch,answer1,answer2,answer3); COMMENT input char;
COMMENT handle control-C or "%";
if (answer1 = 3) or (answer1 = 37) then goto KCOUT8;
COMMENT if control-G, get out;
if answer1 = 7 then
	goto outCG;
COMMENT error message if control-V instead of control-G, (same deal as above);
if answer1 = 22 then
  begin
     outsymbol(27); outsymbol(89); outsymbol(39); outsymbol(32);
     write("[NNNN]                                                        ");
     write("[N]Control-V is <PICK>.                                      ");
     write("[N]Please try over, from the beginning.         ");
     outsymbol(27); outsymbol(89); outsymbol(38); outsymbol(32);
     if MIME then
          outsymbol(1)
     else
       begin
          outsymbol(27); outsymbol(60); comment go into vt100 mode;
          outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(59);
          outsymbol(50); outsymbol(51); outsymbol(114); comment set top and bottom margins;
          outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(59);
          outsymbol(49); outsymbol(72); comment position cursor;
          outsymbol(27); outsymbol(77); comment scroll down;
          outsymbol(27); outsymbol(91); outsymbol(49); outsymbol(59);
          outsymbol(50); outsymbol(52); outsymbol(114); comment reset margins;
          outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
          outsymbol(108); comment return to vt52 mode;
          outsymbol(27); outsymbol(89); outsymbol(38); outsymbol(32)
       end;
     breakoutput;
     write("In the midst of his laughter and glee");
     outsymbol(27); outsymbol(89); outsymbol(38); outsymbol(32);
     breakoutput;
     goto getenter8
  end;
COMMENT error message for other control character, (same deal as above);
if answer1 < 27 then
  begin
     outsymbol(27); outsymbol(89); outsymbol(39); outsymbol(32);
     write("[NNNN]                                                        ");
     write("[N]<PUT> command is control-G                             ");
     write("[N]Please try over, from the beginning"); breakoutput;
     outsymbol(27); outsymbol(89); outsymbol(38); outsymbol(32);
     if MIME then
          outsymbol(1)
     else
       begin
          outsymbol(27); outsymbol(60); comment go into vt100 mode;
          outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(59);
          outsymbol(50); outsymbol(51); outsymbol(114); comment set top and bottom margins;
          outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(59);
          outsymbol(49); outsymbol(72); comment position cursor;
          outsymbol(27); outsymbol(77); comment scroll down;
          outsymbol(27); outsymbol(91); outsymbol(49); outsymbol(59);
          outsymbol(50); outsymbol(52); outsymbol(114); comment reset margins;
          outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
          outsymbol(108); comment return to vt52 mode;
          outsymbol(27); outsymbol(89); outsymbol(38); outsymbol(32)
       end;
     breakoutput;
     write("In the midst of his laughter and glee");
     outsymbol(27); outsymbol(89); outsymbol(38); outsymbol(32);
     breakoutput;
     goto getenter8
  end;
COMMENT error message for non control character (same deal as above);
outsymbol(27); outsymbol(89); outsymbol(39); outsymbol(32);
write("[NNNN]                                                        ");
write("[N]You don't need a parameter.                            ");
write("[N]Please try over from the beginning"); breakoutput;
outsymbol(27); outsymbol(89); outsymbol(38); outsymbol(32);
if MIME then
     outsymbol(1)
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(59);
     outsymbol(50); outsymbol(51); outsymbol(114); comment set top and bottom margins;
     outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(59);
     outsymbol(49); outsymbol(72); comment position cursor;
     outsymbol(27); outsymbol(77); comment scroll down;
     outsymbol(27); outsymbol(91); outsymbol(49); outsymbol(59);
     outsymbol(50); outsymbol(52); outsymbol(114); comment reset margins;
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
     outsymbol(27); outsymbol(89); outsymbol(38); outsymbol(32)
  end;
breakoutput;
write("In the midst of his laughter and glee");
outsymbol(27); outsymbol(89); outsymbol(38); outsymbol(32);
breakoutput;
goto getenter8;
OUTCG: COMMENT bottom line blanked out;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
write("                           ");
COMMENT position cursor 7th line;
outsymbol(27); outsymbol(89); outsymbol(39); outsymbol(32);
COMMENT insert blank line;
if MIME then
     outsymbol(1)
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(56); outsymbol(59);
     outsymbol(50); outsymbol(51); outsymbol(114); comment set top and bottom margins;
     outsymbol(27); outsymbol(91); outsymbol(56); outsymbol(59);
     outsymbol(49); outsymbol(72); comment position cursor;
     outsymbol(27); outsymbol(77); comment scroll down;
     outsymbol(27); outsymbol(91); outsymbol(49); outsymbol(59);
     outsymbol(50); outsymbol(52); outsymbol(114); comment reset margins;
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
     outsymbol(27); outsymbol(89); outsymbol(39); outsymbol(32)
  end;
breakoutput;
COMMENT rewrite deleted line in proper place, get a return, and that's it;
write("In the midst of his laughter and glee,");
write("[NNNNN]                                                          ");
write("[N]                                                              ");
write("[N]Please push return to continue               [N]");
breakoutput; getline;
COMMENT clear screen, cursor home;
outsymbol(27); outsymbol(72); outsymbol(27); outsymbol(74);
write("That was just fine! Keep up the good work.");
breakoutput;
pause;
COMMENT update scores;
latescore := latescore + 1; if dummy = 4 then score := score + 1;
goto question8out;
COMMENT go here if control-C or "%";
KCOUT8: outsymbol(27); outsymbol(72); outsymbol(27);
outsymbol(74);
write("Type BACK to try this question over");
write("[N]     SKIP to go to the next section");
write("[N]     STOP to end this lesson");
write("[N]--->");
breakoutput;
getline;
POS:=1;
if anywhere("STOP") then goto endoflesson;
POS:=1;
if anywhere("BACK") then goto question8;
POS:=1;
if anywhere("SKIP") then goto question8out;
goto KCOUT8
END;

%TEXT QUESTION8OUT: outsymbol(27); outsymbol(62); outsymbol(12);
Inserting text in the file using <PUT>
======================================
     You already know how to insert text by using <INSERT-MODE>
(numeric keypad ENTER) or by opening up a hole using <INSERT-SPACES>
(control-B) and then typing over the hole. However, the easiest way
to insert text is to use the <PUT> command. Type

        <ENTER-PARAMETER><string><PUT>

where <string> is whatever you want to insert and <PUT> is control-G.
This has the same effect as opening spaces and typing over them. The
string is inserted where the cursor is.
%TEXT
     Furthermore, the editor remembers the string, so if you want to
put it somewhere else you can move there and type <PUT> and the same
string will be inserted at the new location.
%ALGOL
begin dummy:=0; qcount:=qcount+1; COMMENT initialize dummy, increment qcount;
question9:
COMMENT clear screen, cursor home;
outsymbol(27); outsymbol(72); outsymbol(27); outsymbol(74);
write("Pretend you are in SED, and this is the text of the file.");
write("[N]In the sentence below, the cursor is before the word ""brown"".");
write("[N]Using the <PUT> command, insert the word ""quick"" ");
write("[N](don't forget a space to separate it from ""brown"").");
write("[NN]The brown fox jumped over the lazy dog.");
breakoutput;
f10call(noecho);
outsymbol(27); outsymbol(61); COMMENT enter alternate keypad mode;
breakoutput;
getenter9: COMMENT blank out bottom line;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
outsymbol(27); outsymbol(75);
COMMENT position cursor at "brown";
outsymbol(27); outsymbol(89); outsymbol(37); outsymbol(36);
breakoutput;
dummy := dummy + 1; COMMENT increment dummy;
f10call(inch,answer1,answer2,answer3); COMMENT input char;
COMMENT handle control-C or "%";
if (answer1 = 3) or (answer1 = 37) then goto KCOUT9;
COMMENT if ESC P, get parameter;
if answer1 = 27 then
  begin
     if answer2 = 80 then
          goto getq
  end;
if MIME then
     write("[4N]No! The <ENTER-PARAMETER> command is the BLUE key")
else
     write("[4N]No! The <ENTER-PARAMETER> command is the PF1 key");
write("[N]Please try over.                    ");
goto getenter9;
getq: COMMENT give parameter prompt (as usual);
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
if MIME then
  begin
     outsymbol(27); outsymbol(83); outsymbol(66)
  end
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(50); outsymbol(52); outsymbol(59);
     outsymbol(48); outsymbol(72); comment position to last line;
     outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(109);
     comment reverse video;
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
  end;
write(">");
if MIME then
  begin
     outsymbol(27); outsymbol(83); outsymbol(64)
  end
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(48); outsymbol(109);
     comment unreverse video;
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
  end;
breakoutput;
f10call(inch,answer1,answer2,answer3); COMMENT input char;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT9;
COMMENT if "q" go get a "u";
if answer1 = 113 then
  begin
     outsymbol(answer1);
     breakoutput;
     goto getu
  end;
COMMENT if printable, print;
if answer1 > 31 then
     outsymbol(answer1);
outsymbol(27); outsymbol(72);
COMMENT if "Q" ask for lower-case, otherwise reg. error message;
if answer1 = 81 then
     write("[9N]Please use lower-case                                 ")
  else
     write("[9N]The word you are inserting is ""quick"".              ");
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter9;
getu: f10call(inch,answer1,answer2,answer3); COMMENT input char;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT9;
COMMENT if "u" go get an "i";
if answer1 = 117 then
  begin
     outsymbol(answer1);
     breakoutput;
     goto geti
  end;
COMMENT handle wrong answer;
if answer1 > 31 then
     outsymbol(answer1);
outsymbol(27); outsymbol(72);
if answer1 = 85 then
     write("[9N]Please use lower-case                                 ")
  else
     write("[9N]The word you are inserting is ""quick"".              ");
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter9;
geti: f10call(inch,answer1,answer2,answer3); COMMENT input char;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT9;
COMMENT if "i" go get a "c";
if answer1 = 105 then
  begin
     outsymbol(answer1);
     breakoutput;
     goto getc
  end;
COMMENT handle wrong answer;
if answer1 > 31 then
     outsymbol(answer1);
outsymbol(27); outsymbol(72);
if answer1 = 73 then
     write("[9N]Please use lower-case                                 ")
  else
     write("[9N]The word you are inserting is ""quick"".              ");
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter9;
getc: f10call(inch,answer1,answer2,answer3); COMMENT input char;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT9;
COMMENT if "c" go get a "k";
if answer1 = 99 then
  begin
     outsymbol(answer1);
     breakoutput;
     goto getk2
  end;
COMMENT handle wrong answer;
if answer1 > 31 then
     outsymbol(answer1);
outsymbol(27); outsymbol(72);
if answer1 = 67 then
     write("[9N]Please use lower-case                                 ")
  else
     write("[9N]The word you are inserting is ""quick"".              ");
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter9;
getk2: f10call(inch,answer1,answer2,answer3); COMMENT input char;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT9;
COMMENT if "k" go get a space;
if answer1 = 107 then
  begin
     outsymbol(answer1);
     breakoutput;
     goto getspace
  end;
COMMENT handle wrong answer
if answer1 > 31 then
     outsymbol(answer1);
outsymbol(27); outsymbol(72);
if answer1 = 75 then
     write("[9N]Please use lower-case                                 ")
  else
     write("[9N]The word you are inserting is ""quick"".              ");
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter9;
getspace: f10call(inch,answer1,answer2,answer3); COMMENT input char;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT9;
COMMENT if space, go get command;
if answer1 = 32 then
  begin
     outsymbol(answer1);
     breakoutput;
     goto getcommand9
  end;
COMMENT handle wrong answer;
if answer1 > 31 then
     outsymbol(answer1);
outsymbol(27); outsymbol(72);
write("[9N]Insert a space after ""quick"".                       ");
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter9;
getcommand9: f10call(inch,answer1,answer2,answer3); COMMENT input char;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT9;
COMMENT if control-G get out;
if answer1 = 7 then
	goto outCG2;
COMMENT handle wrong answers;
if answer1 = 22 then
  begin
     outsymbol(27); outsymbol(72);
     write("[9N]Control-V is <PICK>.                                 ");
     write("[N]Please try over, from the beginning");
     goto getenter9
  end;
if answer1 < 27 then
  begin
     outsymbol(27); outsymbol(72);
     write("[9N]<PUT> command is control-G.                            ");
     write("[N]Please try over, from the beginning"); breakoutput;
     goto getenter9
  end;
if answer1 > 31 then
     outsymbol(answer1);
outsymbol(27); outsymbol(72);
write("[9N]Give the <PUT> command after you give the parameter              ");
write("[N]Please try over, from the beginning"); breakoutput;
goto getenter9;
OUTCG2: COMMENT blank out parameter;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
write("                           ");
COMMENT position cursor at "brown" and insert "quick ";
outsymbol(27); outsymbol(89); outsymbol(37); outsymbol(36);
outsymbol(27); outsymbol(75);
write("quick brown fox jumped over the lazy dog");breakoutput;
write("[4N]Good! You got it!                                           ");
write("[N]Push RETURN to continue               [N]");
outsymbol(27); outsymbol(89); outsymbol(37); outsymbol(36);
COMMENT get a carriage return;
breakoutput; getline; write("[6N]");
COMMENT update scores;
latescore := latescore + 1; if dummy = 1 then score := score + 1;
goto question9out;
COMMENT go here if control-C or "%";
KCOUT9: outsymbol(27); outsymbol(72); outsymbol(27);
outsymbol(74);
write("Type BACK to try this question over");
write("[N]     SKIP to go to the next section");
write("[N]     STOP to end this lesson");
write("[N]--->");
breakoutput;
getline;
POS:=1;
if anywhere("STOP") then goto endoflesson;
POS:=1;
if anywhere("BACK") then goto question9;
POS:=1;
if anywhere("SKIP") then goto question9out;
goto KCOUT9
END;

%TEXT question9out: outsymbol(12); outsymbol(27); outsymbol(62);
REVIEW
======
     Before ending this lesson, let's have a quick review
test of the commands you've learned so far.

     For the following questions, give the number of the
answer which you think is correct.
%QUESTION
The <PERCENT-GOTO> command is:
        1)Control-P
        2)Control-G
        3)Control-T
        4)Control-V
%RIGHT 1
%RIGHT 1)
%WRONG 2
Control-G is the <PUT> command.
%WRONG 3
Control-T if the <ROLL-FORWARD-LINES> command.
%WRONG 4
Control-V is the <PICK> command.
%WRONG
Answer 1, 2, 3, or 4.
%WRONG
%SAME
%QUESTION
The <PERCENT-GOTO> command is control-P.
To get to the beginning of the file you should type:
        1) <PERCENT-GOTO>
        2) <ENTER-PARAMETER><PERCENT-GOTO>
        3) <ENTER-PARAMETER>0<PERCENT-GOTO>
        4) <ENTER-PARAMETER>100<PERCENT-GOTO>
%RIGHT 3
%RIGHT 3)
%WRONG 1
Typing just <PERCENT-GOTO> will get you to the same
percent of the way through the file as the LAST time
a <PERCENT-GOTO> command was given in the current editing
session. If that happens to be 0, or if this is the first
<PECENT-GOTO> issued, then you will get to the beginning
of the file. This is not always the case, however.
%WRONG 2
<ENTER-PARAMETER><PERCENT-GOTO> will get you to the
END of the file, not the beginning.
%WRONG 4
<ENTER-PARAMETER>100<PERCENT-GOTO> will get you to the
END of the file, not the beginning.
%WRONG
Answer 1, 2, 3, or 4.
%WRONG
%SAME
%QUESTION
The two <SEARCH> commands are:
        1) Control-F for <SEARCH-FORWARD>, control-B for <SEARCH-BACKWARD>
        2) Control-R for <SEARCH-FORWARD>, control-E for <SEARCH-BACKWARD>
        3) Control-R for <SEARCH-FORWARD>, control-B for <SEARCH-BACKWARD>
        4) Control-F for <SEARCH-FORWARD>, control-E for <SEARCH-BACKWARD>
%RIGHT 2
%RIGHT 2)
%WRONG 1
Control-F is <DELETE-LINES> and control-B is <INSERT-SPACES>
%WRONG 3
Control-R is <SEARCH-FORWARD> but control-B is <INSERT-SPACES>
%WRONG 4
Control-E is <SEARCH-BACKWARD> but control-F is <DELETE-LINES>
%WRONG
Answer 1, 2, 3, or 4.
%WRONG
%SAME
%QUESTION
If you have already searched forward for a certain text
string, and now you want to search backward for it:
        1)You must re-enter the text string as a parameter
        2)You must NOT re-enter the text string as a parameter
        3)You can re-enter the text string but it is not necessary
%RIGHT 3
%RIGHT 3)
%WRONG 1
<SEARCH-FORWARD> and <SEARCH-BACKWARD> share a parameter, therefore
there is no need to  re-enter the text-string.
%WRONG 2
Since the <SEARCH-BACKWARD> and <SEARCH-FORWARD> share a parameter,
re-entering the text string is a waste of time for you, but will
not do any harm.
%WRONG
Answer 1, 2, or 3.
%WRONG
%SAME
%QUESTION
The <PICK> command, to load lines into the pick buffer
without changing the file, is:
        1) Control-V
        2) Control-G
        3) Control-F
        4) Control-P
%RIGHT 1
%RIGHT 1)
%WRONG 2
Control-G is the <PUT> command, which puts the contents
of the buffer into the file.
%WRONG 3
Control-F is the <DELETE-LINES> command which, although
it does load the lines into a buffer, deletes lines
from the file.
%WRONG 4
Control-P is the <PERCENT-GOTO> command.
%WRONG
Answer 1, 2, 3, or 4.
%WRONG
%SAME
%TEXT
That is enough for this lesson.
Initially, you will probably have trouble remembering
all the different commands, so you should type or
print out a copy of the SED.HLP file, which has a list
of all the SED commands.

To type SED.HLP (on a hard-copy terminal, preferably), type:

        HELP SED

when you are at monitor (when you get the "." prompt).

To print it out, type:

        PRINT HLP:SED.HLP

when you are at monitor.

%END