Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-11 - 43,50537/sed04.gno
There are no other files named sed04.gno in the archive.
%NOCONTROLC
%VARIABLES INTEGER ANSWER1, ANSWER2, ANSWER3, DUMMY, downct, rightct;
%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.
%TEXT
     You should run this lesson only if you have used the material
covered in the first three lessons enough to be comfortable with
it. If you try running this lesson directly after taking the previous
lessons, without a chance to practice what you have learned, chances
are you will get confused and not learn much.

%TEXT outsymbol(12);
Purpose of this Lesson
======================
     This lesson will teach you
	-new ways of using parameters,
	-how to edit two files at a time,
	-how to copy and delete large blocks of text
	 (bigger than one page),
	-how to get help and status information from SED, and
	-how to set switches to invoke options at monitor level,
	 during editing, and in a SWITCH.INI file.

%TEXT outsymbol(12);
Defining the parameter by moving the cursor
===========================================
     You don't need to know how to count in order to issue editor
commands. Instead of typing, say, <ENTER-PARAMETER>7<DELETE-SPACES>,
you could type <ENTER-PARAMETER> and then move the cursor over the
characters you want to delete (using <TAB> or <CURSOR-RIGHT>
(right arrow)). Then type <DELETE-SPACES>, and the text between
where the cursor started and where it ended will be deleted. This
method of passing a parameter is called "cursor movement." It is
often a lot easier to use than counting.
%TEXT
     When you initiate cursor movement the editor will type "Parm
defined by cursor movement" in reverse video at the bottom of the
screen, as a reminder.
%TEXT
     Cursor movement works across a span of lines, too, and often
can cover a change of both lines and spaces. For example, if you
wanted to delete a whole line, and part of the line after it, you
would position the cursor at the beginning of the first line you
want to delete, type <ENTER-PARAMETER>, then position the cursor
at the point in the next line where you want to stop deleting, then
type <DELETE-LINES>.
%TEXT
     Any key that moves the cursor can be used for a cursor
movement parameter (remember that the space bar is not a cursor
mover, it INSERTS a space). SED looks only at where the cursor
starts and where it ends up; it doesn't matter what the cursor
passes over on the way. So the quickest way of getting the cursor
where you want it is the best way.
%QUESTION doyouknow:
Do you remember what the <DELETE-SPACES> command is?
%NEUTRAL NO
<DELETE-SPACES> is control-N.

%GOTO prequestion1;
%NEUTRAL N
%SAME
%NEUTRAL no
%SAME
%NEUTRAL n
%SAME
%NEUTRAL YES
%GOTO whatsdeletespace;
%NEUTRAL Y
%SAME
%NEUTRAL yes
%SAME
%NEUTRAL y
%SAME
%NEUTRAL
Please answer yes or no.
%GOTO doyouknow;
%QUESTION whatsdeletespace:
O.K. What is it? (don't give the command, just give its description,
e.g. control-C, etc).
%RIGHT CONTROL-N
%RIGHT control-N
%RIGHT control-n
%RIGHT CTRL-N
%RIGHT ctrl-N
%RIGHT ctrl-n
%WRONG
<DELETE-SPACES> is control-N.
%GOTO prequestion1;
%TEXT prequestion1:
     In the next question, please give the computer time to work
between each keystroke.
%ALGOL
begin dummy:=0; qcount:=qcount+1; COMMENT initialize dummy, increment qcount;
question1:
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 ""quick"".");
write("[N]Using cursor movement, delete the word ""quick"" ");
write("[N](don't forget the space separating it from ""brown"").");
write("[NN]The quick brown fox jumped over the lazy dog.");
f10call(noecho);
outsymbol(27); outsymbol(61); COMMENT enter alternate keypad mode;
getenter1: COMMENT blank out bottom line;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
outsymbol(27); outsymbol(75);
COMMENT position cursor at "quick";
outsymbol(27); outsymbol(89); outsymbol(37); outsymbol(36);
COMMENT make sure "q" is unmarked;
write("q"); outsymbol(8);
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 KCOUT1;
COMMENT if ESC P, get parameter;
if answer1 = 27 then
  begin
     if answer2 = 80 then
          goto getcr1
  end;
write("[4N]"); 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]"); outsymbol(27); outsymbol(75);
write("Please try over.");
goto getenter1;
getcr1: COMMENT mark char where cursor is (reverse video, low intensity);
if MIME then
  begin
     outsymbol(27); outsymbol(83); outsymbol(74); write("q"); breakoutput;
     outsymbol(27); outsymbol(83); outsymbol(64); breakoutput; COMMENT unreverse video;
  end
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(109);
     comment reverse video; write("q"); comment unreverse video;
     outsymbol(27); outsymbol(91); outsymbol(48); outsymbol(109);
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
  end;
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 KCOUT1;
COMMENT if ESC C get next input;
if answer1 = 27 then
  begin
     if answer2 = 67 then
          goto getcr2;   COMMENT get 2nd <CURSOR-RIGHT>;
  end;
COMMENT if printable, print;
if answer1 > 31 then
     outsymbol(answer1);
outsymbol(27); outsymbol(72);
COMMENT if " " give space error mess. otherwise reg. error message;
write("[9N]"); outsymbol(27); outsymbol(75);
if answer1 = 32 then
     write("The space bar inserts a space.")
  else
     write("Give the <CURSOR-RIGHT> (right arrow) command.");
write("[N]"); outsymbol(27); outsymbol(75);
write("Please try over, from the beginning");
breakoutput;
goto getenter1;
getcr2:
if MIME then
  begin
     outsymbol(27); outsymbol(83); outsymbol(66); COMMENT reverse video;
  end
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     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(" *** Parm. defined by cursor movement ***");
if MIME then
  begin
     COMMENT unreverse video;
     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 "u";
outsymbol(27); outsymbol(89); outsymbol(37); outsymbol(37);
breakoutput;
f10call(inch,answer1,answer2,answer3); COMMENT input char;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT1;
COMMENT if ESC C, get next input;
if answer1 = 27 then
  begin
     if answer2 = 67 then
          goto getcr3;   COMMENT get 3rd <CURSOR-RIGHT>;
  end;
outsymbol(27); outsymbol(72);
COMMENT if " " give space error mess. otherwise reg. error message;
write("[9N]"); outsymbol(27); outsymbol(75);
if answer1 = 32 then
     write("The space bar inserts a space.")
  else
     write("Give the <CURSOR-RIGHT> (right arrow) command.");
write("[N]"); outsymbol(27); outsymbol(75);
write("Please try over, from the beginning");
breakoutput;
goto getenter1;
getcr3: outsymbol(27); outsymbol(67); COMMENT move cursor right;
breakoutput;
f10call(inch,answer1,answer2,answer3); COMMENT input char;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT1;
COMMENT if ESC C, get next input;
if answer1 = 27 then
  begin
     if answer2 = 67 then
          goto getcr4;   COMMENT get 4th <CURSOR-RIGHT>;
  end;
outsymbol(27); outsymbol(72);
COMMENT if " " give space error mess. otherwise reg. error message;
write("[9N]"); outsymbol(27); outsymbol(75);
if answer1 = 32 then
     write("The space bar inserts a space.")
  else
     write("Give the <CURSOR-RIGHT> (right arrow) command.");
write("[N]"); outsymbol(27); outsymbol(75);
write("Please try over, from the beginning");
breakoutput;
goto getenter1;
getcr4: outsymbol(27); outsymbol(67); COMMENT move cursor right;
breakoutput;
f10call(inch,answer1,answer2,answer3); COMMENT input char;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT1;
COMMENT if ESC C, get next input;
if answer1 = 27 then
  begin
     if answer2 = 67 then
          goto getcr5;   COMMENT get 5th <CURSOR-RIGHT>;
  end;
outsymbol(27); outsymbol(72);
COMMENT if " " give space error mess. otherwise reg. error message;
write("[9N]"); outsymbol(27); outsymbol(75);
if answer1 = 32 then
     write("The space bar inserts a space.")
  else
     write("Give the <CURSOR-RIGHT> (right arrow) command.");
write("[N]"); outsymbol(27); outsymbol(75);
write("Please try over, from the beginning");
breakoutput;
goto getenter1;
getcr5: outsymbol(27); outsymbol(67); COMMENT move cursor right;
breakoutput;
f10call(inch,answer1,answer2,answer3); COMMENT input char;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT1;
COMMENT if ESC C, get next input;
if answer1 = 27 then
  begin
     if answer2 = 67 then
          goto getcr6;   COMMENT get 6th <CURSOR-RIGHT>;
  end;
outsymbol(27); outsymbol(72);
COMMENT if " " give space error mess. otherwise reg. error message;
write("[9N]"); outsymbol(27); outsymbol(75);
if answer1 = 32 then
     write("The space bar inserts a space.")
  else
     write("Give the <CURSOR-RIGHT> (right arrow) command.");
write("[N]"); outsymbol(27); outsymbol(75);
write("Please try over, from the beginning");
breakoutput;
goto getenter1;
getcr6: outsymbol(27); outsymbol(67); COMMENT move cursor right;
breakoutput;
f10call(inch,answer1,answer2,answer3); COMMENT input char;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT1;
COMMENT if ESC C, get next input;
if answer1 = 27 then
  begin
     if answer2 = 67 then
          goto getcommand1; COMMENT get <DELETE-SPACES>;
  end;
outsymbol(27); outsymbol(72);
COMMENT if " " give space error mess. otherwise reg. error message;
write("[9N]"); outsymbol(27); outsymbol(75);
if answer1 = 32 then
     write("The space bar inserts a space.")
  else
     write("Give the <CURSOR-RIGHT> (right arrow) command.");
write("[N]"); outsymbol(27); outsymbol(75);
write("Please try over, from the beginning");
breakoutput;
goto getenter1;
getcommand1: outsymbol(27); outsymbol(67); COMMENT move cursor right;
breakoutput;
f10call(inch,answer1,answer2,answer3); COMMENT input char;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT1;
COMMENT if control-N get out;
if answer1 = 14 then
	goto outCN;
COMMENT handle wrong answers;
outsymbol(27); outsymbol(72);
write("[9N]"); outsymbol(27); outsymbol(75);
if answer1 = 2 then
  begin
     write("Control-B is <INSERT-SPACES>.                        ");
     write("[N]Please try over, from the beginning");
     goto getenter1
  end;
if answer1 < 27 then
  begin
     write("<DELETE-SPACES> command is control-N.                            ");
     write("[N]Please try over, from the beginning"); breakoutput;
     goto getenter1
  end;
write("Give the <DELETE-SPACES> command after you give the parameter              ");
write("[N]Please try over, from the beginning"); breakoutput;
goto getenter1;
OUTCN: COMMENT blank out bottom line;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
outsymbol(27); outsymbol(75);
COMMENT position cursor at "quick" and delete "quick ";
breakoutput;
outsymbol(27); outsymbol(89); outsymbol(37); outsymbol(36);
outsymbol(27); outsymbol(75);
write("brown fox jumped over the lazy dog");
write("[4N]"); outsymbol(27); outsymbol(75);
write("Good! You got it!");
write("[N]"); outsymbol(27); outsymbol(75);
write("Push RETURN to continue");
outsymbol(27); outsymbol(89); outsymbol(37); outsymbol(36);
COMMENT get a carriage return;
breakoutput; getline; write("[5N]");
COMMENT update scores;
latescore := latescore + 1; if dummy = 1 then score := score + 1;
goto question1out;
COMMENT go here if control-C or "%";
KCOUT1: outsymbol(27); outsymbol(72); outsymbol(27);
outsymbol(74); outsymbol(27); outsymbol(72); breakoutput;
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 question1;
POS:=1;
if anywhere("SKIP") then goto question1out;
goto KCOUT1
END;

%TEXT question1out: outsymbol(12); outsymbol(27); outsymbol(62);
     There are many commands with which you can use parameters
defined by cursor movement.

     <DELETE-SPACES> will delete all the text in the "rectangle"
defined by the beginning and the end of the cursor movement.
That is, the intersection of lines and columns between the two
cursor movement "end points" will be deleted.
For example, in the lines below, if we start cursor movement
parameter definition at the first "*" (top left), and we end
it after the last "*" (bottom right, on the next "t"),
all that will be deleted is the "*"'s.

before:
      text text text **************text text text text
      text text text **************text text text text
      text text text **************text text text text

after:
      text text text text text text text
      text text text text text text text
      text text text text text text text

     <INSERT-SPACES> will insert spaces inside a rectangle defined
as for the <DELETE-SPACES> command above. (The text to the right
of the first endpoint column will be shoved to the right of the last
endpoint column).
%TEXT
     <DELETE-LINES> will delete all the lines between the two
endpoints, and store them in the delete buffer.
For example, if we begin cursor movement at the first "*", and
end it after the last "*" in the example below, all the "*"'s
will be deleted and stored in the delete buffer.

before:
      text text text ******************************
      *********************************************
      ****************************text text text

after:
      text text text text text text

%TEXT
     <INSERT-LINES> will insert blank lines filling up the
space between the endpoints, starting at the first endpoint.
(The text after the first endpoint will be shoved over to
where the second endpoint is, and the space in between will
be blanked out).

%TEXT
     <PICK> command will put all the lines between the
two endpoints into the put buffer.
     <PUT> command will put all the lines between the
two endpoints into the put buffer, and into the file
where the first endpoint is (thus the file will have
two copies of this set of lines, one after the other).

%TEXT
    <SEARCH-FORWARD> or <SEARCH-BACKWARD> will search
for the next or previous occurrence of the text-string
between the two end-points (note that you cannot define
a search key over several lines!).

%TEXT
     That covers cursor movement for the commands you have
learned so far. In general, cursor movement works wherever
you would expect it to. Practice this kind of parameter use
on a test file, to get a hang of it. Don't experiment on an
important file, as you may lose part of it by doing the wrong
things.
%ALGOL
begin dummy:=0; qcount:=qcount+1; COMMENT initialize dummy, increment qcount;
question2:
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 cursor is before the first ""*"".");
write("[N]Using cursor movement, delete all the ""*""'s. ");
write("[NNN]text*** text text text text");
write("[N]text*** text text text text");
write("[N]text*** text text text text");
breakoutput;
f10call(noecho);
outsymbol(27); outsymbol(61); COMMENT enter alternate keypad mode;
breakoutput;
getenter2: COMMENT blank out bottom line;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
outsymbol(27); outsymbol(75);
COMMENT position cursor at "***";
outsymbol(27); outsymbol(89); outsymbol(37); outsymbol(36);
COMMENT make sure "*" is unmarked;
write("*"); outsymbol(8);
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 KCOUT2;
COMMENT if ESC P, get parameter;
if answer1 = 27 then
  begin
     if answer2 = 80 then
          goto getcm1
  end;
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]"); outsymbol(27); outsymbol(75);
write("Please try over.                    ");
goto getenter2;
getcm1: COMMENT mark char where cursor is (reverse video, low intensity);
if MIME then
  begin
     outsymbol(27); outsymbol(83); outsymbol(74); write("*");
     outsymbol(27); outsymbol(83); outsymbol(64); COMMENT unreverse video;
  end
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(109);
     comment reverse video; write("*"); comment unreverse video;
     outsymbol(27); outsymbol(91); outsymbol(48); outsymbol(109);
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
  end;
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;
COMMENT initialize rightct and downct (counters for number of right and down
cursor movements);
rightct := 0; downct := 0;
breakoutput;
f10call(inch,answer1,answer2,answer3); COMMENT input char;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT1;
COMMENT if ESC C or ESC B, get next input;
if answer1 = 27 then
  begin
     if (answer2 = 66) or (answer2 = 67) then
       begin
          if MIME then
            begin
               outsymbol(27); outsymbol(83); outsymbol(66); COMMENT reverse video;
            end
          else
            begin
               outsymbol(27); outsymbol(60); comment go into vt100 mode;
               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(" *** Parm. defined by cursor movement ***");
          if MIME then
            begin
               COMMENT unreverse video;
               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 "*";
          outsymbol(27); outsymbol(89); outsymbol(37); outsymbol(36)
       end;
     if answer2 = 67 then
       begin
          rightct := rightct + 1; COMMENT if ESC C, increment rightct;
          outsymbol(27); outsymbol(67); COMMENT move cursor right;
          breakoutput;
          goto getcm2;   COMMENT get 2nd cursor movement;
       end;
     if answer2 = 66 then
       begin
          downct := downct + 1; COMMENT if ESC B, increment downct;
          outsymbol(27); outsymbol(66); COMMENT move cursor down;
          breakoutput;
          goto getcm2;   COMMENT get 2nd cursor movement;
       end;
  end;
COMMENT if printable, print;
if answer1 > 31 then
     outsymbol(answer1);
outsymbol(27); outsymbol(72);
COMMENT if " " give space error mess. otherwise reg. error message;
write("[11N]"); outsymbol(27); outsymbol(75);
if answer1 = 32 then
     write("The space bar inserts a space.")
  else
     write("Use the right arrow or the down arrow.");
write("[N]"); outsymbol(27); outsymbol(75);
write("Please try over, from the beginning");
breakoutput;
goto getenter2;
getcm2: f10call(inch,answer1,answer2,answer3); COMMENT input char;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT2;
COMMENT if ESC C or ESC B, get next input;
if answer1 = 27 then
  begin
     if answer2 = 67 then
       begin
          rightct := rightct + 1; COMMENT if ESC C, increment rightct;
          outsymbol(27); outsymbol(67); COMMENT move cursor right;
          breakoutput;
          goto getcm3;   COMMENT get 3rd cursor movement;
       end;
     if answer2 = 66 then
       begin
          downct := downct + 1; COMMENT if ESC B, increment downct;
          outsymbol(27); outsymbol(66); COMMENT move cursor down;
          breakoutput;
          goto getcm3;   COMMENT get 3rd cursor movement;
       end;
  end;
outsymbol(27); outsymbol(72);
COMMENT if " " give space error mess. otherwise reg. error message;
write("[11N]"); outsymbol(27); outsymbol(75);
if answer1 = 32 then
     write("The space bar inserts a space.")
  else
     write("Use the right arrow or the down arrow.");
write("[N]"); outsymbol(27); outsymbol(75);
write("Please try over, from the beginning");
breakoutput;
goto getenter2;
getcm3: f10call(inch,answer1,answer2,answer3); COMMENT input char;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT2;
COMMENT if ESC C or ESC B, get next input;
if answer1 = 27 then
  begin
     if answer2 = 67 then
       begin
          rightct := rightct + 1; COMMENT if ESC C, increment rightct;
          outsymbol(27); outsymbol(67); COMMENT move cursor right;
          breakoutput;
          goto getcm4;   COMMENT get 4th cursor movement;
       end;
     if (answer2 = 66) and (downct < 2) then
       begin
          downct := downct + 1; COMMENT if ESC B, increment downct;
          outsymbol(27); outsymbol(66); COMMENT move cursor down;
          breakoutput;
          goto getcm4;   COMMENT get 4th cursor movement;
       end;
     if (answer2 = 66) and (downct >= 2) then
       begin
          outsymbol(27); outsymbol(72);
          write("[11N]"); outsymbol(27); outsymbol(75);
          write("You only need to use the down arrow twice                ");
          write("[N]"); outsymbol(27); outsymbol(75);
          write("Please try over, from the beginning");
          breakoutput;
          goto getenter2
       end
  end;
outsymbol(27); outsymbol(72);
COMMENT if " " give space error mess. otherwise reg. error message;
write("[11N]"); outsymbol(27); outsymbol(75);
if answer1 = 32 then
     write("The space bar inserts a space.")
  else
     write("Use the right arrow or the down arrow.");
write("[N]"); outsymbol(27); outsymbol(75);
write("Please try over, from the beginning");
breakoutput;
goto getenter2;
getcm4: f10call(inch,answer1,answer2,answer3); COMMENT input char;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT2;
COMMENT if ESC C or ESC B, get next input;
if answer1 = 27 then
  begin
     if (answer2 = 67) and (rightct < 3) then
       begin
          rightct := rightct + 1; COMMENT if ESC C, increment rightct;
          outsymbol(27); outsymbol(67); COMMENT move cursor right;
          breakoutput;
          goto getcm5;   COMMENT get 5th cursor movement;
       end;
     if (answer2 = 67) and (rightct >= 3) then
       begin
          outsymbol(27); outsymbol(72);
          write("[11N]"); outsymbol(27); outsymbol(75);
          write("You only need to use the right arrow three times.");
          write("[N]"); outsymbol(27); outsymbol(75);
          write("Please try over, from the beginning");
          breakoutput;
          goto getenter2
       end;
     if (answer2 = 66) and (downct < 2) then
       begin
          downct := downct + 1; COMMENT if ESC B, increment downct;
          outsymbol(27); outsymbol(66); COMMENT move cursor down;
          breakoutput;
          goto getcm5;   COMMENT get 5th cursor movement;
       end;
     if (answer2 = 66) and (downct >= 2) then
       begin
          outsymbol(27); outsymbol(72);
          write("[11N]"); outsymbol(27); outsymbol(75);
          write("You only need to use the down arrow twice.");
          write("[N]"); outsymbol(27); outsymbol(75);
          write("Please try over, from the beginning");
          breakoutput;
          goto getenter2
       end
  end;
outsymbol(27); outsymbol(72);
COMMENT if " " give space error mess. otherwise reg. error message;
write("[11N]"); outsymbol(27); outsymbol(75);
if answer1 = 32 then
     write("The space bar inserts a space.")
  else
     write("Use the right arrow or the down arrow.");
write("[N]"); outsymbol(27); outsymbol(75);
write("Please try over, from the beginning");
breakoutput;
goto getenter2;
getcm5: f10call(inch,answer1,answer2,answer3); COMMENT input char;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT2;
COMMENT if ESC C or ESC B, get next input;
if answer1 = 27 then
  begin
     if (answer2 = 67) and (rightct < 3) then
       begin
          rightct := rightct + 1; COMMENT if ESC C, increment rightct;
          outsymbol(27); outsymbol(67); COMMENT move cursor right;
          breakoutput;
          goto getcommand2
       end;
     if (answer2 = 67) and (rightct >= 3) then
       begin
          outsymbol(27); outsymbol(72);
          write("[11N]"); outsymbol(27); outsymbol(75);
          write("You only need to use the right arrow three times");
          write("[N]Please try over, from the beginning");
          breakoutput;
          goto getenter2
       end;
     if (answer2 = 66) and (downct < 2) then
       begin
          downct := downct + 1; COMMENT if ESC B, increment downct;
          outsymbol(27); outsymbol(66); COMMENT move cursor down;
          breakoutput;
          goto getcommand2
       end;
     if (answer2 = 66) and (downct >= 2) then
       begin
          outsymbol(27); outsymbol(72);
          write("[11N]"); outsymbol(27); outsymbol(75);
          write("You only need to use the down arrow twice");
          write("[N]Please try over, from the beginning");
          breakoutput;
          goto getenter2
       end
  end;
outsymbol(27); outsymbol(72);
COMMENT if user tries to give control-N now, give error message;
if answer1 = 14 then
  begin
     write("[11N]"); outsymbol(27); outsymbol(75);
     write("You must put the cursor AFTER the last ""*""!");
     write("[N]Please try over from the beginning");
     breakoutput;
     goto getenter2
  end;
COMMENT if " " give space error mess. otherwise reg. error message;
write("[11N]"); outsymbol(27); outsymbol(75);
if answer1 = 32 then
     write("The space bar inserts a space.")
  else
     write("Use the right arrow or the down arrow.");
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter2;
getcommand2: f10call(inch,answer1,answer2,answer3); COMMENT input char;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT2;
COMMENT if control-N get out;
if answer1 = 14 then
	goto outCN2;
COMMENT handle wrong answers;
outsymbol(27); outsymbol(72);
write("[11N]"); outsymbol(27); outsymbol(75);
if answer1 = 2 then
  begin
     write("Control-B is <INSERT-SPACES>.");
     write("[N]Please try over, from the beginning");
     goto getenter2
  end;
if answer1 < 27 then
  begin
     write("<DELETE-SPACES> command is control-N.");
     write("[N]Please try over, from the beginning"); breakoutput;
     goto getenter2
  end;
write("Give the <DELETE-SPACES> command after you give the parameter.");
write("[N]Please try over, from the beginning"); breakoutput;
goto getenter2;
OUTCN2: COMMENT blank out bottom line;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
write("                                                              ");
COMMENT position cursor at "***" and delete the block of "*"'s;
breakoutput;
outsymbol(27); outsymbol(89); outsymbol(37); outsymbol(36);
outsymbol(27); outsymbol(75); write(" text text text text");
outsymbol(27); outsymbol(89); outsymbol(38); outsymbol(36);
outsymbol(27); outsymbol(75); write(" text text text text");
outsymbol(27); outsymbol(89); outsymbol(39); outsymbol(36);
outsymbol(27); outsymbol(75); write(" text text text text");
breakoutput;
write("[4N]"); outsymbol(27); outsymbol(75);
write("Good! You got it!");
write("[N]"); outsymbol(27); outsymbol(75);
write("Push RETURN to continue");
outsymbol(27); outsymbol(89); outsymbol(39); outsymbol(36);
COMMENT get a carriage return;
breakoutput; getline; write("[5N]");
COMMENT update scores;
latescore := latescore + 1; if dummy = 1 then score := score + 1;
goto question2out;
COMMENT go here if control-C or "%";
KCOUT2: 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 question2;
POS:=1;
if anywhere("SKIP") then goto question2out;
goto KCOUT1
END;

%TEXT question2out: outsymbol(12); outsymbol(27); outsymbol(62);
Token parameters
================
     Sometimes the parameter you want is looking up at you
from the terminal screen. Instead of typing it, you can have
SED pick it up from the file. Such a parameter is called a
"token."
%TEXT
     To get a token parameter, position the cursor at the
start of the thing you want and type <ENTER-PARAMETER><command>
(where <command> is whatever command you're giving the parameter
to). Either the "word" at the cursor location or the length of
that "word" will be taken as the command's parameter.
A "word" is defined to be the text starting at the cursor and
extending to the first non-alphanumeric character.
%TEXT
     If the command takes a numeric parameter, the size of the
token is used, otherwise the actual string is used. For example,
to delete a word from the file, position the cursor to it and
type <ENTER-PARAMETER><DELETE-SPACES>. To search for the word
at the cursor position type <ENTER-PARAMETER><SEARCH-FORWARD>.
%TEXT
     Not all commands allow token parameters. You've seen the
<PERCENT-GOTO> and <PUT> commands, where <ENTER-PARAMETER><command>
has a special non-token meaning. However, in general if a token
makes sense for a command, it is legal. Experiment and see what
happens.
%ALGOL
begin dummy:=0; qcount:=qcount+1; COMMENT initialize dummy, increment qcount;
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]In the sentence below, the cursor is before the word ""quick"".");
write("[N]Using token parameters, delete the word ""quick"" ");
write("[NNN]The quick brown fox jumped over the lazy dog.");
f10call(noecho);
outsymbol(27); outsymbol(61); COMMENT enter alternate keypad mode;
getenter3: COMMENT blank out bottom line;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
outsymbol(27); outsymbol(75);
COMMENT position cursor at "quick";
outsymbol(27); outsymbol(89); outsymbol(37); outsymbol(36);
COMMENT make sure "q" is unmarked;
write("q"); outsymbol(8);
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 KCOUT3;
COMMENT if ESC P, get command;
if answer1 = 27 then
  begin
     if answer2 = 80 then
          goto getcommand3
  end;
write("[4N]"); 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;
getcommand3: COMMENT mark char where cursor is (reverse video, low intensity);
if MIME then
  begin
     outsymbol(27); outsymbol(83); outsymbol(74); write("q"); breakoutput;
     outsymbol(27); outsymbol(83); outsymbol(64); breakoutput; COMMENT unreverse video;
  end
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     outsymbol(27); outsymbol(91); outsymbol(55); outsymbol(109);
     comment reverse video; write("q"); comment unreverse video;
     outsymbol(27); outsymbol(91); outsymbol(48); outsymbol(109);
     outsymbol(27); outsymbol(91); outsymbol(63); outsymbol(50);
     outsymbol(108); comment return to vt52 mode;
  end;
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(">"); breakoutput;
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 KCOUT3;
COMMENT if control-N get out;
if answer1 = 14 then
	goto outCN3;
COMMENT handle wrong answers;
outsymbol(27); outsymbol(72);
write("[9N]"); outsymbol(27); outsymbol(75);
if answer1 = 2 then
  begin
     write("Control-B is <INSERT-SPACES>.");
     write("[N]Please try over, from the beginning");
     goto getenter3
  end;
if answer1 < 27 then
  begin
     write("<DELETE-SPACES> command is control-N.");
     write("[N]Please try over, from the beginning"); breakoutput;
     goto getenter3
  end;
write("Give the <DELETE-SPACES> command (you don't need a parameter).");
write("[N]Please try over, from the beginning"); breakoutput;
goto getenter3;
OUTCN3: COMMENT blank out bottom line;
outsymbol(27); outsymbol(89); outsymbol(55); outsymbol(32);
outsymbol(27); outsymbol(75);
COMMENT position cursor at "quick" and delete "quick ";
breakoutput;
outsymbol(27); outsymbol(89); outsymbol(37); outsymbol(36);
outsymbol(27); outsymbol(75); write("brown fox jumped over the lazy dog");
write("[4N]"); outsymbol(27); outsymbol(75);
write("Good! You got it!");
write("[N]"); outsymbol(27); outsymbol(75);
write("Push RETURN to continue");
outsymbol(27); outsymbol(89); outsymbol(37); outsymbol(36);
COMMENT get a carriage return;
breakoutput; getline; write("[5N]");
COMMENT update scores;
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); breakoutput;
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(12); outsymbol(27); outsymbol(62);
IMPORTANT:
Please remember that after you use any command with a parameter,
that parameter remains for that command (and its parameter-sharing
partner) until you change it. Thus if you use <DELETE-SPACES>
with a cursor movement or token parameter, the length of that
parameter will remain as the parameter. In the last example, for
instance, you deleted "quick "; therefore, if you now use
<DELETE-SPACES> without specifying a parameter, SED will delete 6
characters.
%text outsymbol(12);
Changing files while editing
============================
     If you are editing a file, and you want to do something to
a second file, you can get to it by typing

        <ENTER-PARAMETER><file2><SET-FILE>

where <file2> is the filespecs for your second file and the
<SET-FILE> command is the numeric keypad "1". SED will save the
first file (remembering where you are in that file) and display
the first page of the second file for editing. You can return to
the first file by typing just the <SET-FILE> command (this will
put you back exactly where you left off when you typed the first
<SET-FILE> command). Then you can get back to the second file
by typing another <SET-FILE> (again returning where you left off).
%TEXT
     If you give as a parameter the name of the file you are
currently editing, then you can toggle between two points in the
same file.
%TEXT
     This command is especially useful if you wish to copy
parts of one file into another, because typing the <SET-FILE>
command does not alter the buffers or the parameter values.
Thus you could go to file1, <PICK> some text, type the <SET-FILE>
command, and <PUT> the picked text into file2.
%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 file you are editing.");
write("[N]You want to edit another file called ""SNARK.FOR"".");
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;
if (answer1 = 3) or (answer1 = 37) then goto KCOUT4;
if answer1 = 27 then
  begin
     if answer2 = 80 then
          goto gets
  end;
COMMENT if not ESC P, error message and start over;
write("[5N]"); 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 getenter4;
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 KCOUT4;
COMMENT if "s" type it out and go get an "n";
if (answer1 = 115) or (answer1 = 83) then
  begin
     outsymbol(answer1);
     breakoutput;
     goto getn
  end;
COMMENT if printable, print it;
if answer1 > 31 then
     outsymbol(answer1);
outsymbol(27); outsymbol(72);
write("[5N]"); outsymbol(27); outsymbol(75);
write("The name of the file is ""SNARK.FOR"".");
COMMENT if wrong parameter, start over;
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter4;
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 KCOUT4;
COMMENT if "n" type it, go get an "a";
if (answer1 = 110) or (answer1 = 78) 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;
write("[5N]"); outsymbol(27); outsymbol(75);
write("The file you want is ""SNARK.FOR"".");
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter4;
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 KCOUT4;
COMMENT if "a" print it, go get an "r";
if (answer1 = 97) or (answer1 = 65) 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;
write("[5N]"); outsymbol(27); outsymbol(75);
write("The file you want is ""SNARK.FOR"".");
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter4;
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 KCOUT4;
COMMENT if "r" print it and get a "k";
if (answer1 = 114) or (answer1 = 82) 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;
write("[5N]"); outsymbol(27); outsymbol(75);
write("The file you want is ""SNARK.FOR"".");
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter4;
getk: f10call(inch,answer1,answer2,answer3); COMMENT input char;
COMMENT handle control-C or "%";
if (answer1 = 3) or (answer1 = 37) then goto KCOUT4;
COMMENT if "k", print it and get a ".";
if (answer1 = 107) or (answer1 = 75) then
  begin
     outsymbol(answer1);
     breakoutput;
     goto getdot
  end;
COMMENT if printable, print it;
if answer1 > 31 then
     outsymbol(answer1);
COMMENT error message, start over;
outsymbol(27); outsymbol(72);
write("[5N]"); outsymbol(27); outsymbol(75);
write("The file you want is ""SNARK.FOR"".");
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter4;
getdot: 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 KCOUT4;
COMMENT if "." type it, go get an "f";
if answer1 = 46 then
  begin
     outsymbol(answer1);
     breakoutput;
     goto getf
  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;
write("[5N]"); outsymbol(27); outsymbol(75);
write("The file you want is ""SNARK.FOR"".");
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter4;
getf: 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 "f" print it, go get an "o";
if (answer1 = 102) or (answer1 = 70) then
  begin
     outsymbol(answer1);
     breakoutput;
     goto geto
  end;
COMMENT if character is printable, print it;
if answer1 > 31 then
     outsymbol(answer1);
outsymbol(27); outsymbol(72);
COMMENT error message, start over;
write("[5N]"); outsymbol(27); outsymbol(75);
write("The file you want is ""SNARK.FOR"".");
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter4;
geto: 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 KCOUT4;
COMMENT if "o" print it and get a "r";
if (answer1 = 111) or (answer1 = 79) then
  begin
     outsymbol(answer1);
     breakoutput;
     goto getr2
  end;
COMMENT if character is printable, print it;
if answer1 > 31 then
     outsymbol(answer1);
outsymbol(27); outsymbol(72);
COMMENT error message, start over;
write("[5N]"); outsymbol(27); outsymbol(75);
write("The file you want is ""SNARK.FOR"".");
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter4;
getr2: f10call(inch,answer1,answer2,answer3); COMMENT input char;
COMMENT handle control-C or "%";
if (answer1 = 3) or (answer1 = 37) then goto KCOUT4;
COMMENT if "r", print it and get the command;
if (answer1 = 114) or (answer1 = 82) then
  begin
     outsymbol(answer1);
     breakoutput;
     goto getcommand4
  end;
COMMENT if printable, print it;
if answer1 > 31 then
     outsymbol(answer1);
COMMENT error message, start over;
outsymbol(27); outsymbol(72);
write("[5N]"); outsymbol(27); outsymbol(75);
write("The file you want is ""SNARK.FOR"".");
write("[N]Please try over, from the beginning");
breakoutput;
goto getenter4;
getcommand4: f10call(inch,answer1,answer2,answer3); COMMENT input char;
COMMENT handle control-C or "%";
if (answer1 = 3) or (answer1 = 37) then goto KCOUT4;
COMMENT if ESCAPE ? q, correct answer;
if answer1 = 27 then
  begin
     if answer2 = 63 then
       begin
         if answer3 = 113 then
              goto out1
       end
  end;
COMMENT regular keypad "1" gets special error message;
if answer1 = 49 then
  begin
     outsymbol(49);
     outsymbol(27); outsymbol(72);
     write("[5N]"); outsymbol(27); outsymbol(75);
     write("Use the ""1"" on the NUMERIC keypad (to the right)");
     write("[N]Please try over, from the beginning");
     goto getenter4
  end;
COMMENT if printable, print;
if answer1 > 31 then
     outsymbol(answer1);
COMMENT error message, start over;
outsymbol(27); outsymbol(72);
write("[5N]"); outsymbol(27); outsymbol(75);
write("Give the command after you give the parameter              ");
write("[N]Please try over, from the beginning"); breakoutput;
goto getenter4;
OUT1: outsymbol(27); outsymbol(72); outsymbol(27); outsymbol(74);
COMMENT write message;
write("Right! At this point, SED would place you at the first");
write("[N]page of the file called ""SNARK.FOR"".[NNN]");
COMMENT update scores;
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); pause;
END;
%TEXT outsymbol(12);
Picking or deleting large blocks of text
========================================
      If you want to pick or delete a few lines of text,
you can simply type <ENTER-PARAMETER>, the number
of lines to pick or delete, and then the desired command.
You could also type <ENTER-PARAMETER>, and then use
cursor movement to  get the lines you want.
However, if you want to pick or delete a large
number of lines (more than a screen-full), you would
not be able to  use cursor movement, and it would
be awkward to have to count the number of lines
you want deleted.
%TEXT
     Using the <MARK> command, numeric keypad 7,
you can mark your current position in the file,
move forward or backward to any other position, and
do a <PICK> or <DELETE-LINES> which will affect all
of the text between the mark and the ending cursor
position. You can use <ROLLs>, <SEARCHes>, <PERCENT_GOTO>,
or an other command which does not modify the file, to
get to the other end of the text you want to work with.
The <PICK>ed or <DELETE>d text can be <PUT> (back) in the
file in the normal fashion (by typing <PUT> or
<ENTER-PARAMETER><PUT>.
%ALGOL
begin dummy:=0; qcount:=qcount+1; COMMENT initialize dummy, increment qcount;
outsymbol(27); outsymbol(61); COMMENT enter alternate keypad mode;
question5:
COMMENT clear screen, cursor home;
outsymbol(27); outsymbol(72); outsymbol(27); outsymbol(74);
askmark:
dummy := dummy + 1; COMMENT increment dummy;
write("What is the <MARK> command ? (Give the command, not it's description)");
write("[N]--->"); breakoutput;
f10call(inch,answer1,answer2,answer3); COMMENT get input;
COMMENT if ESC ? w, correct answer, otherwise error message, try again;
if answer1 = 27 then
  begin
     if answer2 = 63 then
     begin
        if answer3 = 119 then
          begin
             latescore := latescore + 1;
             if dummy = 1 then
               begin
                  score := score + 1;
                  write("[N]Very good!")
               end
             else
                write("[N]That's right. I knew you could do it");
             breakoutput;
             goto question5out
          end;
COMMENT if 3 wrong tries, give answer and exit, otherwise try again;
        if dummy < = 3 then
          begin
            write("[N]No. That's the wrong key.");
            write("[N]Please try again.[NNN]");
            breakoutput;
            goto askmark
          end;
        write("[N]No! The <MARK> command is given by pushing the ");
        write("[N]""7"" key on the numeric keypad to the right of");
        write("[N]the regular keyboard.");
        breakoutput; goto question5out
     end
  end;
COMMENT if control-C or %, go to KCOUT;
if (answer1 =3) or (answer1 = 37) then goto KCOUT5;
if dummy < = 3 then
  begin
    write("[N]No. The <MARK> command is one of the numeric keypad keys.");
    write("[N]Please try again.[NNN]");
    breakoutput;
    goto askmark
  end;
write("[N]No! The <MARK> command is given by pushing the ");
write("[N]""7"" key on the numeric keypad to the right of");
write("[N]the regular keyboard.");
breakoutput; goto question5out;
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;
POS:=1;
if anywhere("SKIP") then goto question5out;
goto KCOUT5;
COMMENT exit alternate keypad mode;
QUESTION5OUT: outsymbol(27); outsymbol(62); pause;
END;
%TEXT outsymbol(12);
Getting information from SED
============================
     There are three ways you can get help from SED while
you are running it.

     You can get information about any command by typing

       <ENTER-PARAMETER><ENTER-PARAMETER><command>

where <command> is the command you want information on.
%ALGOL
begin
write("[N]     For example, if you type");
write("[2N]        <ENTER-PARAMETER><ENTER-PARAMETER><PICK>");
write("[2N]that is");
write("[2N]        <BLUE key><BLUE key> control-V");
write("[2N]SED would respond with:");
write("[2N]");
if MIME then
  begin
     outsymbol(27); outsymbol(83); outsymbol(74)
  end
else
  begin
     outsymbol(27); outsymbol(60); comment go into vt100 mode;
     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("[N]The <PICK> command (^PK)");
write("[N]");
write("[N]Loads the pick buffer with stuff from the file so that stuff can be");
write("[N]inserted somewhere else. Does not delete from the file.");
write("[N]");
write("[N]the pick buffer is dumped using the PUT command. Just move where you");
write("[N]want it and type <PUT>. The buffer can be put as often as desired.");
write("[N]");
write("[N]Related commands: <PUT>, <DELETE-LINES>, <MARK>");
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;
write("[2N]")
end;
%TEXT pause;
     Note that the above text is in reverse video to show you
what is typed out by SED. When you run SED, it will not type
the help messages in reverse video.
%TEXT
     Once you have typed two <ENTER-PARAMETER>s, SED will stay
in help mode until you type a "G". That way, you can get help
on as many commands as you want, without having to retype the
two <ENTER-PARAMETER>s each time.
%TEXT outsymbol(12);
     To get file status information, type the <SWITCH> command,
which consists of typing the numeric keypad "2".
The editor will write on the bottom of the screen a line which
looks like:

FILE: DSKB0:FILE.EXT[107006,1314] LINE: 123(53%) POS: 45 ALT:FILE2.EXT

This line says that the current file is "FILE.EXT", on account number
[107006,1314], the cursor is at the 123rd line, which is 53% through
the file, it is positioned at the 45th column, and the alternate
file (if you are editing two files) is "FILE2.EXT."
%TEXT outsymbol(12);
     To find out what the current parameter values are for various
commands, type <ENTER-PARAMETER><SWITCH>. (<SWITCH> is keypad 2).
This will give you a line like:

RL: 8, RP: 1, PC: 2, SL: 8, IL:1, IS: 8, PK: 3,8, TB: 8; KEY: th

This message tells you that the following values are set:

LINES TO ROLL:          8
PAGES TO ROLL:          1
PERCENT-GOTO:           2
SLIDE:                  8
INSERT/DELETE LINES:    1 line and 0 spaces
INSERT/DELETE SPACES:   8
PICK:                   3 lines and 8 spaces
TAB SIZE:               8
SEARCH KEY:             th
%ALGOL
begin dummy:=0; qcount:=qcount+1; COMMENT initialize dummy, increment qcount;
outsymbol(27); outsymbol(61); COMMENT enter alternate keypad mode;
question6:
COMMENT clear screen, cursor home;
outsymbol(27); outsymbol(72); outsymbol(27); outsymbol(74);
askswitch:
dummy := dummy + 1; COMMENT increment dummy;
write("What is the <SWITCH> command ? (Give the command, not it's description)");
write("[N]--->"); breakoutput;
f10call(inch,answer1,answer2,answer3); COMMENT get input;
COMMENT if ESC ? r, then correct, otherwise error message try again;
if answer1 = 27 then
  begin
     if answer2 = 63 then
     begin
        if answer3 = 114 then
          begin
             latescore := latescore + 1;
             if dummy = 1 then
               begin
                  score := score + 1;
                  write("[N]Very good!");
                  breakoutput;
                  goto question6out
               end;
             write("[N]That's right. I knew you could do it");
             breakoutput;
             goto question6out
          end;
COMMENT if 3 wrong tries, give answer and exit, otherwise try again;
        if dummy < = 3 then
          begin
            write("[N]No. That's the wrong key.");
            write("[N]Please try again.[NNN]");
            breakoutput;
            goto askswitch
          end;
        write("[N]No! The <SWITCH> command is given by pushing the ");
        write("[N]""2"" key on the numeric keypad to the right of");
        write("[N]the regular keyboard.");
        breakoutput; goto question6out
     end
  end;
COMMENT if control-C or %, give user a chance to exit;
if (answer1 =3) or (answer1 = 37) then goto KCOUT6;
if dummy < = 3 then
  begin
    write("[N]No. The <SWITCH> command is one of the numeric keypad keys.");
    write("[N]Please try again.[NNN]");
    breakoutput;
    goto askswitch
  end;
write("[N]No! The <SWITCH> command is given by pushing the ");
write("[N]""2"" key on the numeric keypad to the right of");
write("[N]the regular keyboard.");
breakoutput; 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;
COMMENT exit alternate keypad mode;
QUESTION6OUT: outsymbol(27); outsymbol(62); pause;
END;
%TEXT outsymbol(12);
Setting Switches
================
     The main use of the <SWITCH> command (keypad 2) is to set
switches. To set switches when you are in SED, type

        <ENTER-PARAMETER>/switch1/switch2/...<SWITCH>

where switch1, switch2, ... are the switches you wish to set.
(You must precede switches with a "/").
%TEXT
     You can also set switches when entering SED, by issuing
the monitor command:

        SED FILE.EXT/switch1/switch2/...

where FILE.EXT is the file you are editing, and switch1, switch2, ...
are the switches you wish to set.
%TEXT
     Switches for SED can also be put in your SWITCH.INI file,
if you have one. (If you don't have one, and want to know more
about it, see the help file "SWITCH.HLP". You can type it out
on your terminal by issuing the monitor command "HELP SWITCH"
or you can have it printed on the lineprinter by issuing the
monitor command "PRI HLP:SWITCH.HLP".
%TEXT
    There are a number of switches which you can set to tailor
SED to your own tastes. Here are the most useful ones. See the
reference manual, "DOC:SED.DOC", for a description of all the
switches.

BACKUP  make a backup file on exit
CASE    make searches case-dependent
LENG:n  make SED think the terminal is n lines long
ISAVE:n do an incremental save every n commands
RESET   reset parameters to default values after each command
SAVE:n  do and incremental save every n characters of type-in
STRIP   strip off SOS line numbers before editing a file
TABS:n  set tabs to be every n spaces
WIDTH:n make SED think the terminal is n spaces wide
%TEXT
SED starts with /BACKUP/CASE/NOISAVE/NORESET/NOSAVE/NOSTRIP/TABS:8.
LENGTH and WIDTH are the dimensions of your terminal.

Most switches can be prefixed with NO to turn them off. For
example, /NOCASE will make searches case-independant.

/NOTABS will make the tab-stops correspond with the start of
words (words are any string of characters between spaces), this
is called "word-wise" tabs.
%TEXT outsymbol(12);
Before ending this lesson, let's have a little review test,
to check how well you learned all this.
%ALGOL qcount := qcount + 1; goto question7;
%TEXT question7: pause; qcount := qcount - 1;
Consider the following text:

In winter when the fields are white,
I sing this song for your delight.

The cursor starts out on the "t" in "the", you type:
<ENTER-PARAMETER><CURSOR-DOWN><CURSOR-RIGHT><CURSOR-RIGHT><command>,
where <command> is some command. The resulting text is:

In winter when
                 the fields are white,
I sing this song for your delight.
%QUESTION
Which of the following is the <command>?

        1) <INSERT-SPACES> (control-B)
        2) <DELETE-SPACES> (control-N)
        3) <INSERT-LINES>  (control-D)
        4) <DELETE-LINES>  (control-F)
%EXTRA
%RIGHT 3
%RIGHT 3)
%WRONG 1
That would have resulted in:

In winter when   the fields are white,
I sing this son  g for your delight.
%GOTO question7;
%wrong 2
That would have resulted in:

In winter when e fields are white,
I sing this sonfor your delight.
%goto question7;
%WRONG 4
That would have resulted in:

In winter when for your delight.
%goto question7;
%WRONG
Please answer 1, 2, 3, or 4.
%QUESTION
In the following text, the cursor is positioned on the "g"
in "fragilistic":

super-cali-fragilistic-expi-ali-docious

You type <ENTER-PARAMETER><SEARCH-FORWARD>.

Which of the following is the key that will be searched for:

        1) fragilistic
        2) gilistic
        3) super-cali-fragilistic-expi-ali-docious
        4) gilistic-expi-ali-docious
%RIGHT 2
%RIGHT 2)
%WRONG 1
The token parameter is the "word" at the cursor position.
However, a "word" is defined to be the text string
STARTING AT THE CURSOR and extending to the first
non-alphanumeric character.
%WRONG 3
The token parameter is the "word" at the cursor position.
However, a "word" is defined to be the text string
STARTING AT THE CURSOR and extending to the first
NON-ALPHANUMERIC character. "-" is the first non-alphanumeric
character after the cursor.
%WRONG 4
The token parameter is the "word" at the cursor position.
However, a "word" is defined to be the text string
starting at the cursor and extending to the first
NON-ALPHANUMERIC character. "-" is the first non-alphanumeric
character after the cursor.
%WRONG
Please answer 1, 2, 3, or 4.
%QUESTION
The <SET-FILE> command is used to get from one file to
another in SED. To give the <SET-FILE> command you should
type:

        1) Numeric keypad "1"
        2) Numeric keypad "2"
        3) Numeric keypad "7"
        4) Numeric keypad "8"
%RIGHT 1
%RIGHT 1)
%WRONG 2
Numeric keypad "2" is the "<SWITCH>" command.
%WRONG 3
Numeric keypad "7" is the "<MARK>" command.
%WRONG 4
Numeric keypad "8" is the "<BEGIN-LINE>" command.
(Puts you at the beginning of a line).
%WRONG
Please answer 1, 2, 3, or 4.
%QUESTION
The <MARK> command allows you to mark a position in the
file, in order to pick or delete large blocks of text.
The <MARK> command is given by typing:

        1) Numeric keypad "1"
        2) Numeric keypad "2"
        3) Numeric keypad "7"
        4) Numeric keypad "8"
%RIGHT 3
%RIGHT 3)
%WRONG 1
Numeric keypad "1" is the "<SET-FILE>" command.
%WRONG 2
Numeric keypad "2" is the "<SWITCH>" command.
%WRONG 4
Numeric keypad "8" is the "<BEGIN-LINE>" command.
(Puts you at the beginning of a line).
%WRONG
Please answer 1, 2, 3, or 4.
%QUESTION
To get information about a command, type:

        1) <ENTER-PARAMETER><command>
        2) <ENTER-PARAMETER>G<command>
        3) <ENTER-PARAMETER><command><command>
        4) <ENTER-PARAMETER><ENTER-PARAMETER><command>
%RIGHT 4
%RIGHT 4)
%WRONG 1
That would use the command with a TOKEN parameter.
%WRONG 2
"G" is used to get OUT of help-mode, not into it.
%WRONG 3
You have the right idea, but you're repeating the wrong
part of the command.
%WRONG
Please answer 1, 2, 3, or 4.
%QUESTION
The <SWITCH> command is used to set switches, get file status
information, or find out what the various parameters are set to.
The <SWITCH> command is given by typing:

        1) Numeric keypad "1"
        2) Numeric keypad "2"
        3) Numeric keypad "7"
        4) Numeric keypad "8"
%RIGHT 2
%RIGHT 2)
%WRONG 1
Numeric keypad "1" is the "<SET-FILE>" command.
%WRONG 3
Numeric keypad "7" is the "<MARK>" command.
%WRONG 4
Numeric keypad "8" is the "<BEGIN-LINE>" command.
(Puts you at the beginning of a line).
%WRONG
Please answer 1, 2, 3, or 4.

%QUESTION
To get file status information (for example, something like:
FILE: SED.RNO[123,4567] LINE:534(67%) POS:1 ALT: FOO.BAR[123,4567]),
you should type:

        1) <SWITCH>
        2) <ENTER-PARAMETER><SWITCH>
        3) <ENTER-PARAMETER>/FILE<SWITCH>
        4) <ENTER-PARAMETER>/STATUS<SWITCH>
%RIGHT 1
%RIGHT 1)
%WRONG 2
<ENTER-PARAMETER><SWITCH> would tell you what the various
parameters are set to.
%WRONG 3
That would try to set a switch called "/FILE", which doesn't
exist, and you would get an error message.
%WRONG 4
That would try to set a switch called "/STATUS", which doesn't
exist, and you would get an error message.
%QUESTION
To find out what the various parameters are currently set to,
type:

        1) <SWITCH>
        2) <ENTER-PARAMETER><SWITCH>
        3) <ENTER-PARAMETER>/PARAM<SWITCH>
        4) <ENTER-PARAMETER>/STATUS<SWITCH>
%RIGHT 2
%RIGHT 2)
%WRONG 2
<SWITCH> would give you file status information.
%WRONG 3
That would try to set a switch called "/PARAM", which doesn't
exist, and you would get an error message.
%WRONG 4
That would try to set a switch called "/STATUS", which doesn't
exist, and you would get an error message.
%TEXT outsymbol(12);
Alright, that's all for this lesson.
%END