Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-04 - 43,50334/tops6s.gno
There are no other files named tops6s.gno in the archive.
%switch qz false
%if qz
%nocontrolc
%nextlesson pub("TOPQ");
%ifend qz
%qend begin integer misscount; external integer procedure tinput;
%TEXT t1:
Text editing with SOS.
======================

SOS is a very powerful text editor on the DEC 10.
This course will not teach you all of the commands of SOS,
only the most useful ones.
SOS is a line editor; that is you normally use the line number(s)
as reference when you use a command in SOS.

SOS can be either in COMMAND mode or INSERT mode.

In the COMMAND mode you can use any of the commands
in SOS. When SOS is in COMMAND mode it types an asterisk ("*") in the
first position of the line, and waits for you to type a command.

In INSERT mode you can only insert a new text. In this mode SOS types
a line number in the left margin.
%question q1:
Is it possible to use a command in SOS if you have an
asterisk in the left margin?
%noextra
%order
%right yes
The asterisk means COMMAND mode.
%right y
%same
%wrong no
%same
%wrong n
%same
%extra
%neutral
Answer yes or no.
%goto q1
%text
Inserting text into a file.
===========================

When you create a new file in SOS by using the "SOS" command,
you automatically enter the INSERT mode.
You just type a line of text that you want to insert and press
return key. A new line number will appear to the left and
you can continue to insert more text.

%text
If you want to leave the insert mode and enter the command
mode you press the ALTMODE or ESCAPE key.
SOS will then type an asterisk which
means that you are in command mode.
The ESCAPE or ALTMODE key is a very important key.
If the ESCAPE key does not work, or if there is no such key,
you could sometimes push CONTROL-# instead, that is simultaneously
pushing the CONTROL and "#" key on your terminal. On other
terminals you should use CONTROL-[ or CONTROL-$ to get ESCAPE.
If nothing works, please consult your local system manager.

The ESCAPE character is not printable. Therefore, in this
lesson it will be printed as $. Wherever the $ character occurs
in this lesson, it does not really mean $, it means ESCAPE.
%QUESTION printESCAPE:
Push the ESCAPE key!
%RIGHT 
%wrong stop
Write "%" if you want to stop.
%extra
%wrong $
Press the ESCAPE key, not the character it will be printed as.
%wrong [
%same
%wrong #
%same
%wrong ESC
Push the ESCAPE key. Do not type the whole word ESCAPE.
%wrong CONTROL
Push the CONTROL key and another key. Don't type the
word CTRL or CONTROL or the character "^"!
%wrong CTRL
%same
%wrong ^
%same
%WRONG
%wrong
%WRONG
Your terminal and the computer probably do not quite understand
each other. This may be remedied by the tty command, ask someone
about it.
%GOTO printESCAPE
%text t3:
When you edit an old file in SOS you will instead enter 
the command mode after you type the SOS command.
%text
If you are in command mode and want to insert a text
into the file, you can do this by using the INSERT command
which is written as the single letter "I".
After "I" you type the line number where you want to
have the text. Then you press the RETURN key and type your text.

EXAMPLE: You want to insert the text "BEGIN" at line 300.
Then you type "I300" , press the RETURN key and type "BEGIN".
%question q3:
What do you type if you want to insert the text "INTEGER"
at line 500?
%noextra
%order
%neutral I 500
%algol if skip then begin skip:=false; goto q3a; end;
nopause:=true; write("00500   "); breakoutput;
begin integer i,c;
for i:=1 step 1 until 7 do begin c:=tinput;
  if c # "INTEGER".[i] and
     c # "integer".[i] then begin
     newline;
     wrongmessage;
     Write("Type INTEGER[N]");
     goto q3;
  end;
end;
c:=tinput;
if c # 27 and c # 13 then
begin newline; wrongmessage;
  Write("Finish with pushing ESCAPE or RETURN[N]");
  goto q3;
end;
if c = 13 then c:=tinput;
newline;
rightmessage;
end;
%neutral I 0500
%same
%neutral I 00500
%same
%wrong 500 i
You typed the command in the wrong order.
%extra
%wrong INTEGER
First type the command, then push RETURN, and then
type "INTEGER".
%lack I
Use the "I" command in SOS.
%wrong insert
The INSERT command is typed "I".
%wrong "
Do not type the quotation marks.
%extra
%wrong I 500   
You only type the command I500 and press the RETURN key.
Then you write INTEGER.
%wrong 5OO
You probably typed the letter "O" instead of "0".
%lack 500
The line number is 500.
%wrong
Just type the command I500 , press the RETURN key and 
write your text.
%wrong
%same
%wrong
%goto t3
%question q3a:
Do you want another question on the INSERT command ?
%neutral yes
%goto q4
%neutral y
%same
%neutral no
%goto t4
%neutral n
%same
%neutral
Answer yes or no!
%goto q3a
%question q4:
What do you type if you want to insert the text "REAL"
at line 800?
%noextra
%order
%neutral I 800
%algol if skip then begin skip:=false; goto t4; end;
write("00800   "); breakoutput; nopause:= true;
begin integer i,c;
for i:=1 step 1 until 4 do begin c:=tinput;
  if c # "REAL".[i] and
     c # "real".[i] then begin
     newline;
     wrongmessage;
     Write("Type REAL[N]");
     goto q3a;
  end;
end;
c:=tinput;
if c # 27 and c # 13 then
begin newline; wrongmessage;
  Write("Finish with pushing ESCAPE or RETURN[N]");
  goto q3a;
end;
if c = 13 then c:=tinput;
newline;
rightmessage;
end;
%neutral i 0800
%same
%neutral i 00800
%same
%extra
%wrong insert
The INSERT command is typed "I".
%lack I
Use the I command in SOS.
%wrong "
You should not write the quotation marks.
%wrong integer
No, this time you shold insert the word REAL
%extra
%wrong I 800   
You only type the command I800 and press the RETURN key.
Then you write REAL.
%wrong 8OO
You probably typed "O" instead of "0".
%lack 800
The line number is 800.
%wrong insert
The INSERT command is written "I".
%wrong
Just type the command I800 , press the RETURN key and 
write your text.
%wrong
%same
%wrong
Type I800
%wrong
%goto next
%text t4:
If you want to insert a text at a line number which
is already occupied, SOS will give the inserted text
a line number between the number you wanted and the
following line number.

 EXAMPLE: You have the file below consisting of only
two lines.

00100    line 1
00200    line 2

If you type the command "I100", press the RETURN key
and type "INSERT" you will get the result:

00100    line 1
00150    INSERT
00200    line 2

%question
What number will an inserted line receive in the
file below, if you use the SOS command "I200"?

00100    line 1
00200    line 2
00300    line 3
%noextra
%order
%right 00250
%right 0250
%right 250
%extra
%right two hundred fifty
%right two hundred and fifty
%wrong 200
This line is already occupied. 
%wrong 300
%same
%wrong 100
%same
%wrong 150
You will get a line number between the line number you wanted
and the next line number.
%wrong 25O
You typed "O" instead of "0".
%wrong
%wrong
The right answer is 250.
%goto t5
%text t5:
The print command.
==================

When you are working with a file, you often need to look 
at specific lines in the file.
You can do that by using the "PRINT" command which is 
written as the single letter "P". After "P" you type
the number of the line you want to see.

EXAMPLE: If you want to look at line 100 you type "P100".

If you want to see more than one line then you type the number
of the first and the last line separated by a ":".

EXAMPLE:  P1000:1400
will print line 1000 up to line 1400.
This way of specifying a range of lines (two linenumbers
separated by a colon) applies to many SOS commands.

The symbol "^" indicates the first line and "*" the last line. 
These can be used instead of line numbers.
%question q9:
What do you type if you want to look at the lines 1000
up to and including the last line?
%order
%noextra
%right P 1000 : *
%right P 01000 : *
%right P 1000 : EF
Maybe the best way to write this command,
but will print to end of file, not only end of page.
%right p 01000 : EF
%same
%wrong p * : 1000
You have typed the line numbers in the wrong order.
%extra
%wrong ^
The symbol ^ means the first line,
use the symbol * for the last line instead.
%wrong print
The PRINT command is typed "P".
%lack p
The PRINT command is typed "P".
%lack *
Use the symbol "*" for the last line.
%lack :
Use the ":" to separate the lines.
%wrong 1OOO
You typed "O" instead of "0".
%lack 1000
The first line number was 1000.
%wrong ^[
You must type return, not ESCAPE or ALTMODE.
%wrong
First the "P" command and then the line numbers.
%wrong
%goto t5
%text
The character "." indicates current line.
That means the last line that has been printed
on your terminal. This character can be used instead of the
line number.
%question qest10:
What do you type if you want to see the first line
upto and including current line?
%noextra
%order
%right P ^ : .
%right p bf : .
This is correct, but how did you know that ?
%right P 1 : .
I did not expect that answer, but it is a correct command in SOS.
It is often better to use "^" for the first line.
%right p 0 : .
%same
%extra
%wrong *
No, the symbol * means the last line and not the current line.
%lack p
The PRINT command is typed "P".
%lack ^
Use "^" to represent the first line.
%lack .
Use "." to represent current line.
%lack :
You must have a colon to separate the lines.
%wrong print
The PRINT command is written "P".
%wrong p ^ : .
%algol extratest;
%wrong
%wrong
Now it is time for some repetition.
%goto t5
%text
By using the "P" command without any specified line number
the current line and the next fifteen lines will be displayed.
If you type "P" once again, the next sixteen lines will be
printed. If you continue to give the "P" command, sixteen
lines will be printed every time.
%question qest11:
What do you type if you want to print current line
and the next fifteen lines with as few keystrokes
as possible?
%noextra
%right P
%wrong p . : . + 15
This does the job, but uses too many keystrokes.
Tell me how to do it in one keystroke!
%wrong p . ! 16
%same
%wrong p ! 16
%same
%wrong p .
SOS will then print only the current line.
%lack P
Use the "P" command.
%wrong print
The print command is typed "P".
%wrong
You don't need to type anything after "P".
%text line1:
You may print the line after current line without using
the PRINT command by just pushing the LINE FEED key.
(If you do not have a LINE FEED key on your terminal, you can
type CONTROL-J. That is press the CONTROL and "J" key at the
same time.)

If you want to print the line before current line you
push the ALTMODE or ESCAPE (ESC) key.
%question qline1:
What key do you push if you want to see the line after
current line ? (End the answer by pushing the RETURN key.)
%extra
%noorder
%algol
if answerlength=1 and answer.[1] = 10 then
begin rightmessage; goto next; end;
if answerlength=1 and answer.[1] =12 then
begin write("You pushed the FORM FEED instead of LINE FEED.");
wrongmessage; goto repeat; end;
%right LINE FEED
%right LF
%right ERASE LINE
%wrong j
Before you press the "J", you must press the CONTROL key
and keep it suppressed when you push the "J" key.
%neutral p.+1
This is not quite what I asked, although it does the right thing.
Show me how to do it in one keystroke only.
%wrong 
You pushed the ALTMODE or ESCAPE.
%wrong
You did not hit the LINE FEED key. Look for a key labelled
"LINE FEED" or "LF" or "ERASE LINE". 
%wrong
%goto line1
%question qline2:

Push the key you use when you want to see the line before the current
line ! (End the answer by pushing the RETURN key.)
%noextra
%RIGHT 
%wrong stop
Write "%" if you want to stop.
%extra
%wrong $
Press the ESCAPE key, not the character it will be printed as.
%wrong [
%same
%wrong #
%same
%wrong ESC
Push the ESCAPE key. Do not type the whole word ESCAPE.
%wrong CONTROL
Push the CONTROL key and another key. Don't type the
word CTRL or CONTROL or the character "^"!
%wrong CTRL
%same
%wrong ^
%same
%WRONG
%wrong
%WRONG
Your terminal and the computer probably do not quite understand
each other. This may be remedied by the tty command, ask someone
about it.
%GOTO qline2;
%text t6:
The delete command.
===================

Sometimes you want to delete lines you do not need 
any  more.
You can do that with the DELETE command.
It is written as the letter "D". After "D" you type
the number of the line you want to delete. If you want
to delete more than one line you separate the first
and last line number by a colon, as you did in the
PRINT command.

EXAMPLE:  D500:700
will delete lines 500 up to and including 700.

%question
What do you type to delete the first line up to and
including line 50000?
%noextra
%order
%right D ^ : 50000
%right D BF : 50000
This is definitely right, but how did you know ?

%right D 0 : 50000
It is often better to use "^" for the first line.
%right d 1 : 50000
%same
%wrong d 50000 : ^
You have typed the line numbers in the wrong order.
%wrong D 50000  : 1
%same
%wrong D 50000 : 0
%same
%extra
%lack D
Use the "D" command.
%lack :
You must separate the lines by a colon ":".
%lack ^
Use "^" for the first line.
%extra
%wrong 5OOOO
You typed "O" instead of "0".
%wrong delete
The DELETE command is typed "D".
%wrong .
You do not need to type ".".
%wrong d ^ : 50000
%algol extratest;
%wrong
A hint:
Type the "D" command followed by line specifications.
%wrong
Time for repetition.
%goto t6
%text t8:
The replace command.
====================

If you want to replace a text with another text, you can
first delete the line with the "D" command and then 
insert the new text with the "I" command.
A better way is to use the REPLACE command, written "R".
It works as the "D" command and "I" command taking together.
After "R" you type the number of the line you want to replace.
Then press the RETURN key and type your new text.

EXAMPLE: If you want to replace the text "page" below you type
"R200" press the RETURN key and type your new text
in the same way as you did in the INSERT command.
00100    line 1
00200    page
00300    line 3
%question q7:
What do you type if you want to replace "page" by "line 2"
in the given file? (Use the "R" command)

00100    line 1
00200    page
00300    line 3

%noextra
%order
%neutral R 200
%algol write("00200    "); breakoutput; nopause:=true;
%neutral r 0200
%same
%neutral r 00200
%same
%extra
%wrong r 200
After you have typed R200 you press the RETURN key.
Then you write your text.
%wrong r200
%same
%wrong 2OO
You typed "O" instead of "0".
%wrong replace
The REPLACE command is typed "R".
%lack R
The REPLACE command is written "R".
%wrong *
The asterisk means the LAST line.
%wrong
Just type "R" followed by the line number.
%wrong
%goto t8
%qend goto t10; begin procedure pause;;
%question begin integer errcount; goto bypassnormal; comment
%algol if false then bypassnormal:
Begin
firsttry:=true; lasterrors:=lastrights:=errcount:=0;
pause; if back then begin back:=false; goto t8; End;
ihaveblanked:= false;
End;
getline;
%right line 2
%extra
%wrong "
Do not type the quotation marks.
%wrong page
You shold REPLACE "page" by "line 2"
%goto q7
%wrong 200
You do not type the line number. It is done by SOS.
%goto q7
%wrong
After the command "R200" you just type "line 2"
%goto q7
%qend end;
%text t10:
The copy command.
=================

It is possible to duplicate a line or group of lines
by using the COPY command in SOS.
You type a "C" followed by a line number where you want
to have the text. Type a comma and the number of the line 
you want to copy.

EXAMPLE: "C200,100" will copy the contents of line 100
into a new line numbered 200.

If you want to copy more than one line, you separate
the first and last number with a colon.

EXAMPLE: "C1000,100:500" will copy the contents of line
100 through 500 into a new location beginning with line 1000.

%question q10:
What do you type if you want to copy the contents of line
800 through 1600 into a new location beginning at line 4000?
%order
%noextra
%right C 4000 , 800 : 1600
%right C 4000 , 0800 : 1600
%right C 04000 , 00800 : 01600
%extra
%wrong copy
The COPY command is typed "C".
%wrong OO
You probably typed "O" instead of "0".
%lack C
Use the "C" command.
%lack ,
Separate the line number and what you want to copy with a comma.
%lack :
Use a colon to separate the first and the last copied lines.
%lack 4000
The line number was 4000
%lack 800
The line number was 800
%lack 1600
The line number was 1600
%noorder
%wrong 
First you type the "C" command, then the line number where you
want to have your text.
%wrong
We take the text once again.
%goto t10
%text toobig:
If there is not enough space when you use the COPY command,
SOS will renumber the lines and choose a smaller increment 
between the line numbers. 
SOS will inform the user by typing
INC=<increment>
If SOS cannot choose a small enough increment, it will 
type %OUT OF ORDER.
In that case only a part of the text will be copied.
%question q11:
You use the copy command "C" and SOS answers
INC1=10
Does it mean that SOS has copied the whole text
where you wanted to have it and changed the increment
between line numbers to 10 ?
%noextra
%order
%right yes
%right y
%wrong no
When it is not possible to copy the whole text, SOS will 
type %OUT OF ORDER
%wrong n
%same
%extra
%neutral 
Answer yes or no!
%goto q11
%neutral
Why don't you want to answer YES or NO ?
%goto t11
%text t11:
Are you tired ?
We have only one command left.
It is the TRANSFER command and it is not more difficult
than the COPY command.
%text t12:
The transfer command.
=====================

If you want to transfer a line or a group of lines within 
a file you can use the TRANSFER command, written "T".
It works like the copy command but it also deletes the old
lines you copied.
First you type the "T", then the line number where you
want to have the text. Type a comma and the number of the
line you want to transfer.

EXAMPLE:   "T1000,100:500"  
will transfer lines 100 through 500 into the location
beginning with line 1000.

%question q12:
What do you type if you want to transfer lines 200 through
600 into the location beginning with line 1000 ?
%noextra
%order
%right t 1000 , 200 : 600
%right t 1000 , 0200 : 0600
%right t 01000 , 00200 : 00600
%wrong t 200 : 600 , 1000
You have the wrong order.
After "T" you type the line number where you want to have your text.
%extra
%wrong transfer
The TRANSFER command is typed "T".
%lack T
Use the "T" command.
%wrong OO
You probably typed "O" instead of "0".
%lack 1000
After "T" you type the line number where you want to have the text.
%lack ,
After 1000 you type a comma ",".
%lack 200
The first copied line has the number 200.
%lack :
You separate the copied lines by a colon ":".
%lack 600
The last copied line has the number 600.
%wrong
A hint:
First the "T" command , then the line number where you want to
have your text.
%wrong
%wrong
%goto q12
%question
What do you type if you want to transfer line 800 to
line 1200 with the shortest possible transfer command ?
%noextra
%order
%right T 1200 , 800
%right T 1200 , 0800
%wrong t 01200 , 00800
Omitting the zeroes will make the command shorter.
%wrong T 800 , 1200
You have typed the line numbers in the wrong order.
%extra
%wrong transfer
The TRANSFER command is typed "T".
%lack T
Use the TRANSFER command "T".
%lack ,
Use a comma to separate the destination from the source lines.
%wrong :
You only need to use the colon when you transfer more
than one line.
%wrong OO
You probably typed "O" instead of "0".
%lack 800
You did not type 800.
%lack 1200
You did not type 1200.
%wrong transfer
The TRANSFER command is typed "T".
%wrong
You are only transferring one line.
First you type the "T" command. Then the line number where you
want to have your text. Type a comma and end with the transfered line.
%wrong
%same
%wrong
%same
%text t13:
In this exercise we have only handled complete lines.
It is also possible in SOS to make changes within a line.
We will do that in lesson number 8.
The next lesson will teach you how to start and end SOS editing.
%question slut3:
Do you want to repeat this lesson ?
%noextra
%neutral yes
%goto start
%neutral y
%same
%neutral no
%neutral n
%extra
%neutral
Answer yes or no!
%goto slut3
%text if percent < 50 then
SOS is not easy to learn.
I am glad that you went on and did not end the lesson.
%text if percent>=50 and percent<80then 
SOS is not easy to learn, but you have made great progress.
%text if percent>=80 and percent<100 then
You have given very good answers and I am glad to have such
a clever student.
%text if percent=100 then
Perfect!!
You have given the right answer to all questions.
Have you used SOS before ??
If not, you have done an exellent job!!
%text summary:
Summary
=======

All these commands are for edit mode.

SOS Command	Effect
-----------	------
$		(ESCAPE) Print the previous line.
		(If in insert mode: Switch to edit mode)
LINE FEED	Print the next line.
In		Insert line with line number n.
Pn		Print line n.
Pm:n		Print all lines from m to n, inclusively.
Dn		Delete line n.
Dm:n		Delete all lines from m to n, inclusively.
Rn		Replace line n.
Rm:n		Replace all lines from m to n, inclusively.
Ck,m:n		Copy all lines between m and n to lines starting
		with line k.
Tk,m:n		Transfer all lines between m and n to line k
		and following lines.

These characters may also be used as line numbers:
^	First line
.	Current line
*	Last line.
%qend end;
%end