Macro Text Editor
Overview
The OS-9 Macro Text Editor is a powerful, easy-to-learn textpreparation system. Use it to prepare text for letters and documents or text to be used by other OS-9 programs, such as the
assembler and high-level languages. The text editor includes the
following features:
Compact size
· Capability of having multiple read and write files open
at the same time
· All OS-9 commands usable inside the text editor
Adjustable workspace size
Repeatable command sequences
,-
0
Edit macros (special utility functions)
Multiple text buffers
Powerful commands
The Macro Text Editor is about 5 kilobytes in size and requires
at least 2K bytes of free RAM to run.
Text Buffers
As you enter text, the editor places it in a temporary storage
area called a text buffer. A text buffer acts as a scratch pad for
saving text that you can manipulate with various edit commands. The Macro Text Editor can use multiple text buffers, one
at a time.
A buffer in use is called the
edit buffer.
Edit also has another
default buffer called the
secondary buffer.
As well, you can create
additional buffers up to the capacity of your computer's memory.
Edit Pointers
The Macro Text Editor has an edit
pointer
that identifies your
position in the buffer, in a manner similar to holding your place
in a book with your finger.
7-1
OS-9 Commands Reference
The pointer is invisible to you, but Edit commands can reposition it and display the text to which it points. Each buffer has its
own edit pointer, and you can move from buffer to buffer without
losing your place in any of them.
Entering Commands
The Macro Text Editor is interactive. This means you and the
editor carry on a two-way conversation. You issue a command,
and the editor carries out the command and displays the result.
When you are through making changes, you can save your
edited file, then press
© ENTER
to quit editing.
When the editor displays
E
: on the screen, it is waiting for you
to type a command. You type a line that includes one or more
commands, then press
ENTER
. Edit carries out the commands and
again displays
E:.
If you enter more than one command on a line, separate the
commands with a space. If, however, a space is the first character on a line, the editor considers the space to be an insert command and not a separator.
Correct a typing error by backspacing over it or by deleting the
entire line. Note, you cannot correct a line after pressing
ENTER .
Control Keys
You can use the same special control keys with Edit that you
use with OS-9. See Appendix D for a complete listing of these
keys. Following is a list of some of the control keys that are especially useful with Edit:
Control Key(s) Function
CTRL
0
Repeats the previous input line.
CTRL
© Terminates the editor and returns to com
mand entry mode.
CTRL
0
Displays the current input on the next line.
CTRL
0
Backspaces and erases the previous
or character.
7-2
Macro Text Editor / 7
Control Key(s) Function
® ENTER
Interrupts the editor and returns to com
mand entry mode.
CTRL
w0
Temporarily halts the data output to your
terminal so that you can read the screen
before the data scrolls off. Output resumes
when you press any other key.
CTRL
or Deletes the line.
SHIFT
CTRL BREAK
Terminates the editor, and returns to command entry mode.
Command Parameters
There are two types of edit parameters, "numeric" and "string."
Numeric Parameters.
Numeric parameters specify an amount,
such as the number of times to repeat a command or the number
of lines affected by a command. If you do not specify a numeric
parameter, the editor uses the default value of one. Specify all
other numeric parameters in one of the following ways.
· Enter a positive decimal integer in the range 0 to
65,535. For example:
0
10
5250
65532
31
· Enter an asterisk (*) as a shorthand for all (all the way
to the beginning, all the way to the end, all of the lines,
and so on). To the editor, an asterisk means infinity. -Use
the asterisk to specify all remaining lines, all characters, or repeat forever.
· Use a numeric variable. (See "Parameter Passing" later
in this chapter.)
7-3
OS-9 Commands Reference
String Parameters. String parameters specify a single character, group of characters, word, or phrase. Specify string parameters in either of the following ways.
· Enclose the group of characters with delimiters (two
matching characters). You can use any characters, but
they must match. If one string immediately follows
another, separate the two with a single delimiter that
matches the others. For example:
"string of characters"
/STRING/
my name
i5
Larry
"first String"second String"
/string 1/ String 2/
· Use a string variable. (See "Using Macros" later in this
chapter.)
Syntax Notation
Syntax descriptions indicate what to enter and the order in
which to do it. The command name is first; type it exactly as
shown. Follow the command name with the correct parameters.
Enter each as it is described in the section on parameters.
The syntax descriptions for each command use the following
notations:
n = numeric parameter
str = string parameter
= space character. When you see 5, press the space bar.
text = one or more characters terminated by pressing
ENTER
Getting Started
From the OS-9 prompt, start Edit by typing:
e d i t
ENTER
Enter a command when the screen shows
E:.
You can quit Edit at any time by pressing
© ENTER . The
Q command terminates the editor and returns you to the OS-9 Shell,
which responds with the
0 S - 9 : prompt
.
7-4
Macro Text Editor l 7
Following is a list of ways you can start the editor, including the
effect of each. The examples call a file that already exists
oldfile.
They call a file to be created
newfile.
EDIT OS-9 loads the editor and starts it. The com
mand does not establish an initial read or
write files, but you can perform text file opera
tions by opening files after the editor is
started.
EDIT
newfile
OS-9 loads the editor and starts it, creating
the file called
newfile. Newfile is
the initial
write file. There is no initial read file. How
ever, you can open files to read later.
EDIT oldfile
OS-9 loads the editor and starts it. The initial
read file is
oldfile.
The editor creates a file
called SCRATCH as the initial write file.
When you end the edit session, OS-9 deletes
oldfile
and renames SCRATCH to
oldfile. This
gives the appearance of
ddfile
being updated.
Note:
The two OS-9 utilities DEL and
RENAME must be present on your system if
you wish to to start the editor in this manner.
EDIT oldlIfle
OS-9 loads the editor and starts it. The initial
newfile
read file is oldfile. The editor creates
newfile
the initial write file. The terms oldfile and
newfile
refer to any properly constructed OS-9
pathlist.
7-5
OS-9 Commands Reference
Edit Commands
Displaying Text
Ln
Lists (displays) the next
n
lines, starting at
the current position of the edit pointer. The
edit pointer position does not change.
1 ENTER
displays the current line. If the edit pointer is
not at the beginning of the line, only the por
tion of the line to the right of the edit pointer
shows on the screen.
13 ENTER
displays the current line and the next two
lines.
1 * ENTER
displays all text from the current position of
the edit pointer to the end of the buffer.
The L command displays text regardless of
which verify mode is in effect.
Xn
Displays the
n
lines that precede the edit
pointer. The position of the edit pointer does
not change. For example:
x ENTER
displays any text on the current line that pre
cedes the edit pointer. If the edit pointer is at
the beginning of the line, the command dis
plays nothing.
x 3 ENTER
displays the two preceding lines and any text
on the current line that precedes the edit
pointer.
The X command displays text regardless of
which verify mode is in effect.
7-6
Macro Text Editor / 7
Manipulating the Edit Pointer
crR~ [D
or
0
Moves the edit pointer to the beginning (first
on an external character) of the text buffer. The screen shows
terminal the up arrow when you hold down
cTR~
and
press
CD.
For example,
CTRL 7~ ENTER
moves the edit pointer to the beginning of the
buffer.
Moves the edit pointer to the end (last charac
ter) of the buffer. For example,
/ ENTER
moves the edit pointer past the end of the
buffer.
Moves the edit pointer to the beginning of the
next line and displays it. Use this command to
go through text one line at a time. You can
look at each line, correct any mistakes, and
then move to the next line.
7-7
OS-9 Commands Reference
+ n
Moves the edit pointer either to the end of the
line or forward
n
lines and displays the line.
Entering a value of zero moves the edit pointer
to the end of the current line. For example:
+ 0 ENTER
Entering a value other than zero moves the
pointer forward
n
lines and displays the line.
For example,
+ ENTER
moves the pointer to the next line and displays
the line. This command performs the same
function as
ENTER .
+ 1 0 ENTER
moves the pointer ahead 10 lines and displays
the line.
+ * ENTER
moves the edit pointer to the end of the buffer.
-n
Moves the edit pointer either to the beginning
of the line or backward
n
lines. For example:
- 0 ENTER
moves the edit pointer to the beginning of the
line and displays the line. Entering a value
other than zero moves the edit pointer back
n
lines. For example,
- ENTER
moves the edit pointer back one line and displays the line.
- 5 ENTER
moves the edit pointer back five lines and displays the line.
- * ENTER
moves the edit pointer to the beginning (top)
of the buffer and displays the first line.
7-8
Macro Text Editor / 7
n
Moves the edit pointer to the right n charac
ters. Use this command to move the edit
pointer to some position in the line other than
the first character. For example,
ENTER
moves the edit pointer to the right one
character.
2 S ENTER
moves the edit pointer to the right 25
characters.
ENTER
moves the edit pointer to the end of the buffer.
< n
Moves the edit pointer to the left n characters.
Use this command to move the edit pointer to
some position in a line other than the first
character. For example:
< ENTER
moves the edit pointer to the left one
character.
< 1 0 ENTER
moves the edit pointer to the left 10
characters.
< * ENTER
moves the edit pointer to the beginning of the
buffer.
A
7-9
Os-9 Commands Reference
Inserting and Deleting Lines
text Preceding
text lines with a space inserts the
text as a new line ahead of the edit pointer.
The position of the edit pointer does not
change. For example,
DInsert this line
ENTER
inserts the line.
pL i n e one
ENTER
OL i ne two
ENTER
OLine three
ENTER
inserts three lines.
In str Inserts a line of n copies of the specified string
immediately before the position of the edit
pointer. The position of the edit pointer does
not change. For example,
i40/*/ ENTER
inserts a line containing 40 asterisks. You can
also use the "I" command to insert a line con
taining a single copy of the string. This func
tion is important when you want to use a
macro to insert lines, since the space bar can
not be used within a macro. For example,
i"Line to insert"
ENTER
inserts the line.
7-10
Macro Text Editor / 7
Dn Deletes (removes) n lines from the edit buffer,
starting with the current line. This command
displays the lines to be deleted. For example:
d ENTER
deletes the current line, regardless of the posi
tion of the edit pointer, and displays it.
d 4 ENTER
deletes the current line and the next three
lines.
d * ENTER
deletes everything from the current line to the
end of the buffer.
Kn Kills (deletes) n characters, starting at the
current position of the edit pointer. This com
mand displays all deleted characters. For
,,~"" ~example,
k ENTER
deletes the character at the edit pointer.
k 4 ENTER
deletes the character at the current position of
the edit pointer and the next three characters.
k * ENTER
deletes everything from the current position of
the edit pointer to the end of the buffer.
7-11
OS-9 Commands Reference
En str Extends n lines by adding a string to the end
of each line.
E
extends a line, displays it, and
then moves the pointer past it. For example,
e/this is a comment/ ENTER
adds the string "this is a comment" to the end
of the current line and moves the edit pointer
to the next line.
e 3 / x x ENTER
adds the string xx to the end of the current
line and the next two lines. It moves the
pointer past these lines.
U Unextends (deletes) the remainder of a line
from the current position of the pointer. Use U
to remove extensions, such as comments, from
a line. For example,
u ENTER
deletes all the characters from the current
position of the pointer up to the end of the cur
rent line.
For some practice in using the commands that display text,
manipulate the edit pointer, and insert and delete lines, turn to
Sample Session 1 in this chapter.
7-12
Macro Text Editor / 7
Searching and Substituting
"~ Sn string
Searches for the next n occurrences of
string.
When Edit finds an occurrence, it displays the
line and moves the edit pointer past it. If Edit
does not find the string or if all the occur
rences have been found, the edit pointer does
not move. For example,
s/my string/
ENTER
searches for the next occurrence of "my
string".
s3"strung out"
ENTER
searches for the next three occurrences of
"strung out".
s*/seek and find/
ENTER
searches for all occurrences of "seek and find"
between the edit pointer and the end of the
text.
Cn ,stringl
Changes the next n occurrences of
stringl
to
string2 string2.
When Edit finds
stringl,
it moves the
edit pointer past it and changes
stringl
to
string2,
then it displays the updated line. If it
does not find
stringl
or if all the occurrences
have been found, the edit pointer does not
move. For example,
c/this/that/
ENTER
changes the next occurrence of "this" to
"that".
c2/in/out/
ENTER
changes the next two occurrences of "in" to
"out".
c*!seek and find!sought and
found ! ENTER
changes all occurrences of "seek and find"
that are between the edit pointer and the end
of text to "sought and found".
7-13
OS-9 Commands Reference
An Sets the SEARCH/CHANGE anchor to Col
umn
n.
To find a string that begins in a spe
cific column, set the anchor to the column
position before using the search command to
find it. If you do not include a value for
n,
Edit
assumes Column 1. For example:
a ENTER
finds a string only if it begins in Column 1.
a20
ENTER
finds a string only if it begins in Column 20.
If you use the A command to set the anchor,
this setting remains in effect only for the cur
rent command line. After Edit executes the
command, the anchor automatically returns to
its normal value of zero.
For some practice in using the commands that search and substitute, turn to Sample Session 2 in this chapter.
Miscellaneous Commands
Tn Tabs (moves) the edit pointer to Column
n
of
the current line. If
n
exceeds the line length,
this command extends the line with spaces.
For example,
t ENTER
moves the edit pointer to Column 1 of the cur
rent line.
t S ENTER
moves the edit pointer to Column 5 of the cur
rent line.
7-14
Macro Text Editor / 7
.SHELL
command
line
Lets you use any OS-9 command from within
the editor. The remainder of the command line
following .SHELL passes to the OS-9 Shell for
execution. For example,
. shel l dir /d1
ENTER
calls the OS-9 Shell to print the directory D1.
.5he11 ba5ic09
ENTER
starts BASIC09.
.shell edit
oldfile newfile
restarts the editor.
Mn
Adjusts the amount of memory available for
buffers and macros. If the workspace is full
and the editor does not allow you to enter
more text, increase the workspace size. If you
need only a small amount of the available
workspace, decrease the workspace size so that
other OS-9 programs can use the memory. For
example,
sets the workspace size to 5000 bytes.
m 1 0 0 0 0 ENTER
sets the workspace size to 10000 bytes.
Before leaving Edit, you can increase the
workspace. This decreases the time the editor
takes to copy the input file to the output file,
because the editor can read and write more
data at one time. Edit changes memory in
256-byte pages. For the M command to have
any effect, a new workspace size must differ
from the current size by at least 256 bytes.
The M command does not let you deallocate
any workspace that Edit needs for buffers or
macros.
7-15
OS-9
Commands Reference
.SIZE Displays the size of the workspace and the
amount that has been used. For example:
.size
S21 1 5328
521 is the amount of workspace Edit uses for
buffers and macros. 15328 is the amount of
available memory.
Q Ends editing and returns to the OS-9 Shell. If
you specified files when you started, Edit
writes the text in Buffer 1 to the initial write
file (specified when you start Edit). Next it
copies the remainder of the initial input file
(specified when you start Edit) to the initial
write file. The editor then terminates, and
control returns to the OS-9 Shell.
V mode Turns the verify mode on or off. Edit always
starts with the verify mode on. Therefore, the
editor displays the results of all the commands
for which verify is appropriate. If you do not
want to see the results of commands, turn off
the verify mode by specifying 0 (zero) for
mode. To turn verify back on, specify any nonzero number. For example,
v 0 ENTER
turns off the verify mode.
v 2
ENTER
turns on the verify mode.
v 1 3
ENTER
turns on the verify mode.
If the verify mode is on when you switch to a
macro, it remains on. If you turn off verify
while in the macro, it is restored when you
return to the editor.
?-16
Macro Text Editor / 7
Manipulating Multiple Buffers
.DIR
Bn
Pn
Displays the directory of the editor's buffers
and macros. For example:
BUFFERS:
MACROS:
0
(secondary buffer)
(primary buffer)
S
(another buffer)
MYMACRO
LIST
COPY
Makes buffer
n
the primary buffer. When you
switch from one buffer to another, the old one
becomes the secondary buffer, and the new one
becomes the primary buffer. For example,
makes Buffer 5 the primary buffer. If Buffer 5
does not exist, Edit creates it.
Puts (moves)
n
lines into the secondary buffer.
This command removes the lines from the primary buffer, starting at the position of the
edit pointer, and inserts them into the secondary buffer before the current position of the
edit pointer. It displays the text that is moved.
For example,
ENTER
moves one line to the secondary buffer.
P S ENTER
moves five lines to the secondary buffer.
P
* ENTER
moves all lines that are between the current
position of the edit pointer and the end of text
to the secondary buffer.
7-17
OS-9 Commands Reference
Gn Gets (moves) n lines from the secondary
buffer. This command takes the lines from the
top of the secondary buffer and inserts them
into the primary buffer before the current
position of the edit pointer. Edit then displays
the moved lines. When used with the P com
mand, G moves text from one place to another.
For example,
ENTER
gets one line from the secondary buffer.
9
5 ENTER
gets five lines from the secondary buffer.
9
* ENTER
gets all lines from the secondary buffer.
For some practice in using miscellaneous commands and the
commands that manipulate multiple buffers, turn to Sample Session 3 in this chapter.
Text File Operations
This section of the manual describes the group of commands
related to reading and writing OS-9 text files.
.NEW Gets new text. Use .NEW when editing a file
that is too large to fit into the editor's workspace. .NEW writes out all lines that precede
the current line, then appends an equal
amount of new text to the end of the buffer.
.NEW always writes text to the initial output
file (created when you start the editor) and
always reads text from the initial input file
(specified when you start the editor).
If you have finished editing the text currently
in the buffer, you can "flush" this text and fill
the buffer with new text by moving the edit
pointer to the bottom of the buffer and then
using the . NEW command. For example:
/ . new ENTER
7-18
Macro Text Editor / 7
If you wish to retain part of the text that is
already in the buffer, move the edit pointer to
the first line you wish to retain and then type
. n e w.
This command "flushes" all lines that
precede the edit pointer. It then tries to read
in new text that is the same size as the portion flushed out.
.READ str Prepares an OS-9 text file for reading. str
specifies the pathlist. For example.
. read "myf i le" ENTER
closes the current input file and opens
"myfile" for reading.
You can specify an empty pathlist. For
example,
. read
"" ENTER
closes the current input file and restores the
initial input file (specified when you start the
- editor) for reading.
An open file remains attached to the primary
buffer until you close the file. You can have
more than one input file open at any time by
using the .READ command to open them in
different buffers.
To read these files, switch to the proper buffer,
and then use the R command to read from
that buffer's input file. To close a file, you
must be in the same buffer where the file was
opened.
7-19
OS-9 Commands Reference
.WRITE ,str Opens a new file for writing. The string speci
fies the pathlist for the file you wish to create.
For example,
.write "newfile"
ENTER
closes the current write file and creates one
called "newfile". You can specify an empty
pathlist. For example:
.write ""
ENTER
closes the current write file and restores the
initial write file (specified when you start the
editor).
.WRITE attaches a new write file to the pri
mary buffer that remains attached until you
close the file. You can have more than one
write file open by using . WRITE to open them
in different buffers. To write these files, switch
to the proper buffer. To close a file, you must
be in the same buffer where the file was
opened.
Rn Reads (gets) n lines of text from the buffer's
input file. It displays the lines and inserts
them before the current position of the edit
pointer. For example,
r
ENTER
reads one line from the input file.
r 1 0
ENTER
reads 10 lines from the input file.
r * ENTER
reads the remaining lines from the input file.
If a file contains no more text, the screen
shows the
* E N D 0 F FILE*
message.
?-20
Macro Text Editor / 7
Wn Writes n lines to the output file, starting with
the current line. It displays all lines that are
deleted from the buffer. For example,
w ENTER
writes the current line to the output file.
w S ENTER
writes the current line and the next four lines
to the output file.
w * ENTER
writes all lines from the current line to the
end of the buffer to the output file.
For some practice in using the commands that read and write
OS-9 text files, turn to Sample Session 4 in this chapter.
Conditionals and Command Series Repetition
'' When a command cannot be executed, the editor sets an internal
flag, and the screen shows FAIL. For example, if you try to read
from a file that has no more text, the editor sets the fail flag. A
set fail flag means that the editor cannot execute any more com
mands until Edit encounters one of the following:
· The end of a command line typed from the keyboard.
· The end of the current loop. Any loops that are more
deeply nested are skipped. (See the repeat command.)
· A colon (:) command. Since loops nested deeper than the
current level are skipped, any occurrences of : that are
in a more deeply nested loop are also skipped.
7-21
OS-9 Commands Reference
Following are the commands and conditions that set the fail flag:
< Trying to move the edit pointer beyond the
beginning of the edit buffer.
Trying to move the edit pointer beyond the +
end of the buffer.
S,C Not finding a string that was searched for.
G No text left in the secondary buffer.
R No text left in the read file.
P,W No text left in the primary buffer.
If you specify an asterisk for the repeat count on these commands, Edit does not set the fail flag, because an asterisk usually means continue until there is nothing more to do. The
following commands explicitly set the fail flag if some 'condition
is not true.
.EOF Tests for end-of-file. .EOF succeeds if there is
no more text to read from a file. Otherwise, it
1''`
sets the fail flag.
.NEOF
Tests for not end-of-file. .NEOF succeeds if
there is text to read from the file. Otherwise,
it sets the fail flag.
.EOB Tests for end-of-buffer. .EOB succeeds if the
edit pointer is at the end of the buffer. Other
wise, it sets the fail flag.
.NEOB
Tests for not end-of-buffer. .NEOB succeeds if
the edit pointer is not at the end of the buffer.
Otherwise, it sets the fail flag.
.EOL Tests for end-of-line. This test succeeds if the
edit pointer is at the end of the line. Other
wise, it sets the fail flag. -
.NEOL
Tests for not end-of-line. .NEOL succeeds if
the edit pointer is not at the end of the line.
Otherwise, it sets the fail flag.
.ZERO n
Tests for zero value. .ZERO succeeds if n
equals zero. Otherwise, it sets the fail flag.
7-22
Macro Text Editor / 7
.STAR n
Tests for star (asterisk). .STAR succeeds if n
equals 65,535 ("*"). Otherwise, it sets the fail
flag.
.STR str Tests for string match. .STR succeeds if the
characters at the current position of the edit
pointer match the string. Otherwise, it sets
the fail flag.
.NSTR str Tests for string mismatch. .NSTR succeeds if
the characters at the current position of the
edit pointer do not match the string. Other
wise, it sets the fail flag.
.S Exits and succeeds. This is an unconditional
exit from the innermost loop or macro. The
fail flag clears after the exit.
.F Exits and fails. This is an unconditional exit
from the innermost loop or macro. The fail
flag sets after the exit.
[commands]n
Repeats the commands n times. Left and right
brackets form a loop that repeats the enclosed
commands n times. (The loop must be
repeated at least once.) If you enter the loop
command from the keyboard, it must all be on
one line. If it is part of a macro, however, it
can span several command lines. For example,
Ill 5 ENTER
repeats the L command five times.
Note: This is not the same as L5, which executes the L
command only once and has 5 as its parameter.
[ + ]* Displays lines starting with the next line up
to the end of the buffer and moves the edit
pointer to the end of the buffer. -
This command repeats until the operation
reaches the end of the buffer. Then, when the
command tries to move the edit pointer past
the end of the buffer, Edit sets the fail flag,
terminates the loop, then clears the fail flag.
7-23
OS-9 Commands Reference
commands
Executes the commands following the colon
based on the state of the fail flag. For
example:
FAIL FLAG CLEAR Skips all commands
that
follow
the colon (:)
up to the end of the cur
rent loop or macro.
FAIL FLAG SET Clears the fail flag, and
executes the commands
that
follow
the colon ( : ) .
Below is a command line that deletes all lines
that do not begin with the letter A.
CTRL
07
C . neob f . rstr"A" + : d I
l * ENTER
moves the edit pointer to the beginning of
the buffer. The outer loop tests for the end of
the buffer and terminates the loop when it is
reached.
The inner loop tests for A at the beginning of
the line. If there is an A, the + command is
executed. Otherwise, it executes the D
command.
Below is a command that searches the current
line for "find it". If the command finds the
text, it displays the line. Otherwise, the command line fails and the screen shows
* FAIL *.
L .eol v0 -0 v .f : .5tr"find it"
- 0 . 5 : [>I J * ENTER
.EOL VO -0 V .F tests to determine if the edit
pointer is at the end of the line. If it is, Edit
turns off the verify mode to prevent -0 from
displaying the line. Then it turns verify back
on, and .F ends the loop.
7-24
Macro Text Editor / 7
If the edit pointer is not at the end of the line,
the . STR command searches for "find it" at the
current position of the edit pointer. If it is at
the end of the line, Edit executes the -0 .S
commands. This execution moves the edit
pointer back to the beginning of the line, displays the line, and terminates the loop. Otherwise, the > command moves the edit pointer
to,the next position in the line.
The brackets prevent the command from failing and terminating the main loop if the end
of the buffer is reached.
Edit Macros
Edit
macros are commands you create to perform a specialized
or complex task. For example, you can replace a frequently used
series of commands with a single macro. First, save the series in
a macro. Then each time you need it, type a period followed by
the macro's name and parameters. The editor responds as if you
had typed the series of commands.
Macros consist of two main parts, the header and the body. The
header gives the macro a name and describes the type and order
of its parameters. The body consists of any number of ordinary
commands. (Except for a space character and
ENTER , you
can use
any command in a macro).
Note: Macros cannot create new macros.
To create a macro, first define it with the . MAC command. Then
enter the header and body in the same manner as you enter text
into an edit buffer. When you are satisfied with the macro, close
its definition by pressing
© ENTER . This
command returns you
to the normal edit mode.
Macro Headers. A macro header must be the first line in each
macro. It consists of a name, and a "variable list" that describes
the macro's parameters, if there are any. The name consists of
any number of consecutive letters and underline characters. Following are possible macro names:
del-all
trim-spaces
LIST
CHANGE_X-TO_Y
7-25
OS-9 Commands Reference
Although you can make a macro name any length, it is better to
keep it short, because you must spell it the same way each time
you use it. You can use upper- and lowercase letters or a
mixture.
Using Macros.
Like other commands, you can give parameters
to macros so that they are able to work with different strings
and with different numbers of items. Macros are unable to use
parameters directly. Instead, Edit passes the parameters on to
the commands that make up the macro.
To pass the macro's parameters to these commands, use the
variable list in the macro header to tell each command which of
the macro's parameters to use. Each variable in the variable list
represents the value of the macro parameter in its corresponding
position. Use the corresponding variable wherever the parameter's value is needed.
The two types of variables are numeric and string. A numeric
variable is a variable name preceded by the # character. A
string variable is a variable name preceded by a $ character.
Variable names, like macro names, are composed of any number
of consecutive letters and underline characters. Examples of
numeric variables are:
#N
#ABC
#LONG_NUMBER-VARIABLE
Examples of string variables are:
$A
$B
$STR
$ STR-A
$lower_case_variable_name
The function of the edit macro below is the same as that of the S
command, to search for the next n occurrences of a string.
7-26
Macro Text Editor / 7
The first line of the macro is the macro header. It assigns the
macro's name as SRCH. It also specifies that the macro needs
one numeric parameter (#N) and one string parameter ($STR).
The entire body of the macro is the second line. This example
passes both of the macro's parameters to the S command, which
does the actual searching.
SRCH #N $STR
S #N $STR
Here is an example of how to execute this macro:
. SRCH 1 5
"5 t
r i ng" ENTER
In the next example, the order of the parameter is reversed.
Therefore, when executing the macro, use the reverse order. The
macro structure is:
SRCH $STR #N
S #N $STR
Specify the parameters for the "S" command in the proper order
since it is only the "SRCH" macro that is changed. The following
example shows how to execute this macro. The order of the
parameters corresponds directly to the order of the variables in
the variable list.
. SRCH
"5
t r i ng" 1 5 ENTER
7-27
OS-9 Commands Reference
Macro Commands
Although macro editing has the same functions as text editing,
the macro mode also includes some special commands. The
macro commands you can use are as follows:
!
text Places comments inside a macro. Ignores the
remainder of the line following the ! command.
This command lets you include, as part of a
macro, a short description of what it does.
Comments can help you remember the func
tion of a macro. For example:
t
< > ! Move the pointer to the top of the
buffer.
1*! Display all lines of text.
In this example there are four comments. Two
are empty, and two describe the commands
that precede them.
.macro name
Executes the macro specified by the name fol
lowing the period (.). For example:
. myma c r o ENTER
. 1 i 5 t 0 ENTER
.trim " " ENTER
.merge " f i 1 e-a " file b b " ENTER
.MAC str
Creates a new macro or opens the definition of
an existing one so that it can be edited. To
create a new macro, specify an empty string.
For example,
. ma c "" ENTER
creates a new macro and puts you into the
macro mode.
7-28
Macro Text Editor / 7
The screen shows M: instead of E : when the
editor is in the macro mode. To edit a macro
that already exists, specify the macro's name.
For example,
. ma c "myma c r o"
ENTER
opens the macro "MYMACRO" for editing.
When a macro is open, edit it, or enter its definition with the same commands you use in a
text buffer. After you edit the macro, press [0
ENTER
to close its definition and return to the
edit mode. The first line of the macro must
begin with a name that is not already used in
order to close the definition and return to
Edit.
.SAVE ctrl Saves macros on an OS-9 file.
Strl
specifies a
str2 list of macros to be saved. Separate the macro
names with spaces.
Str2
specifies the pathlist
for the file on which you want to save the
macros. For example:
. 5ave "mymac r o"myf i 1 e"
ENTER
saves the macro "MYMACRO" on the file
"MYFILE".
. 5ave "maca macb macc"mf i le"
ENTER
saves the macros "MACA," "MACE," and
"MACC" on the file "MFILE".
.SEARCH n Searches the text file buffer for the specified
str string. When a match is found, it stops and
displays that line. The
n
option permits a
search for the
nth
occurrence of a string
match. This command is the same as
S n str.
7-29
OS-9 Commands Reference
.LOAD str
Loads macros from an OS-9 file. As each
macro loads, Edit verifies that no other macro
already exists with the same name. If one
does, the macro with the duplicate name does
not load, and Edit skips to the next macro on
the file. Edit displays the names of all macros
it loads. For example,
.load "macrof i le"
ENTER
loads the macros in the file called
MACROFILE.
. 1 oad "myf i 1 e"
ENTER
loads the macros in the file called MYFILE.
.DEL str Deletes the macro specified by the string. For
example,
. d e 1 "myma c r o"
ENTER
deletes the macro called MYMACRO.
. d e 1 " 1 i 5
t " ENTER
deletes the macro called LIST.
MIR Displays the current edit buffer area. All edit
buffers and macros currently in memory are
displayed.
.CHANGE n Changes the occurrence of strl to str2. The
n
strl str2 option permits
n
occurrences of strl to be
changed to str2.
7-30
Macro Text Editor / 7
Ends a macro edit session and returns you to
the normal edit mode. For example:
Search-and-Delete #N $STR
!This example MACRO i5 used to
!check
!the string at the beginning of
!an #N number of lines. If the
!string matches, it will delete
!that line from the text buffer
!file.
!NOTE: The way the editor
!proces5e5 a MACRO cau5e5 it to
!see any parameters in the outer
!loop first. Thus, the #N
!parameter is processed before
!the STR parameter.
i
!Move to Start of
!edit buffer
L !start of outer loop
. neob !test for buffer end
L !start of inner loop
.n5tr $5tr !test for not String
!match
!go to next line if
!no match
!if flag clear Skip
!next command
D !delete line if flag
!set
7 !end of inner loop
J#N !end of outer loop
! End of Macro
For practice in using macro commands, turn to Sample Session 5
in this chapter.
7-31
OS-9 Commands Reference
Sample Session 1
Clear the buffer by deleting its contents.
You Type:
CTRL
07
D·
ENTER
Screen Shows:
^ D
Insert three lines into the buffer. Begin each line with a space,
which is the command for inserting text.
You Type:
pMY FIRST LINE
ENTER
AMY SECOND LINE
ENTER
AMY THIRD LINE
ENTER
Screen Shows:
M Y FIRST LINE
MY SECOND LINE
MY THIRD LINE
Move the edit pointer to the top of the test. The editor always
considers the first character you type a command.
Note:
CTRL
~ always shows " on the screen. Typing - * also
moves the edit pointer to the beginning of a buffer.
YOU
Type:
CTRL
70
ENTER
Screen Shows:
List (display) the first line you inserted into the buffer.
You Type:
L ENTER
Screen Shows:
MY FIRST LINE
Display the first two lines you inserted into the buffer.
You Type:
L 2
ENTER
Screen Shows:
L2
MY FIRST LINE
MY SECOND LINE
Move to the next line and display it.
YOU
Type:
ENTER
Screen Shows:
MY SECOND LINE
Move to the next line and display it.
You Tie:
ENTER
Screen Shows:
M Y THIRD LINE
7-32
Macro Text Editor / 7
Using L, display text beginning at the position of the edit
pointer.
You Type:
Screen Shows:
Insert a line into the buffer.
MY THIRD LINE
Note: In the next sample you see that the insert comes
before the current position of the edit pointer.
You Type:
Screen Shows:
INSERT A LINE
INSERT A LINE
The following command line consists of more than one command.
moves the edit pointer to the top of the text.
L
dis-
plays the text, and the asterisk ( * ) following
L
indicates that text
is displayed through to the end of the buffer.
You Type:
CTRL
Ol
L * ENTER
Screen Shows:
^ L
MY FIRST LINE
MY SECOND LINE
INSERT A LINE
MY THIRD LINE
Show the position of the edit pointer.
YOU
Type:
L
ENTER
Screen Shows:
L
MY FIRST LINE
Move the edit pointer forward two lines and display the lines.
You Type:
+ 2 ENTER
Screen Shows:
+ 2
INSERT A LINE
Display all lines from the edit pointer to the end of the buffer.
YOU
Type:
L * ENTER
Screen Shows:
L
INSERT A LINE
MY THIRD LINE
Move the edit pointer to the end of the buffer.
You Type:
Screen Shows:
Determine if the edit pointer is at the end of text. Since the
screen shows no more lines, the edit pointer is at the end-of-text.
You Type:
L * ENTER
Screen Shows:
L
7-33
OS-9 Commands Reference
Insert two more lines.
You Type.
pF I FTH LINE
ENTER
BLAST LINE
ENTER
Screen Shows:
FIFTH LINE
LAST LINE
Move the edit pointer back one line, and display the line.
YOU
Type:
-2 ENTER
Screen Shows:
- 2
FIFTH LINE
Move the edit pointer back two lines, and display the line.
You Type:
- 3 ENTER
Screen Shows:
- 3
MY SECOND LINE
Move the edit pointer three characters to the right and display
the remainder of the line.
Note: You must put spaces between commands.
You Type:
> 3 L
ENTER
Screen Shows:
> 3 L
SECOND LINE
Display the characters that precede the edit pointer on the cur
rent line.
YOU
Tie:
X ENTER
Screen Shows: x
MY
Move the edit pointer to the end of the current line.
You Type:
+ 0 ENTER
Screen Shows: · a
Determine if the edit pointer is at the end of the line. It is, since
the screen shows no lines.
You Type:
L
ENTER
Screen Shows:
Display the characters that precede the edit pointer on the cur-
rent line.
You Type:
X ENTER
Screen Shows: x
MY SECOND LINE
7-34
Macro Text Editor / 7
Move the edit pointer back to the beginning of the current line.
You Type:
- 0
ENTER
Screen Shows:
- 0
MY SECOND LINE
Determine if the edit pointer is at the beginning of the line.
Since the screen shows no lines, the pointer is at the beginning.
You Type:
X ENTER
Screen Shows:
X
Go to the beginning of the text.
You Type:
CTRL ~7 ENTER
Screen Shows:
Insert a line of 14 asterisks.
You Type:
I 1 4
~~ * ~~ ENTER
Screen Shows:
I 14
Insert an empty line.
You Type:
I "" ENTER
Screen Shows:
Pool
Move to the top of the text, and display all lines in the buffer.
You Type:
CTRL 70
L * ENTER
Screen Shows:
^ L *
**************
MY FIRST LINE
MY SECOND LINE
INSERT A LINE
MY THIRD LINE
FIFTH LINE
LAST LINE
Move the edit pointer forward two lines.
You Type:
+ 2
ENTER
Screen Shows:
+ 2
MY FIRST LINE
Extend the line with XXX.
You Type:
Ell X X V
ENTER
Screen Shows:
Ell X X X
I I
MY FIRST LINE XXX
Display the current line.
7-35
OS-9 Commands Reference
Note: The previous E command moved the edit pointer to
the next line.
You Type:
L
ENTER
Screen Shows:
L
MY SECOND LINE
Extend three lines with YYY.
You Type:
E 3 "OY Y Y " ENTER
Screen Shows:
E 3" Y Y Y "
MY SECOND LINE YYY
INSERT A LINE YYY
MY THIRD LINE YYY
Move back 2 lines.
You Type:
- 2 ENTER
Screen Shows:
- 2
INSERT A LINE YYY
Move the edit pointer to the end of the line and then move the
edit pointer back four characters. Display the current line, start
ing at the edit pointer.
You Type:
+ 0 < 4 L
ENTER
Screen Shows:
+ 0 < 4 L
YYY
Truncate the line at the current position of the edit pointer. This
command removes the YYY extension.
You Type:
U ENTER
Screen Shows:
U
INSERT A LINE
Go to the top of the text and display the contents of the buffer.
You Type:
CTRL ~7
L * ENTER
Screen Shows:
^ L
**************
MY FIRST LINE XXX
MY SECOND LINE YYY _
INSERT A LINE
MY THIRD LINE YYY
FIFTH LINE
LAST LINE
7-36
Macro Text Editor / 7
Delete the current line and the next line.
You Type:
D2 ENTER
Screen Shows: n
2
Move the edit pointer forward two lines.
You Type:
Screen Shows:
Delete this line.
You Type:
Screen Shows:
Display the current line.
You Type:
Screen Shows:
+ 2 ENTER
+2
INSERT A LINE
D
ENTER
D
INSERT A LINE
MY THIRD LINE YYY
Move the edit pointer to the right three characters and display
the test.
YOU
Type:
> 3
L ENTER
Screen Shows:
> 3 L
THIRD
LINE YYY
Kill (delete) the 11 characters that constitute THIRD LINE.
You Type:
K11
ENTER
Screen Shows:
THIRD LINE
Go to the beginning of the line and display it.
You Type:
Screen Shows:
- 0
ENTER
-0
MY YYY
Concatenate (combine) two lines. Move the edit pointer to the
end of the line; delete the character at the end of the line; move
the edit pointer back to the beginning of the lines. Display the
line.
You Type:
Screen Shows:
+ 0 K - 0
ENTER
9 K -6
MY YYYFIFTH LINE
Separate the two lines by inserting an end-of-line character.
YOU
Type:
>6 I / / ENTER
Screen Shows:
> 6 I / /
MY YYY
7-37
OS-9 Commands Reference
Note: The end of line character is inserted before the current
position of the edit pointer.
You Type:
L ENTER
Screen Shows:
FIFTH LINE
Sample Session 2
Clear the buffer by deleting its contents.
You Type:
CTRL
07
D * ENTER
Insert lines.
You Type:
GONE TWO THREE 1 . 0
ENTER
BONE
ENTER
DOTWO ENTER
00I7THREE
ENTER
BONE TWO THREE 2.0
ENTER
BONE
ENTER
OOTWO ENTER
OOEITHREE
ENTER
GONE TWO THREE 3.0
ENTER
Screen Shows:
ONE TWO THREE 1.0
ONE
TWO
THREE
ONE TWO THREE 2.0
ONE
TWO
THREE
ONE TWO THREE 3.0
Go to the top of the text, and display all lines in the buffer.
You Type:
CTRL QQ L* ENTER
Screen Shows:
^ LONE TWO THREE 1.0
ONE
TWO
THREE
ONE TWO THREE 2.0
ONE
TWO
THREE
ONE TWO THREE 3.0
7-38
Macro Text Editor / 7
Search for the next occurrence of TWO.
You Type:
S "TWO" ENTER
Screen Shows:
S - · T W
o
I
ONE TWO THREE 1.0
Search for all occurrences of TWO that are between the edit
pointer and the end of the buffer.
You Type:
S * /TWO / ENTER
Screen Shows:
S * / T W
o /
ONE TWO THREE 1.0
TWO
ONE TWO THREE 2.0
TWO
ONE TWO THREE 3.0
Go to the top of the buffer, and change the first occurrence of
THREE to ONE.
You Type:
CTRL
0
C /THREE / 0 N E / ENTER
Screen Shows:
^ C /THREE / 0 N E /
ONE TWO ONE 1.0
Move the edit pointer to the top of the buffer. Set the anchor to
Column 2, and then use the search command to find each occurrence of TWO that begins in Column 2. Skip all other
occurrences.
You Type:
CTRL
O7
A 2 S * / T W 0 / ENTER
Screen Shows:
" A 2 S * / T W 0 /
TWO
TWO
Move the edit pointer to the top of the buffer. Set the anchor to
Column 1, and change each occurrence of ONE that begins in
that column to XXX.
Note: ONE in Line 1 is not changed, since it does not begin
in Column 1.
You Type:
CTRL
07
A C * / 0 N E / X X X / ENTER
Screen Shows:
^ A C * / 0 N E / X X X /
X X X TWO ONE 1 . 0
XXX
XXX TWO THREE 2.0
'~ XXX
XXX TWO THREE 3.0
7-39
OS-9 Commands Reference
Go to the top of the buffer, and display the text.
You Type:
CTRL 70L · ENTER
Screen Shows:
XXX TWO ONE 1.0
XXX
TWO
THREE
XXX TWO THREE 2.0
XXX
TWO
THREE
XXX TWO THREE 3.0
Change the remaining ONE to XXX.
Note: The anchor is no longer set. It is reset to zero after
each command is executed.
YOU
Type:
C / 0 N E / X X X / ENTER
Screen Shows:
C / 0 N E / X X X
XXX TWO XXX 1.0
Move to the beginning of the current line.
You Type:
- 0
ENTER
Screen Shows:
- e
XXx TWO
xxx
1.e
Change three occurrences of XXX to ZZZ.
You Type:
C3/XXX/ZZZ/ ENTER
Screen Shows:
C 3 / X X X / ZZZ
ZZZ TWO XXX 1.6
ZZZ TWO ZZZ 1.0
ZZZ
Sample Session 3
Clear the buffer by deleting its contents:
You Type:
CTRL ~7 D · ENTER
7-40
Macro Text Editor / 7
Display the directory of buffers and macros. The dollar sign ($)
identifies the secondary buffer as Buffer 0. The asterisk (*) identifies the primary buffer as Buffer 1. Edit has no macros defined.
This is the initial environment when you start Edit.
You Type:
. D I R
ENTER
Screen Shows: . n
t R
BUFFERS:
8 0
MACROS:
Insert some lines into Buffer 1 so that later you can identify it.
You Type:
OBUFFER ONE 1 . 0
ENTER
OBUFFER ONE 2.0
ENTER
OBUFFER ONE 3.0
ENTER
OBUFFER ONE 4.6
ENTER
Screen Shows:
Display the text in Buffer 1.
You Type:
Screen Shows:
BUFFER ONE 1.0
BUFFER ONE 2.0
BUFFER ONE 3.0
BUFFER ONE 4.0
CTRL
[D
L· ENTER
^L·
BUFFER ONE 1.0
BUFFER ONE 2.0
BUFFER ONE 3.0
BUFFER ONE 4.0
Make Buffer 0 the primary buffer. Buffer 1 becomes the second
ary buffer.
You Type:
H 0 ENTER
Screen Shows:
H
e
Display the directory of buffers and macros.
Note: The symbols identifying the buffers are now reversed.
You Tie:
. DIR
ENTER
Screen Shows:
. DIR
BUFFERS:
MACROS:
7-41
OS-9 Commands Reference
Insert some lines into Buffer 0.
You Type:
OBUFFER ZERO 1 . 0
ENTER
pBUFFER ZERO 2.0
ENTER
OBUFFER ZERO 3.0
ENTER
OBUFFER ZERO 4.0
ENTER
Screen Shows:
BUFFER ZERO 1 . 0
BUFFER ZERO 2.0
BUFFER ZERO 3.0
BUFFER ZERO 4.0
Display the text in Buffer 0.
You Type:
CTRL ~7 L * ENTER
Screen Shows:
^ L *
BUFFER ZERO 1.0
BUFFER ZERO 2.0
BUFFER ZERO 3.0
BUFFER ZERO 4.0
Switch to Buffer 1.
You Type:
B
ENTER
Screen Shows:
B
Display the text in Buffer 1.
You Type:
CTRL O7 L * ENTER
Screen Shows:
^ L *
BUFFER ONE 1.0
BUFFER ONE 2.0
BUFFER ONE 3.0
BUFFER ONE 4.0
Move the edit pointer to Line 3 in this buffer.
You Type:
+ 2
ENTER
Screen Shows:
+ 2
BUFFER ONE 3.0
Switch to Buffer 0.
You Type:
B 0
ENTER
Screen Shows:
B 0
Display the text in Buffer 0.
You Type:
L * ENTER
Screen Shows:
L *
BUFFER ZERO 1 .0
BUFFER ZERO 2.0
BUFFER ZERO 3.0
BUFFER ZERO 4.0
7-42
Macro Text Editor / 7
Move the edit pointer to Line 2 in this buffer.
YOU
Type:
+ ENTER
Screen Shows:
BUFFER ZERO 2.0
Switch to
Buffer 1.
You Type:
H ENTER
Screen Shows:
s
Display the text in Buffer 1 from the current position of the edit
pointer.
Note:
The position of the edit pointer has not changed since
you switched to Buffer 0.
You Type:
Screen Shows:
L · ENTER
L·
BUFFER ONE 3.0
BUFFER ONE 4.0
Switch to Buffer 0.
You Type:
H0
ENTER
Screen Shows:
H
e
Display the text in Buffer 0 from the current position of the edit
pointer.
Note:
The position of the edit pointer has not changed since
you switched to Buffer 1.
You Type:
Screen Shows:
L*
BUFFER ZERO 2.0
BUFFER ZERO 3.0
BUFFER ZERO 4.0
Delete the contents of Buffer 0.
You Type:
CTRL
07
D
* ENTER
Screen Shows:
^ D
BUFFER ZERO 1
BUFFER ZERO 2
BUFFER ZERO 3.0
BUFFER ZERO 4.0
Make Buffer 1 the primary buffer and Buffer 0 the secondary
buffer.
You Type:
Screen Shows:
H
0
0
7-43
OS-9 Commands Reference
Move two lines from the primary buffer (Buffer 1) into the sec-
ondary buffer (Buffer 0).
You Type:
CTRL ~7
P 2
ENTER
Screen Shows:
^ P 2
BUFFER ONE 1.0
BUFFER ONE 2.0
Switch to Buffer 0, and show that the lines were moved to it.
You Type:
B 0
CTRL ~7 L * ENTER
Screen Shows:
B 0 ^ L *
BUFFER ONE 1.0
BUFFER ONE 2.0
Switch to Buffer 1. Go to the bottom of the buffer, and get the
text out of the secondary buffer.
You Type:
B / G * ENTER
Screen Shows:
B / G *
BUFFER ONE 1.0
BUFFER ONE 2.0
Show the contents of the buffer.
Note: The order of the lines is changed as a result of mov-
ing the text.
You Type:
CTRL O7 L * ENTER
Screen Shows:
^ L *
BUFFER ONE 3.0
BUFFER ONE 4.0
BUFFER ONE 1.0
BUFFER ONE 2.0
Move two lines into the secondary buffer.
You Type:
P 2
ENTER
Screen Shows:
P 2
BUFFER ONE 3.0
BUFFER ONE 4.0
Move to the bottom of the buffer, and get the lines back out of
the secondary buffer.
You Type:
/ G * ENTER
Screen Shows:
/ G *
BUFFER ONE 3.0
BUFFER ONE 4.0
7-44
Macro Text Editor / 7
Show that the order of the lines is restored.
You Type:
CTRL 7~
L
Screen Shows:
L
BUFFER ONE 1.0
BUFFER ONE 2.0
BUFFER ONE 3.0
BUFFER ONE 4.0
Sample Session 4
Clear the buffer by deleting its contents:
YOU
Type:
CTRL 07
D * ENTER
Enter some lines of text.
You Type:
DL I N E 0 N E
ENTER
OSECOND LINE OF TEXT
ENTER
OTH I RD LINE OF TEXT
ENTER
OFOURTH LINE
ENTER
OFIFTH LINE
ENTER
DL A S T LINE
ENTER
Screen Shows:
LINE ONE
SECOND LINE OF TEXT
THIRD LINE OF TEXT
FOURTH LINE
FIFTH LINE
LAST LINE
Open the file Oldfile for writing.
You Type:
. WRITE"oldfile"
ENTER
Screen Shows:
WRITE"oldfile"
Write all lines to the file.
YOU
Type:
CTRL
al
W * ENTER
Screen Shows: ^ w
LINE ONE
SECOND LINE OF TEXT
THIRD LINE OF TEXT
FOURTH LINE
FIFTH LINE
LAST LINE
*END OF TEXT*
Close the file.
You Type:
. WRITE//
ENTER
Screen Shows:
. WRITE//
7-45
OS-9 Commands Reference
Verify that the buffer is empty.
You Type:
CTRL ~7
L * ENTER
Screen Shows:
^ L
Open the file Oldfile for reading.
You Type:
. READ"oldfile"
ENTER
Screen Shows:
. READ"oldfile"
Create a new file called Newfile for writing.
You Type:
. WRITE"newfile"
ENTER
Screen Shows:
WRITE"newfile"
Read four lines from the input file. The screen shows the lines as
they are read in.
You Type:
R 4
ENTER
Screen Shows:
R 4
LINE ONE
SECOND LINE OF TEXT
THIRD LINE OF TEXT
FOURTH LINE
Read all the remaining text from the file. The screen shows the
lines. When there is no more text, the screen shows the
* E N D 0 F
F I L E
* message.
You Type:
R * ENTER
Screen Shows:
R *
LINE FIVE
LAST LINE
*END OF FILE*
Go to the top of the buffer, and display the text to make sure it
is inserted into the buffer.
You Type:
CTRL 7~
L * ENTER
Screen Shows:
^ L *
LINE ONE
SECOND LINE OF TEXT
THIRD LINE OF TEXT
FOURTH LINE _
FIFTH LINE
LAST LINE
7-46
Macro Text Editor / 7
Write three lines to the output file, and display the lines.
You Type:
W 3 ENTER
Screen Shows:
W 3
LINE ONE
SECOND LINE OF TEXT
THIRD LINE OF TEXT
Move to the next line and display it.
ENTER
You Type: +
0
Screen Shows:
FIFTH LINE
Show that when writing lines, the editor starts at the current
line and not at the top of the buffer.
You Type:
W ENTER
Screen Shows:
W
FIFTH LINE
Go to the top of the buffer, and display the text to be sure that
the lines were written to the output file.
You Type:
CTRL ~7
L * ENTER
Screen Shows:
FOURTH LINE
LAST LINE
Clear the buffer.
You Type:
CTRL O7
D * ENTER
Screen Shows:
^ D *
FOURTH LINE
LAST LINE
Switch to Buffer 2. Open the input file Oldfile, and read two
lines from it.
You Type:
H2 . REAY'oldfile" R2
ENTER
Screen Shows:
B2 READ"oldfile" R2
LINE ONE
SECOND LINE OF TEXT
Switch to Buffer 1. Open the input file Oldfile and read one -line
of text.
You Type:
H . READ"oldfile" R
ENTER
Screen Shows:
H READ"oldfile" R
LINE ONE
7-47
OS-9 Commands Reference
Switch to Buffer 2, and read one line.
Note: Your place in the file was not lost.
You Type:
B 2 R
ENTER
Screen Shows:
B 2 R
THIRD LINE OF TEXT
Switch to Buffer 1, and read one line of text.
Note: Your place in the file was not lost.
You Type:
B R
ENTER
Screen Shows:
B R
SECOND LINE OF TEXT
Switch to Buffer 2, and delete its contents.
You Type:
B 2
CTRL 07
D * ENTER
Screen Shows:
B 2 ^ D *
LINE ONE
SECOND LINE OF TEXT
THIRD LINE OF TEXT
Insert some extra lines into the buffer.
You Type:
DEXTRA LINE ONE
ENTER
DEXTRA LINE TWO
ENTER
Screen Shows:
EXTRA LINE 0 N E
EXTRA LINE TWO
Try to write B2 buffer to file. It fails because you have not
opened a file in this buffer.
You Type:
CTRL ~7 W * ENTER
Screen Shows:
^ W *
*FILE CLOSED*
Close the file for Buffer 1, and return to Buffer 2.
You Type:
B . WRITE// B 2
ENTER
Screen Shows:
B . WRITE// B 2
Open the old "write" file for reading, and then read it back in.
You Type:
. READ"newfile" R * ENTER
Screen Shows:
READ"newfile" R*
LINE ONE
SECOND LINE OF TEXT
THIRD LINE OF TEXT
FIFTH LINE
*END OF FILE*
7-48
Macro Text Editor / 7
Display the contents of the buffer.
Note: It read the file into the beginning of the buffer, since
that was the position of the edit pointer.
You Type:
CTRL 7~
L * ENTER
Screen Shows:
^ L
LINE ONE
SECOND LINE OF TEXT
THIRD LINE OF TEXT
FIFTH LINE
EXTRA LINE ONE
EXTRA LINE TWO
Sample Session 5
Delete all text from the edit buffer.
You Type:
CTRL 07
D * ENTER
Insert three lines.
You Type:
pL I N E ONE
ENTER
OL I NE TWO
ENTER
OL I NE THREE
ENTER
Screen Shows:
LINE 0 N E
LINE TWO
LINE THREE
Create a new macro using an empty string.
You Type:
. MAC//
ENTER
Screen Shows:
M
Display the contents of the macro mode, which is now open.
Note: The
E
prompt is now
M.
You Type:
CTRL ~7
L * ENTER
Screen Shows:
^ L *
Define the macro.
You Type:
EF I ND
ENTER
OS"TWO" ENTER
Screen Shows:
FIND
,~ S"TWO"
Display the contents of the macro.
You Type:
CTRL ~7
L * ENTER
Screen Shows:
^ L *
FIND
S"TWO"
7-49
OS-9 Commands Reference
Close the macro's definition.
You Type:
Q ENTER
Screen Shows:
E
Display the directory of buffers and macros.
You Type:
. D I R
ENTER
Screen Shows:
. D I R
BUFFERS:
$ 0
1
MACROS:
FIND
Display the contents of the edit buffer.
You Type:
CTRL 70L * ENTER
Screen Shows:
^ L *
LINE ONE
LINE TWO
LINE THREE
Use the FIND macro to find the string TWO.
You Type:
. FIND
ENTER
Screen Shows:
. FIND
LINE TWO
Reopen the definition of the FIND macro.
You Type:
. MAC/FIND/
ENTER
Screen Shows:
. MAC/FIND/
M:
Show that the macro is still intact.
You Type:
CTRL ~7
L * ENTER
Screen Shows:
^ L *
FIND
S"TWO"
Add the numeric parameter and the string parameter to the
macro's header.
You Type:
C /FIND /FIND # N $ S T R / ENTER
Screen Shows:
C /FIND /FIND # N $ S T R /
FIND #N $STR
Move to the second line of the macro.
You Type:
+ ENTER
Screen Shows: +
S"TWO"
7-50
Macro Text Editor / 7
Give the macro's parameters to the S command. Now the FIND
macro will perform the same function as the S command.
You Type:
C / "TWO" / # N $ STR / ENTER
Screen Shows:
C/11TWO11/ #N $STR
S #N $STR
Close the macro's definition.
You Type:
Q ENTER
Screen Shows:
E
Display the contents of the edit buffer.
You Type:
CTRL
70
L * ENTER
Screen Shows:
^ L *
LINE ONE
LINE TWO
LINE THREE
Use the FIND macro to find the next two occurrences of LINE.
You Type:
. FIND 2 /LINE/
ENTER
Screen Shows:
. FIND 2 /LINE/
LINE ONE
LINE TWO
Create a new macro.
You Type:
. MAC//
ENTER
Screen Shows:
. MAC//
M:
Define the macro FIND-LINE, which performs the same function as the S command except that it returns the edit pointer to
the head of the line after finding the last occurrence of STR.
You Type:
O F I N D_L I N E # N $ S T R
ENTER
Screen Shows:
FIND-LINE #N $STR
You Type:
E S # N $ S T R
ENTER
Screen Shows:
S # N $ S T R
Turn off the verify mode.
You Type:
OV 0 ENTER
Screen Shows:
v
0
Move the edit pointer to the first character of the current line.
You Type:
- 0 ENTER
Screen Shows:
- 0
7-51
OS-9 Commands Reference
Close the macro's definition.
You Type:
D ENTER
Screen Shows:
a
E:
Display the contents of the edit buffer.
You Type:
CTRL ~7 L · ENTER
Screen Shows:
^ LLINE ONE
LINE TWO
LINE THREE
Use the FIND-LINE macro to search for the string TWO.
You Type:
. FIND-LINE/TWO/
ENTER
Screen Shows:
. FIND-LINE/TWO/
LINE TWO
Show that the FIND-LINE macro left the edit pointer at the
head of the line.
You Type:
L
ENTER
Screen Shows:
LINE TWO
Create a new macro.
You Type:
. MAC//
ENTER
Screen Shows:
. MAC//
M:
7-52
Macro Text Editor / 7
Use the exclamation point (!) command to comment itself. Type
the following:
CONVERT_TO_L I NES #N
ENTER
!This i s a comment
ENTER
! ENTER
!This macro converts the next n
ENTER
!space characters to new line
ENTER
!characters.
ENTER
V0 !Turn verify mode off
ENTER
!to prevent intermediate results
ENTER
!from being displayed.
ENTER
! ENTER
t ! Begin loop
ENTER
.SEARCH/ / !Search for the space character.
ENTER
I// !Insert empty line (new line character).
ENTER
- !Hack u P one 1 i n e . ENTER
C/ // !Delete the next space character.
ENTER
L + !Show line, move past it.
ENTER
J #N !End of loop. Repeat #N times.
ENTER
Close the macro's definition.
You Type:
Q ENTER
Screen Shows:
Q
E:
Display the contents of the edit buffer.
You Type:
CTRL
L * ENTER
Screen Shows:
^ L
LINE ONE
LINE TWO
LINE THREE
Convert all space characters to new line characters.
Note: The loop stops when the C command in the macro
cannot find a space to delete.
You Type:
. CONVERT-TO-LINES * ENTER
Screen Shows:
CONVERT-TO-LINES *
LINE
LINE
LINE
7-53
OS-9 Commands Reference
Display the contents of the edit buffer.
You Type:
CTRL L * ENTER
Screen Shows:
^ L
LINE '~
ONE
LINE
TWO
LINE
THREE
7-54
Macro Text Editor / 7
Edit Quick Reference Summary
EDIT OS-9
loads the editor and starts it without
creating any read or write files. Perform text
file operations by opening files after the editor
is running.
EDIT
newfile OS-9
loads the editor and starts it. If
newfile
does not exist, Edit creates it and makes it the
initial write ale. Although this command does
not create an initial read file, you can open
read files after starting Edit.
EDIT oldfile OS-9 loads
the editor and starts it, making
the initial read file oldfile. The editor creates
a new file called SCRATCH as the initial
write file. When the edit session is complete,
Edit deletes
oldfile
and renames SCRATCH to
old fate.
EDIT oldfile OS-9
loads the editor and starts it. The initial
newflle
read file is oldfile. The editor creates a file
called
newfile
as the initial write file.
Edit Commands
MACRO
Executes the macro specified by the name fol
lowing the period (.).
! Places comments inside a macro, and ignores
the remainder of the command line.
D Inserts a line before the current position of the
edit pointer.
ENTER
Moves the edit pointer to the next line, and
displays it.
+n Moves the edit pointer forward n lines and dis
plays the line.
-n Moves the edit pointer backward n lines and
displays the line.
+0 Moves the edit pointer to the last character of
the line.
7-55
OS-9
Commands Reference
-0 Moves the edit pointer to the first character of
the current line and displays it.
>n
Moves the edit pointer forward
n
characters.
<n
Moves the edit pointer backward n characters.
CTRL 0
or 0 for Moves the edit pointer to the beginning of the
external text.
terminals
/ Moves the edit pointer to the end of the text.
[commands]
n
Repeats the sequence of commands between
the two brackets n times.
· Skips to the end of the innermost loop or
macro if the fail flag is not on.
An
Sets the SEARCH/CHANGE anchor to Col
umn
n,
restricting searches and changes to
those strings starting in Column
n.
This com
mand remains in effect for the current com
mand line.
AO
Returns the anchor to the normal mode of
searching so that strings are found regardless
of the column in which they start.
Bn
Makes buffer
n
the primary buffer.
Cn strl str2
Changes the next
n
occurrences of strl to str2.
Dn
Deletes
n
lines.
En str
Extends (adds the string to the end of) the
next
n
lines.
Gn
Gets
n
lines from the secondary buffer, starting from the top. Inserts the lines before the
current position in the primary buffer.
In str
Inserts a line containing
n
copies of the string
before the current position of the edit pointer.
Kn Kills
n
characters starting at the current
position of the edit pointer.
Ln
Lists , (displays) the next
n
lines, starting at
the current position of the edit pointer.
7-56
Macro Text Editor / 7
Mn Changes workspace (memory) size to
n
bytes .
Pn Puts (moves)
n
lines from the position of the
edit pointer in the primary buffer to the posi
tion of the edit pointer in the secondary buffer.
Quits editing (and terminates editor). If you
specified a file(s) when you entered Edit,
Buffer 1 is written to the output file. The
remainder of the input file is copied to the out
put file. All files are closed.
Rn Reads
n
lines from the buffer's input file.
Sn str Searches for the next
n
occurrences of the
string.
Tn Tabs to Column
n
of the present line. If
n is
greater than the line length, Edit extends the
line with space.
U Unextends (truncates) a line at the current
position of the edit pointer.
V mode
Turns the verify mode on or off.
Wn Writes
n
lines to the buffer's output file.
Xn Displays
n
lines that precede the edit position.
The current line is counted as the first line.
Pseudo Macros
.CHANGE n Changes
n
occurrences of strl to str2.
ctrl- str2
.DEL str Deletes the macro specified by str.
.DIR Displays the directory of buffers and macros.
.EOB Tests for the end of the buffer.
.EOF Tests for the end of the file.
.EOL Tests for the end of the line.
.F Exits the innermost loop or macro and sets the
fail flag.
.LOAD str Loads macros from the path specified in the
string.
7-57
OS-9 Commands Reference
.MAC str
Opens the macro specified by the string for
definition. If you give an empty string, Edit
creates a new macro.
.NEOB
Tests for not end of buffer.
.NEOL Tests for not end of file.
.NEW Writes all lines up to the current line to the
initial output file, and then attempts to read
an equal amount of text from the initial input
file. The text read-in is appended to the end of
the edit buffer.
.NSTR str Tests to see if string does not match the char
acters at the current position of the edit
pointer.
.READ str Opens an OS-9 text file for reading, using
string as the pathlist.
.S Exits the innermost loop or macro and suc
ceeds (clears the fail flag).
.SEARCH
n
Searches for
n
occurrences of str.
str
.SAVE ctrl
Saves the macros specified in strl on the file
str2 specified by the pathlist in str2.
.SHELL
Calls OS-9 shell to execute the command line.
command line
.SIZE Displays the size of memory used and the
amount of memory available in the workspace.
.STAR
n
Tests to see if
n
equals asterisk (infinity).
.STR str Tests to see if string matches the characters at
the current position of the edit pointer.
.WRITE str Opens an OS-9 text for writing, using str as a
pathlist.
.ZERO
n
Tests
n
to see if it is zero.
C Starts at a macro loop; press
CTRL
(E.
Ends at a macro loop; press
CTRL
7-58
Macro Text Editor / 7
Moves edit pointer to beginning of buffer;
press
cTR~
ID.
Editor Error Messages
BAD MACRO You did not begin the first line in a macro
NAME with a legal name. You can close the definition
of a macro after you give it a legal name.
BAD
NUMBER
BAD VAR
NAME
BRACKET
MISMATCH
BREAK
DUPL
MACRO
END OF
FILE
FILE
CLOSED
MACRO IS
OPEN
MISSING
DE LIM
NOT FOUND
You have entered an illegal numeric parameter, probably a number greater than 65,535.
You have specified an illegal variable name,
omitted the variable name, or included a $ or
# character in the commands parameter list.
You have not entered brackets in pairs or the
brackets are nested too deeply.
You pressed
CTRL
© or
CTRL © to
interrupt
the editor. After printing the error message,
the editor returns to command entry mode.
You attempted to close a macro definition with
an existing macro name. Rename the macro
before trying to close its definition.
You are at the end of the edit buffer.
You tried to write to a file that is not open.
Either specify a write file when starting the
editor from OS-9, or open an output file using
the . WRITE pseudo macro.
You must close the macro definition before
using the command.
The editor could not find a matching delimiter
to complete the string you specified. You must
put the entire string on one line.
The editor cannot find the specified string or
macro.
7-59
OS-9 Commands Reference
UNDEFINED You used a variable that is not specified in the
VAR macro's definition parameter list. A variable
parameter can be used only in the macro in
which it is declared.
WHAT ?? The editor does not recognize a command. You
typed a command that does not exist or mis
spelled a name.
WORKSPACE The buffer did not have room for the text you
FULL want to insert. Increase the workspace, or
remove some text.
7-60