%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 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: 50 That is 50. 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: 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 command is the BLUE key") else write("No! The 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(" 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 command is the BLUE key") else write("[NNNNNN]No! The 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] 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 "); 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 or where is your search key (without the brackets), is control-R, and 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 . 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 . The search parameter is shared by both 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 command is the BLUE key") else write("[6N]No! The 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 . "); 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] 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 command is the BLUE key") else write("[14N]No! The 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] 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 "); 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 command); if answer1 > 31 then begin outsymbol(27); outsymbol(72); write("[9N]Type the 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] command is control-E "); write("[N]Please try over "); write("[NN]"); breakoutput; goto getKE end; outsymbol(27); outsymbol(72); write("[9N]Give the 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 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: where the 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 command, control-V. As with , the parameter is the number of lines to pick. To insert the lines back in the file, position the cursor and issue the command (without the ). %text Thus, is the command which writes out the pick or delete buffer. writes the pick buffer and writes the delete buffer. Use the and commands to duplicate lines from your file; use and 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 . "); write("[N]Please try over. "); goto getenter8 end; COMMENT error message if control-character, not F; if answer1 < 27 then begin write("[NNNNNNN] is control-F. "); write("[N]Please try over. "); goto getenter8 end; COMMENT non-control character error message; write("[NNNNNNN]Just type the 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 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 "); 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 . "); 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] 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 ====================================== You already know how to insert text by using (numeric keypad ENTER) or by opening up a hole using (control-B) and then typing over the hole. However, the easiest way to insert text is to use the command. Type where is whatever you want to insert and 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 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 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 command is the BLUE key") else write("[4N]No! The 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 . "); write("[N]Please try over, from the beginning"); goto getenter9 end; if answer1 < 27 then begin outsymbol(27); outsymbol(72); write("[9N] 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 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 command is: 1)Control-P 2)Control-G 3)Control-T 4)Control-V %RIGHT 1 %RIGHT 1) %WRONG 2 Control-G is the command. %WRONG 3 Control-T if the command. %WRONG 4 Control-V is the command. %WRONG Answer 1, 2, 3, or 4. %WRONG %SAME %QUESTION The command is control-P. To get to the beginning of the file you should type: 1) 2) 3) 0 4) 100 %RIGHT 3 %RIGHT 3) %WRONG 1 Typing just will get you to the same percent of the way through the file as the LAST time a command was given in the current editing session. If that happens to be 0, or if this is the first issued, then you will get to the beginning of the file. This is not always the case, however. %WRONG 2 will get you to the END of the file, not the beginning. %WRONG 4 100 will get you to the END of the file, not the beginning. %WRONG Answer 1, 2, 3, or 4. %WRONG %SAME %QUESTION The two commands are: 1) Control-F for , control-B for 2) Control-R for , control-E for 3) Control-R for , control-B for 4) Control-F for , control-E for %RIGHT 2 %RIGHT 2) %WRONG 1 Control-F is and control-B is %WRONG 3 Control-R is but control-B is %WRONG 4 Control-E is but control-F is %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 and share a parameter, therefore there is no need to re-enter the text-string. %WRONG 2 Since the and 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 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 command, which puts the contents of the buffer into the file. %WRONG 3 Control-F is the command which, although it does load the lines into a buffer, deletes lines from the file. %WRONG 4 Control-P is the 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