SPECWORD 48/128
by Stuart Nicholls
from ZX Computing Jan,Feb,Mar.1987


[**WARNING**                                                             ]
[The RAMTOP for this program is set so low that after loading there are  ]
[only a few dozen bytes of memory free, and the program soon crashes with]
[an "Out of memory" error whatever option is tried. Because of this error]
[I haven't tested any of the program options.                            ]
[It might work better in 48K mode by first deleting all the RAMdisk lines]
[as mentioned below, but I expect that will just postpone the inevitable.]
[It would seem that the version of the program printed in the magazine   ]
[was not the final working version used by the programmer; a typical sort]
[of type-in screw-up.                                                JimG]


A menu driven word processor for both 48 and 128 Spectrums by Stuart Nicholls.


This is a word processor that will meet the needs of most home users.
Over three parts Specword will build up into a word processing program
with many advanced features. Part 3 contains a complete operating manual.


Features

Specword has insert / overwrite modes, wordwrap, find, word count, block
delete / move / copy / print, redefinable Centronics control codes (30),
16K text space (blank lines only occupy 1 character space), lines of ANY
length from one character to the full text length, margins, thirty one
setable TABS, supports both the ZX printer and most Centronics printers
(with built in software for the Kempston interface) and RAM! file
facilities for the 128K Spectrum.


Entering and Saving Specword

Specword 48/+/128K can be entered easily using the following procedure.

1. 128K Spectrum owners should type in the BASIC LISTING AS LIST 1. 48K
Spectrum owners will have to leave out the lines containing the
instructions for RAM FILE loading and saving etc. ie. lines 2220, 2410,
3620, 6510 & 6550. The program will work on their computers without
these lines as the RAM FILE options are not available to them.

2. SAVE the BASIC program using SAVE "WP48/+/128".

3. Using the HEXLOADER / HEXDUMP dual purpose program (to be published
in part 2) enter the machine code as HEXDUMP LIST 2.

REMEMBER TO RESET RAMTOP TO START ADDRESS-1 BEFORE RUNNING THIS
HEXLOADER (ie. ENTER CLEAR 33535 AS A DIRECT COMMAND FOR LIST 2).

The last byte in each line is the checksum byte, this being the sum of
the previous 8 bytes modulo 256. The code should be entered one LINE at
a time as a block of 18 characters (8 bytes + checksum) WITH NO SPACES
BETWEEN THE CHARACTERS. To end the HEXLOADER program enter ZZ after the
checksum byte. This can be done after any line in the dump and a
printout of the number of bytes entered will be given (allowing you to
save the block 'so far') and the last address. You will then be able to
continue entering code from where you left off.

The HEXLOADER program will error trap ANY incorrect line inputs and
prompt you to re-enter wrongly keyed in lines.

4. SAVE this block of code as "code1" CODE 33536,9407.

5. Using the same HEXLOADER enter the machine code as the HEXDUMP LIST 3.

6. SAVE this block of code as "code2" CODE 44800,2520.

7. When you are happy that all has been saved and verified then RESET
your Spectrum and enter CLEAR 32767 as a direct command.

8. LOAD the BASIC program.

9. LOAD the CODE code1.

10. LOAD the CODE code2.

11. FINALLY (if you have managed to get this far without your fingers
dropping off), SAVE the complete program using: SAVE "WP48/+/128" LINE
9800: SAVE "specode128" CODE 32768,14600.

12. Should any of the functions not work then the machine code can be
checked using the HEXLOADER / HEXDUMP dual purpose program. The HEXDUMP
option will print out to the screen or printer any block of memory in
the same form as the HEXDUMP LISTS 2 and 3. (The easiest way to check
the code is to compare checksum bytes).


= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =


Part two of a menu driven word processor
for both 48 and 128 Spectrums by Stuart Nicholls.


In last month's article you received the Basic program. Now it's time to
begin the machine code section.

Using the HEXLOADER / HEXDUMP dual purpose program enter the machine
code as HEXDUMP LIST 2.

Remember to reset RAMTOP to start address-1 before running this
hexloader (ie. after clear 33535 as a direct command for list 2).

The last byte in each line is the checksum byte, this being the sum of
the previous 8 bytes modulo 256. The code should be entered one LINE at
a time as a block of 18 characters (8 bytes + checksum) WITH NO SPACES
BETWEEN THE CHARACTERS. To end the Hexloader program enter ZZ after the
checksum byte. This can be done after any line in the dump and a
printout of the number of bytes entered will be given (allowing you to
save the block 'so far') and the last address. You will then be able to
continue entering code from where you left off.

The HEXLOADER program will error trap ANY incorrect line inputs and
prompt you to re-enter wrongly keyed in lines.

SAVE this block of code as "code1" CODE 33536,9407.

Next month's article contains the final part of the Machine Code and the
full operating manual for Specword.


= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =


The third and final part of Stuart Nicholls' menu driven word processor
including the operating manual.


This month we put the finishing touches to Specword with the final chunk
of machine code followed by full instructions on operating the utility.

If you have followed the program through you should by now have saved a
BASIC listing, and a machine code listing (HEXDUMP LIST TWO).

Full instructions on entering and saving Specword were printed in Part 1
(ZX January) but to recap - Using the HEXLOADER used to enter LIST TWO
last month enter this month's machine code as HEXDUMP LIST 3.

Save this block of code as "code2" CODE 44800,2520.

When you are happy that all has been saved and verified then reset your
Spectrum and enter CLEAR 32767 as a direct command.

Load the BASIC PROGRAM.
Load the CODE code 1.
Load the CODE code 2.

Finally SAVE the complete program using "SAVE "WP48/+/128" LINE 9800:
SAVE "specode128" CODE 32768,14600.

Should any of the functions not work then the machine code can be
checked using the HEXLOADER / HEXDUMP dual program. The HEXDUMP option
will print out to the screen or printer any block of memory in the same
form as the HEXDUMP LISTS 2 and 3. (The easiest way to check the code is
to compare checksum bytes).

If all has gone well you are now ready to use Specword.


Specword 48/128 Operating Manual

Specword has been designed to include all the functions most commonly
needed by the home user. For example it has insert / overwrite modes,
wordwrap, find, word count, block delete / move / copy / print,
redefinable centronics control codes (30), 16K text space (blank lines
only occupy 1 character space), lines of ANY length from one character
to the full text length, margins, thirty-one setable TABS, supports both
the ZX printer and most Centronics printers (with built-in software for
the Kempston interface) and RAM! file facilities for the 128K Spectrum.

To LOAD the program use LOAD "" (48K/+) or select the Tape Loader option
on the 128K Spectrum. The program loads in two sections and will display
the copyright screen when loading is complete. The program will
recognise automatically which version of the Spectrum is being used.
Press any key to start.

Specword is menu driven and users of the 128K Spectrum will have no
trouble in using the menu system as it is exactly the same as the
Sinclair start up menus.

MENUS: To select a menu option use the UP/DOWN arrow keys to move the
blue select line to your choice then press ENTER. This will either take
you to a sub-menu or into word processing. This is the main menu and
should the program stop due to any input errors then type "GO TO menu"
to restart from this menu. (The program will error trap most illegal
inputs but cannot trap those associated with illegal RAM! file names).

This menu has the following options:


1) Create.

Before word processing can begin the text file being created must have a
title. Selecting this option will produce a sub-menu asking you to
confirm your choice or Exit back to the Document menu. If you wish to
continue to create a document just press ENTER. You will now be prompted
to enter a title for your document. This must comprise of valid ASCII
characters only (no keywords).

The title given to your document will stay with the document at all
times unless the retitle option is used (see Save). The title will
appear on the top line of your text for reference.

Once a title has been given and accepted you will enter the word
processing mode (see Word Processing).


2) Load.

This will give a sub-menu for loading next files.

i) Tape.

This option will load a text file from tape (the BASIC program can be
modified to allow M/drives etc. to be used).

ii) RAM!

Owners of 128K Spectrums have the option of loading a text file that has
been Saved to a RAM! file. This option will display a CAT! of RAM files
and ask for your choice. 48K/+ owners will be told that this option is
not available on their computer should they attempt to select it.

iii) Exit.

Return to the Document menu.


3) Save.

This option gives a sub-menu for Saving text files.

i) Tape.

Save a text file to Tape using the title as the name for saving.

ii) RAM!

Save the text file to RAM!. Again this is only available on the 128K
Spectrum. NOTE: All text files will be saved with their own parameters
intact. That is if for example the right margin has been set and insert
mode is off then this will be saved with the text so that there is no
need to reset them when reloading the file.

iii) Retitle.

Should you wish to retitle your program before saving it then this
option will allow just that. For example you may have loaded a document
called "textone" and after modifying it want to save it under a
different name.

iv) Program.

If you have customized Specword in any way using the various options to
do so then the whole program can be saved and verified using this
option.

v) Exit.

Return to the Document menu.


4) Print.

This will give a sub menu as follows:

i) All text.

This will print out to your printer all of your text file using the
parameters as set up using the 'format' see (iii).

ii) Block.

If you have defined a block of text within the word processor mode then
this can be printed using this option.

iii) Format.

This will produce a sub menu which will allow you to set up the format
of text to be printed.

a)	Lines per page.
b)	Space between lines.
c)	Margin.
d)	Start at line no.
e)	Page no. at TOP.
f)	Page no. at BOT.
g)	Wait between pages.
h)	Auto line feed.
i)	Exit.

Against each of these parameters will be printed their current default
values. To alter a parameter use the UP/DOWN arrow keys to place the
blue cursor line on your choice then enter the new value. Parameters a)
to d) require a number value and will allow inputs of 0 to 999 (after
entering your required value press ENTER).

Should you make a mistake then press DELETE to cancel the entry.
Parameters e) to h) require Yes/No entry; use the Y and N keys to select
your choice.

When you are happy with all the values then select Exit to return to the
Print menu.

v) Codes.

This option will allow you to alter the printer codes that can be placed
in your text file to control the output of text to a Centronics printer.
For example <Graphics T> in your text will turn on the compressed print
mode and has the codes: 15/255/255/255 allocated to it (each control
character must have four codes allocated and any unused codes must be
set to 255).

If your printer requires a different set of control codes for compressed
characters then use this option to change the set codes. You can even
allocate other control functions to the Graphics characters. Once
amended the codes can be Saved permanently using "Save program". This
will produce sub-menus to select the Graphics letter required, upper or
lower case and finally a list of the codes for the letter selected for
you to update.

Each sub-menu has an Exit option which will return you to the previous
menu.

vi) Initialise.

Should you be using the Kempston Centronics Interface that requires
software to drive it then this option will initialise the computer to
use the Specword software for printing.

If your interface requires special software then this should be loaded
prior to loading Specword.

Note that Specword uses most of the memory of the Spectrum but that
memory between 43000 and 44000 is free for your printer interface
software. The ZX printer and similar printers can only be used with the
48K/+ computers and require no additional software to run them. DO NOT
use the Initialise option when using the ZX printer.

vii) Exit.

Return to the Document menu.


5) Edit.

If a document has been created and a return has been made to the
Document menu then this option can be selected to return you to the word
processor.


6) CAT!

For 128K users only, this will print a list of text files held in RAM memory.


7) Customize.

The word processing mode of Specword will initially use three different
colours to define the various areas of the file as it appears on the
screen. The main text will be white ink on a dark blue back round, the
text entry window will be white ink on a black background and the border
will be light blue. Should this combination of colours not be to your
liking then you may alter them using this option. New values can be
saved permanently using "Save program".

Note that when text is saved the combination of colours is saved with it
so that when loading back into Specword the colours may be different to
those you may be using.

This option also allows you to redefine the # sign for your printer. The
code is initially set to 129 (for the SHINWA printer).


8) ERASE!

Again for 128K owners only, this option will list the files held in RAM
and ask which one you want to erase. To skip this option if selected in
error just press ENTER to return to the Document menu.

If you enter a filename that is not valid then the program will break
with an error report. Should this happen enter "GO TO menu" to restart.


Word Processing

Once you have mastered the menu system then you can begin to enter text
using the word processor.

Using 'Create' to title your text you will be taken into the word
processing mode. The screen will clear and you will see the following
information displayed on line one of the screen.

COL:00001 LIN:00001 GM_EM_CAPS_WW_INS_LMAR:00000 RMAR:00000

COL:   will keep a record of the current cursor column.
LIN:   will keep a record of the current cursor line.
GM_:   will indicate when Graphics mode is selected.
EM_:   will indicate when E.MODE is selected.
CAPS_: will indicate if caps lock is on or off.
WW_:   will indicate if word wrap is on or off.
INS_:  will Indicate if insert mode is on or off.
LMAR:  will indicate the column value of the right margin if set.
RMAR:  will indicate the column value of the left margin if set.

The main text screen will be blank except for a series of dots at the
beginning of each line. Towards the bottom of the screen you will see a
black line; this is the text window in which all typing is carried out.
Above this window there is the text title line to remind you of the name
given to your document. Below the window Is the end of text marker line.
A cursor will be flashing black/white at the beginning of the text
window.

Initially your text file is just one character long, a new line
character code 13 represented by a dot will be seen under the flashing
cursor. All margins and tabs will be reset and insert mode will be on
(indicated by the white bar against INS in the status line) and word
wrap will be off.

In word processing there are three distinct modes which give access to
the various functions.


1) Text Mode

This is the standard mode on entry to word processing in which normal
text entry is carried out. Specword has a keyboard buffer to ensure that
all key presses are read so that even the fastest typist will not be
able to out-type the program.

Use the keyboard as you would a normal typewriter. Typing will always
appear in the text window so that you do not have to search the screen
to find out where you are. When the cursor reaches column 29 the screen
will scroll left to keep text entry in view at all times.

Text entry will continue on line one until ENTER is pressed to indicate
a new line is required (see margins). You will notice a dot placed at
the end of each line, this indicates a new line character and is part of
the text; that is it can be erased to join two lines together or
inserted into a line to split it into two separate lines.

In all modes the INV VIDEO key has a special function in that if pressed
it will display a HELP page for that mode. These HELP pages give brief
information on all the main functions available in that mode.


Text mode functions

i) Arrows: The cursor can be moved around the text using the four arrow
keys.Left and right arrows will move the cursor one character at a time
through the text in the relevant directions. The up and down arrows will
cause the screen to scroll down and up to place the required text line
into the cursor window. When moving up and down through the text the
cursor will try to stay in the same column but if the line to be moved
into the text window is shorter than that column then the cursor will
move to the end of that line (this is similar to program editing on the
128K Spectrum). Note that the keyboard is buffered and if the arrow keys
are held down too long you will overshoot the required position.

ii) Delete: This key will delete the character behind the cursor and
backspace to that position, closing up the text.

iii) True Video: Move to the next TAB position (see E.MODE for the
method of setting tabs).

iv) Graphics: This is the second mode available and is mainly concerned
with the printer control characters (see GRAPHICS MODE).

v) Ext. Mode: The third mode available, mainly concerned with the text
format and editing (see EXT. MODE).

vi) Edit: Return from word processing to the Document menu.

In text mode all the normal characters are available using CAPS SHIFT
and SYMBOL SHIFT. CAPS LOCK will select capitals in the normal way and
indicate that it is on by placing a white block against CAPS in the
status line.


2) Graphics Mode

This will be of interest if you have a dot matrix printer that has
standard controls to select different text formats. Selecting GRAPHICS
will place a white block against GM in the status line

INV VIDEO will produce a HELP page giving the control code letters and
their original functions. You will see that for most functions UPPER
case is used to switch on the function and lower case to switch it off.
There are 30 characters available, all of which can be redefined to suit
your printer.

Printer control characters do not affect the line length of the text
sent to the printer.

There are also eleven form characters that can be printed in this mode.
These characters can be used to place borders around your text. The
following keys are used and as you will see form a keypad to make them
easy to find:

[see SPECWORD.GIF]

The codes used for these characters are initially for the SHINWA CP8O
printer but can be changed to suit your printer with a few simple POKE
commands.

The initial codes are:

[see SPECWORD.GIF]

Each code has two addresses as follows: the first address is for UPPER
case, the second for lower case. So in fact you can re-program 22 new
characters:

34495/6,150
36530/1,154
36532/3,151
36534/5,149
36536/7,156
36558/9,134
36560/1,157
36562/3,159
36570/1,152
36572/3,158
36576/7,153

CAPS LOCK also works in this mode.

This mode also has a 'text' view which will give a display of the
current screen at 128 characters per line. This will be in the form of a
graphics display with a letter represented by a line. This can be used
to check the format of your text. To obtain this view mode press key 1.
The display will remain on until another key is pressed when a return to
TEXT mode will be made.


3) Ext. Mode

This mode is entered by pressing the EXTEND MODE key and will be
indicated by a white block against EM in the status line.

INV VIDEO will display two HELP pages to give you a summary of the
various functions available

The EXTEND MODE key should not be held down once E. MODE has been
selected.

The characters ~ : \ {} [] are available in this mode, and the copyright
symbol - which is non-standard - has been replaced by the ' symbol (the
symbol ' is available in text mode using SYMBOL SHIFT/7).

i) Arrow keys have a special function in this mode as follows: UP will
take you to the start of the text file. DOWN will take you to the end of
the text file. LEFT will take you to the left margin or, if not set, the
beginning of the line. RIGHT will take you to the right margin or, if
not set, the end of the line.

ii) Q (<=) will set the left margin to the current cursor value, and
display that value against LMAR In the status line.

iii) E (>=) will set the right margin to the current cursor value, and
display that value against RMAR in the status line.

iv) R (<) reset the left margin to zero.

v) T (>) reset the right margin to zero.

vi) I insert mode ON. This will be indicated in the status line by
placing a white block against INS. In this mode characters will be
inserted into the text displacing the text to the right to make room for
that character.

ENTER in this mode will produce a new line in the text displacing the
text down one line to make room. The cursor will flash black/white.

viii) O Overprint mode ON. This will be indicated by a short white block
against INS in the status line. The cursor will flash red/white. Text
entered in this mode will overprint the current text. If the right
margin has been set then this mode will not allow printing to continue
on the next line until ENTER is pressed. This has been done to stop
over-printing of text on the next line without confirming that it is OK
to do so. A reminder that the right margin has been set will be printed
on the screen should you attempt to exceed the right margin.

ix) K (+) Word wrap ON. This will be indicated by a long white block
against WW in the status line. There will also be a change of cursor
colour, the white flash will change to blue That is:

INSERT ON / WW ON  = BLACK / BLUE
INSERT ON / WW OFF = BLACK / WHITE
OPRINT ON / WW ON  = RED / BLUE
OPRINT ON / WW OFF = RED / WHITE

Word wrap will only function if the right margin is set and insert mode
is on. Should a word continue from the end of a line to the beginning of
the next line then that word will automatically be transferred to the
next line.

x) J (-) Word wrap OFF. This is indicated by a short white block against
WW in the status line. Words will remain split between the end of one
line and the start of the next providing that the right margin has been
set.

xi) C Count (word). Selecting this function will produce a display of
the number of words in your text. This will not include any Graphics
printer control code letters or block markers. The count is
instantaneous and will remain on screen until a key is pressed.

xii) W Word Find. This will search through your text FROM THE CURSOR
POSITION to find a word or phrase of your choice. You will be prompted
to enter your search text and Specword will search the file until it
finds the required word / phrase and place the cursor at the start of
that word. Should the required word / phrase not be in the text then the
message "WORD NOT IN TEXT" will be displayed and the cursor will remain
in its original position.

xiii) 1 Set TAB. This will set up a tab stop at the current cursor
position. The border will flash dark blue to indicate that the command
has been accepted. Up to 32 tab stops can be set BUT they must be set
with column values of less than 256.

xiv) 2 Reset TAB. This will remove a set tab. The border will flash red
to indicate that the tab has been removed.

xv) 3 Reset all TABS. This command will remove ALL the set tabs and the
border will flash green to indicate that the command has been accepted.

xvi) 8 Set block start. This command will place a block start marker at
the current cursor position. This will be indicated by a forward facing
arrow.

xvii) 9 Set block end. This command will place a block end marker at the
current cursor position and will be indicated by a backward facing
arrow.

Any previously set block markers will be removed before a new block
marker is set.

xviii) 0 Reset blocks. This will remove any set block markers from the
text.

Block markers can be treated as a character in the text file, that is
they can be erased or re-positioned by inserting text into the block.
This will have no effect on any of the block functions. Specword will
allow for any change in position of these markers.

xix) 5 COPY BLOCK. This command will copy a set block to the current
cursor position opening up the text to make room. A block can be any
length from just one character to the whole text file. If there is not
enough room left in the text file to make a block copy then a message to
that effect will be given and the copy command will be ignored.

The block copy will be free from block markers, these will remain set on
the original block.

xx) 6 MOVE BLOCK. This will move a set block from its current position
closing up the text, to the current cursor position opening up the text.
This command will work even on a full text file. The block will be moved
complete with its block markers.

xxi) 7 DELETE BLOCK. This final command will erase a set block from the
text file closing up the text.

Block commands are almost instantaneous but will not work if:
a) The cursor is placed inside the black to be MOVED or COPIED.
b) The start marker is positioned AFTER the end marker.
c) There is insufficient text room to accept block COPY.

As an example of the text that can be created in a file, these
instructions were produced on Specword and took 514 lines of which 406
were produced in one text file (2819 words). The remaining 108 lines
were produced in another text file (854 words).


--
Another Fine Product transcribed by:
Jim Grimwood, Weardale, England (http://www.users.globalnet.co.uk/~jimg/)
--
