%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 a 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 outsymbol(12); This lesson will cover a few useful commands for special cases. This is more an informational lesson than a teaching lesson. It will tell you about what there is in SED, so you know what to look for if ever you need these commands. Since these are commands you will rarely, if ever, use, they will not be covered in great detail. %TEXT Purpose of this lesson ====================== This lesson will cover: -what to do if the file is very wide -scanning the file -how to put control characters in the file -changing the case of characters -setting or clearing the split screen window -repeating commands or inventing your own %TEXT outsymbol(12); What to do if the file is very wide =================================== Sometimes the file you are editing has lines that are longer than 80 characters. If this happens, the text past the 80 characters disappears off the right side of the screen, but is still in the file. %TEXT The (control-K), and (control-L) commands move the viewing window left and right. It is important to remember that what you are moving is the window, not the file, so that will show you the columns to the right, and will put you back. %TEXT The parameter to the commands is the number of columns to slide. If you never give it a parameter, SED will assume 8 columns. %ALGOL begin dummy:=0; qcount:=qcount+1; COMMENT initialize dummy, increment qcount; outsymbol(27); outsymbol(61); COMMENT enter alternate keypad mode; question1: COMMENT clear screen, cursor home; outsymbol(27); outsymbol(72); outsymbol(27); outsymbol(74); askslideleft: dummy := dummy + 1; COMMENT increment dummy; write("What is the command ? "); WRITE("[N](Give the command, not it's description)"); write("[N]--->"); breakoutput; f10call(inch,answer1,answer2,answer3); COMMENT get input; COMMENT if control-K, correct answer; if answer1 = 11 then begin latescore := latescore + 1; if dummy = 1 then begin score := score + 1; write("[N]Very good![N]"); breakoutput; goto question1out end; write("[N]That's right. I knew you could do it[N]"); breakoutput; goto question1out end; COMMENT if control-L, special error message, try again; if answer1 = 12 then begin write("[N]No. I'm sorry, but control-L is ."); write("[N]Please try again.[N]"); breakoutput; goto askslideleft end; COMMENT if control-C or % give user a chance to get out; if (answer1 =3) or (answer1 = 37) then goto KCOUT1; if dummy < = 3 then begin write("[N]No. That's the wrong key."); write("[N]Please try again.[NNN]"); breakoutput; goto askslideleft end; write("[N]No! The command is control-K. [N]"); breakoutput; goto question1out; COMMENT go here if control-C or %; KCOUT1: 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 question1; POS:=1; if anywhere("SKIP") then goto question1out; goto KCOUT1; QUESTION1OUT: pause; dummy:=0; qcount:=qcount+1; COMMENT initialize dummy, increment qcount; question2: askslideright: dummy := dummy + 1; COMMENT increment dummy; write("[2N]What is the command ? "); WRITE("[N](Give the command, not it's description)"); write("[N]--->"); breakoutput; f10call(inch,answer1,answer2,answer3); COMMENT get input; COMMENT if control-L, correct answer; if answer1 = 12 then begin latescore := latescore + 1; if dummy = 1 then begin score := score + 1; write("[N]Very good![N]"); breakoutput; goto question2out end; write("[N]That's right. I knew you could do it[N]"); breakoutput; goto question2out end; COMMENT if control-L, special error message, try again; if answer1 = 11 then begin write("[N]No. I'm sorry, but control-K is ."); write("[N]Please try again.[N]"); breakoutput; goto askslideright end; COMMENT if control-C or %, allow user to exit; if (answer1 =3) or (answer1 = 37) then goto KCOUT2; if dummy < = 3 then begin write("[N]No. That's the wrong key."); write("[N]Please try again.[NNN]"); breakoutput; goto askslideright end; write("[N]No! The command is control-L. [N]"); breakoutput; goto question2out; COMMENT go here if control-C or %; KCOUT2: 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 question2; POS:=1; if anywhere("SKIP") then goto question2out; goto KCOUT2; COMMENT exit alternate keypad mode; QUESTION2OUT: outsymbol(27); outsymbol(62); pause; END; %TEXT outsymbol(12); Scanning ======== Scanning is where SED will do a or , wait a little, then roll again. It will keep rolling and waiting until you tell it to stop. %TEXT To start scanning type or . To stop, type any character, or the DELETE key. The scanning will stop, and the cursor will position itself in the middle of the screen. %ALGOL begin dummy:=0; qcount:=qcount+1; COMMENT initialize dummy, increment qcount; outsymbol(27); outsymbol(61); COMMENT enter alternate keypad mode; question3: COMMENT clear screen, cursor home; outsymbol(27); outsymbol(72); outsymbol(27); outsymbol(74); askscanforward: dummy := dummy + 1; COMMENT increment dummy; write("What command do you give to scan forward ?"); WRITE("[N](Give the command, not it's description)"); write("[N]--->"); breakoutput; f10call(inch,answer1,answer2,answer3); COMMENT get input; COMMENT check if ESC P (blue key); if answer1 = 27 then begin if answer2 = 80 then goto getKT end; if (answer1 = 3) or (answer1 = 37) then goto KCOUT3; if MIME then write("[N]No! is the BLUE key.") else write("[N]No! is the PF1 key."); write("[N]Please try again.[NNN]"); breakoutput; goto askscanforward; getKT: f10call(inch,answer1,answer2,answer3); COMMENT get next input; COMMENT if control-T, correct answer, otherwise error message, try again; if answer1 = 20 then begin latescore := latescore + 1; if dummy = 1 then begin score := score + 1; write("[N]Very good![N]"); breakoutput; goto question3out end; write("[N]That's right. I knew you could do it[N]"); breakoutput; goto question3out end; COMMENT if control-W, special error message; if answer1 = 23 then begin write("[N]No. I'm sorry, but control-W is ."); write("[N]Please try again.[NNN]"); breakoutput; goto askscanforward end; COMMENT if control-C or %, allow user to exit; if (answer1 =3) or (answer1 = 37) then goto KCOUT3; if dummy < = 3 then begin write("[N]No. That's the wrong command."); write("[N]Please try again.[NNN]"); breakoutput; goto askscanforward end; write("[N]No! The command is control-T. "); WRITE("[N]To scan forward, you should type "); breakoutput; 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; COMMENT exit alternate keypad mode; QUESTION3OUT: outsymbol(27); outsymbol(62); pause; END; %ALGOL begin dummy:=0; qcount:=qcount+1; COMMENT initialize dummy, increment qcount; outsymbol(27); outsymbol(61); COMMENT enter alternate keypad mode; question3b: COMMENT clear screen, cursor home; outsymbol(27); outsymbol(72); outsymbol(27); outsymbol(74); askscanbackward: dummy := dummy + 1; COMMENT increment dummy; write("What command do you give to scan backward ?"); WRITE("[N](Give the command, not it's description)"); write("[N]--->"); breakoutput; f10call(inch,answer1,answer2,answer3); COMMENT get input; COMMENT check if ESC P (blue key); if answer1 = 27 then begin if answer2 = 80 then goto getKW end; if (answer1 = 3) or (answer1 = 37) then goto KCOUT3b; if MIME then write("[N]No! is the BLUE key.") else write("[N]No! is the PF1 key."); write("[N]Please try again.[NNN]"); breakoutput; goto askscanbackward; getKW: f10call(inch,answer1,answer2,answer3); COMMENT get next input; COMMENT if control-W, correct answer, otherwise error message, try again; if answer1 = 23 then begin latescore := latescore + 1; if dummy = 1 then begin score := score + 1; write("[N]Very good![N]"); breakoutput; goto question3bout end; write("[N]That's right. I knew you could do it[N]"); breakoutput; goto question3bout end; COMMENT if control-T, special error message; if answer1 = 20 then begin write("[N]No. I'm sorry, but control-T is ."); write("[N]Please try again.[NNN]"); breakoutput; goto askscanbackward end; COMMENT if control-C or %, allow user to exit; if (answer1 =3) or (answer1 = 37) then goto KCOUT3b; if dummy < = 3 then begin write("[N]No. That's the wrong command."); write("[N]Please try again.[NNN]"); breakoutput; goto askscanbackward end; write("[N]No! The command is control-W. "); WRITE("[N]To scan forward, you should type "); breakoutput; goto question3bout; COMMENT go here if control-C or %; KCOUT3b: 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 question3b; POS:=1; if anywhere("SKIP") then goto question3bout; goto KCOUT3b; COMMENT exit alternate keypad mode; QUESTION3bOUT: outsymbol(27); outsymbol(62); pause; END; %TEXT outsymbol(12); Putting control-characters in the file ====================================== Every once in a while, you want to put a control-character in a file. To do this type the command, control-O, followed by the character you want to make a control character. This command can be used within a parameter, too. %TEXT For example, if you want to insert a control-L, type: L %TEXT There are two ways of inserting a tab character. One is using I, to insert a control-I. The other is to use the command, which inserts a tab. The command is given by typing the numerical keypad "0". Note that the command puts a tab character in the file, whereas the command causes the cursor to move but does not actually modify the file. %ALGOL begin dummy:=0; qcount:=qcount+1; COMMENT initialize dummy, increment qcount; outsymbol(27); outsymbol(61); COMMENT enter alternate keypad mode; question4: COMMENT clear screen, cursor home; outsymbol(27); outsymbol(72); outsymbol(27); outsymbol(74); askcontrol: dummy := dummy + 1; COMMENT increment dummy; write("What is the command ?"); WRITE("[N](Give the command, not it's description)"); write("[N]--->"); breakoutput; f10call(inch,answer1,answer2,answer3); COMMENT get input; COMMENT if control-O, correct answer, otherwise error message, try again; if answer1 = 15 then begin latescore := latescore + 1; if dummy = 1 then begin score := score + 1; write("[N]Very good![N]"); breakoutput; goto question4out end; write("[N]That's right. I knew you could do it[N]"); breakoutput; goto question4out end; COMMENT if control-C or %, allow user to exit; if (answer1 =3) or (answer1 = 37) then goto KCOUT4; if dummy < = 3 then begin write("[N]No. That's the wrong command."); write("[N]Please try again.[NNN]"); breakoutput; goto askcontrol end; write("[N]No! is control-O. "); breakoutput; 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: pause; dummy:=0; qcount:=qcount+1; COMMENT initialize dummy, increment qcount; question4b: outsymbol(12); askrealtab: dummy := dummy + 1; COMMENT increment dummy; write("What is the command ? (Give the command, not it's description)"); write("[N]--->"); breakoutput; f10call(inch,answer1,answer2,answer3); COMMENT get input; COMMENT if ESC ? p, correct answer, otherwise error message, try again; if answer1 = 27 then begin if answer2 = 63 then begin if answer3 = 112 then begin latescore := latescore + 1; if dummy = 1 then begin score := score + 1; write("[N]Very good![N]"); breakoutput; goto question4bout end; write("[N]That's right. I knew you could do it[N]"); breakoutput; goto question4bout end; if dummy < = 3 then begin write("[N]No. That's the wrong key."); write("[N]Please try again.[NNN]"); breakoutput; goto askrealtab end; write("[N]No! The command is given by pushing the "); write("[N]""0"" key on the numeric keypad to the right of"); write("[N]the regular keyboard."); breakoutput; goto question4bout end end; COMMENT if control-C or %, allow user to exit; if (answer1 =3) or (answer1 = 37) then goto KCOUT4b; if dummy < = 3 then begin write("[N]No. The command is one of the numeric keypad keys."); write("[N]Please try again.[NNN]"); breakoutput; goto askrealtab end; write("[N]No! The command is given by pushing the "); write("[N]""0"" key on the numeric keypad to the right of"); write("[N]the regular keyboard."); breakoutput; goto question4bout; COMMENT go here if control-C or %; KCOUT4b: 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 question4b; POS:=1; if anywhere("SKIP") then goto question4bout; goto KCOUT4b; COMMENT exit alternate keypad mode; QUESTION4bOUT: outsymbol(27); outsymbol(62); pause; END; %TEXT outsymbol(12); Changing the case of characters =============================== The command, keypad "9", will change characters from lower case to upper case, or from upper case to lower case, when the /INVERT switch is set (which is the default). %TEXT If the /NOINVERT switch is set, then it will only make one-way changes. If /RAISE is set (this is the default), lower case characters at the cursor will be changed to upper case; upper case and non-alphabetic characters will be unaffected Likewise, if /NORAISE is set, upper case characters at the cursor will be changed to lower case. %TEXT The parameter to is the number of characters to look at and maybe change the case of. You can use cursor movement (covered in lesson 4) to make work for more than one line. %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); askcase: dummy := dummy + 1; COMMENT increment dummy; write("What is the command ? (Give the command, not it's description)"); write("[N]--->"); breakoutput; f10call(inch,answer1,answer2,answer3); COMMENT get input; COMMENT if ESC ? y, correct answer, otherwise, error message, try again; if answer1 = 27 then begin if answer2 = 63 then begin if answer3 = 121 then begin latescore := latescore + 1; if dummy = 1 then begin score := score + 1; write("[N]Very good![N]"); breakoutput; goto question5out end; write("[N]That's right. I knew you could do it[N]"); breakoutput; goto question5out end; if dummy < = 3 then begin write("[N]No. That's the wrong key."); write("[N]Please try again.[NNN]"); breakoutput; goto askcase end; write("[N]No! The command is given by pushing the "); write("[N]""9"" key on the numeric keypad to the right of"); write("[N]the regular keyboard."); breakoutput; goto question5out end end; COMMENT if control-C or %, allow user to exit; if (answer1 =3) or (answer1 = 37) then goto KCOUT5; if dummy < = 3 then begin write("[N]No. The command is one of the numeric keypad keys."); write("[N]Please try again.[NNN]"); breakoutput; goto askcase end; write("[N]No! The command is given by pushing the "); write("[N]""9"" 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; QUESTION5OUT: write("[NN]"); COMMENT exit alternate keypad mode; outsymbol(27); outsymbol(62); pause; outsymbol(12); END; %QUESTION The /NOINVERT and the /NORAISE switches are set and the cursor is on the "q" in "qUiCK" in the sentence below: The qUiCK brown fox jumped over the lazy dog. If you type 5, the result will be: 1) The QUICK brown fox jumped over the lazy dog. 2) The quick brown fox jumped over the lazy dog. 3) The qUiCK brown fox jumped over the lazy dog. 4) The QuIck brown fox jumped over the lazy dog. %RIGHT 2 %RIGHT 2) %WRONG 1 When the /NORAISE switch is set, upper case characters become lower case. %WRONG 3 %same %WRONG 4 When the /NORAISE switch is set, upper case characters become lower case, but if the /NOINVERT switch is set, lower case characters remain untouched. %WRONG Please answer 1, 2, 3, or 4. %TEXT outsymbol(12); Setting or clearing the split-screen window =========================================== You already know (from lesson 4) how to toggle between two files, to edit the two at the same time. There is a way to have both files on the screen simultaneously. %TEXT The command, keypad "3", allows you to divide the terminal screen into upper and lower halves and display (and edit) a file in each half. %TEXT After is typed the file you are currently editing will appear in the top half of the screen and the bottom half will be blank. If you do a , the top window will remain unchanged and the new file will appear in the bottom window. You can then use s to toggle between two windows or to change the file which appears in the window. %TEXT To bring the screen back to the normal single-file mode, type the command again, and the screen will display the file you were currently editing. %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); askwindow: dummy := dummy + 1; COMMENT increment dummy; write("What is the command ? (Give the command, not it's description)"); write("[N]--->"); breakoutput; f10call(inch,answer1,answer2,answer3); COMMENT get input; COMMENT if ESC ? s, correct answer, otherwise error message, try again; if answer1 = 27 then begin if answer2 = 63 then begin if answer3 = 115 then begin latescore := latescore + 1; if dummy = 1 then begin score := score + 1; write("[N]Very good![N]"); breakoutput; goto question6out end; write("[N]That's right. I knew you could do it[N]"); breakoutput; goto question6out end; if dummy < = 3 then begin write("[N]No. That's the wrong key."); write("[N]Please try again.[NNN]"); breakoutput; goto askwindow end; write("[N]No! The command is given by pushing the "); write("[N]""3"" key on the numeric keypad to the right of"); write("[N]the regular keyboard."); breakoutput; goto question6out end end; COMMENT if control-C or % then allow user to exit; if (answer1 =3) or (answer1 = 37) then goto KCOUT6; if dummy < = 3 then begin write("[N]No. The command is one of the numeric keypad keys."); write("[N]Please try again.[NNN]"); breakoutput; goto askwindow end; write("[N]No! The command is given by pushing the "); write("[N]""3"" 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); Repeating commands or inventing your own ======================================== This section is included for your information, so that you are aware that the command exists. If you are interested in this command, you can look it up in "SED.DOC". This is a very powerful, and very complicated command, so if you do decide to use it, make sure you read the documentation thoroughly. %TEXT If you have a sequence of commands which you want to repeat many times (like doing a search and substitute, for example, or removing the first 16 characters of every line of the file) you can store that sequence in a buffer in the editor, and then execute it as many times as you like. %TEXT You can also use these buffers to define new editor commands and attach them to terminal keys. The buffers can be saved and read from disk or set up in SWITCH.INI. %TEXT The command which does these things is , control-X. There are too many details to describe here. Suffice it to say that SED has a language which includes all the commands plus several constructs such as DO WHILE and IF CHARACTER or POSITION, and that you can write and run "programs" in that language. The reference manual, DOC:SED.DOC, contains all the details. %TEXT outsymbol(12); Since this lesson was meant to be informational, there won't be any little quiz at the end to test you on your knowledge. I hope this set of lessons helped you. If you have any problems, complaints, or suggestions, please let the staff here at the computer center know. %TEXT Remember, there are several documentation files to help you with SED. On the "HLP:" area, there is "SED.HLP." To type it out on your terminal type the monitor command: HELP SED To print it out on the lineprinter, type the monitor command: PRI HLP:SED.HLP %TEXT On the "DOC:" area, there are two files: "SEDMAN.DOC" (on which these lessons were based), and "SED.DOC". Since these files are rather long, it is recommended that you don't try to type them out on a terminal. To print them on the lineprinter, type the monitor commands: PRI DOC:SEDMAN.DOC or PRI DOC:SED.DOC %TEXT On the "TED:" area there are a few files which contain keyboard layouts for the various terminals which support SED. To type or print them, type the monitor commands: TYPE TED:SED???.KYS or PRI TED:SED???.KYS where ??? is M2A for MIME2A, V10 for VT100 or VT132, V52 for VT52 or H19. %END