SHORTIES\PRMODE.DOC  ·  DOC  ·  6.6 KB  ·  1988-01-01  ·  from PCPlus_Issue-21_Jun-1988
PRMODE - AN EXPANDABLE AND CUSTOMISABLE PRINT MODE SELECTOR.


Usage - PRMODE [parameter] [parameter] ....... etc
        PRMODE without parameters lists the options.
        Upper or lower case may be used.


This utility sends the appropriate control codes to the printer
for each parameter in the command line.
Combinations of typefaces, feed rates and attributes can readily be
selected by including the appropriate parameters either together in
the same PRMODE command, or in separate PRMODE commands.

Codes are sent without regard for any sent earlier, so if the
current status of the printer is not as desired then 'RESET' should
be the first parameter, followed by others as required.
All parameters are checked for errors before any are transmitted.
Checks are made for invalid characters, too many characters
(more than 8), and failure to match a parameter with a table entry.

As currently set, the codes are appropriate for the AMSTRAD DMP3000
printer. They may be altered to suit any other printer by changing
the parameter table as described below. Note that with the AMSTRAD
printer italic style text can only be printed if the Epson
default character set is selected (DS1-7 and DS1-8 off).


CHANGING THE PARAMETER TABLE:

Each entry in this table consists of a sequence of 64 bytes of
information, the format of which is critical for proper functioning.
Note that the error checking referred to earlier only applies to
the command parameters. No checks are made on the table format so
errors here will cause unpredictable operation.

The first 9 bytes of the 64 are for the name of the parameter. (To
be used following the PRMODE command). The name must be expressed in
ASCII codes corresponding to capital letters or numbers, no other
codes are permitted. Note that CAPITALS must be used in the table,
the option to use small letters applies only in the command line.
A maximum of 8 letters/numbers is permitted, and the name must be
terminated by the ASCII record separator code (1E Hex, 30 Decimal).
Any excess bytes after the '1E' Hex code up to and including the
ninth can be padded with anything, 'X's are used in the current
table.

The next byte (tenth) contains a number corresponding to the number
of control codes to be sent to the printer, the maximum permitted
being 22.

There follow the control codes themselves in the required
sequence. After the appropriate number have been listed, the excess
up to 22 can be padded with anything, again 'X's are used in the
current table. This quantity has been included to allow combinations
of codes to be sent for a single parameter. In this way flexibility
is permitted in customising special user requirements.

There now remain 32 bytes which contain the parameter description
to be displayed on the screen when PRMODE without parameters is
entered. These bytes contain the ASCII character codes for the
required display. For a clear presentation the first and last
should be space codes (20 Hex, 32 Decimal). Any padding after
the description should be with spaces.

In the byte immediately following the last table entry, ie after
a whole number of 64 byte sequences, the ASCII 'End of Transmission'
code ( 04 ) should be entered. This acts as a marker for the end
of the table and the program will not function properly without
it.


The table can be altered or expanded using any convenient
debugging or file manipulation utility. The address of the table
start is offset by 02C0 Hex from the start of the program. Note
that if the debugging program displays files beginning at address
0100 Hex, (to allow for the Program Segment Prefix, as does MSDOS'
DEBUG), the table start address will be indicated as 03C0 Hex.
The table of command parameters may be expanded indefinitely, but
note that only the first 40 will be listed on the screen when 
PRMODE is used without parameters.

A sequential file manipulation program can alternatively be
written in BASIC or other high level language. In this case the
file may be read in 64 byte blocks as fixed length strings. The
first 11 such blocks contain the program, and each subsequent block
contains a table entry. When writing a modified file remember to
write the single byte value 04 at the end of the sequence of 64 byte
table entries. Remember also when writing each 64 byte block to
adopt a mode that does not automatically write a carriage return & 
line feed after each block (eg in BASIC end the PRINT# statement
with a semicolon).

A sample BASIC 2 template is given below which reads in the 
PRMODE.COM program as a series of 64 byte blocks, allows extra
lines to be included to handle the required table entry
modifications, then writes the modified program to a new file
called PRMODE2.COM. Note that the routine need not be typed
again, a copy of this document can be made and then all lines
before the routine edited out, leaving the routine ready for
inclusion of the appropriate modifying commands.

If this routine is used then the command to invoke the new
print mode select program becomes PRMODE2 [parameter] ...
To use the original command first rename the original
PRMODE.COM program (say) PROLD.COM, then rename the new one
PRMODE.COM. Of course any other command name that you prefer
may be used instead.


   ------------------------***--------------------------


REM       PRMODE modification template (BASIC 2)
REM       Put the PRMODE disk in drive "A"


DIM prog_block$(11)
DIM orig_entry$(28)
DIM modified_entry$(28)    :REM   Or however many are needed.

OPEN #1, INPUT "a:prmode.com"
FOR x=1 TO 11
prog_block$(x)= INPUT$(#1,64)
NEXT x
FOR x=1 TO 28
orig_entry$(x)= INPUT$(#1,64)
NEXT x
CLOSE #1


REM   The table entries are now held in the 28 elements of string array
REM   "orig_entry$"

REM   Include here the appropriate modification routines to convert
REM   the elements of "orig_entry$" into new elements of the string
REM   array "modified_entry$". (Or read them in from an already
REM   prepared file). Note that additional ones may be incorporated
REM   but make the array size match the number required.
REM   Do not alter the 11 elements of array "prog_block$" in
REM   any way.

REM   The new array together with the original program can now be
REM   written to disk with the routine below.


OPEN #2, OUTPUT "a:prmode2.com"
FOR x=1 TO 11
PRINT #2, prog_block$(x);  :REM   The semi-colon suppresses CR & LF codes
NEXT x
FOR x=1 TO 28              :REM   Or however many are to be sent.
PRINT #2, modified_entry$(x);
NEXT x
PRINT #2, CHR$(4);         :REM   The table end marker.
CLOSE #2
END