home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1995 November
/
PCWK1195.iso
/
inne
/
podstawy
/
dos
/
4dos
/
4uzytki
/
4laser.exe
/
4LASER.DOC
< prev
Wrap
Text File
|
1992-04-16
|
7KB
|
267 lines
4LASER
4DOS Laser Configuration Utility
by
Marshall E. Giguere
CIS ID: [71511,3513]
Created: April 16, 1992
Last Revised: April 16, 1992
Introduction:
-------------
The 4LASER utility defines a simple mnemonic command interface for
sending configuration codes to an HP LaserJet Series II laser
printer. I cobbled this utility together after getting tired of
looking for my printer manual.
Probably the most interesting feature of 4LASER is the generalized
parsing facility and dispatching method that I developed to simplify
handling command line parsing. So if you don't have a LaserJet II
you can simply rip out the action section of 4LASER and put your own
on and you'll have a completly new program.
4LASER is by no means presented as a complete product but rather as
an interesting exploration of ideas. You are encouraged to extent
4LASER with additional features and in fact this should be quite
easy.
4LASER commands:
----------------
The 4LASER utility accepts a sequence of commands on the 4DOS command
line. The 4LASER command line is:
4LASER [command | command=argument]...
Example:
4LASER portrait bold typeface=3 point=12 pitch=10
The above command sets the LJII to portrait mode with a bold face 12
point courier font at 10 characters per inch.
Commands:
---------
Commands are of the form "name" or "name=arg" where arg maybe any
string. Command names are case-insensitive, i.e. "BOLD" and "bold"
are the considered the same.
BOLD
Sets the weight factor to 3 for a bold typeface.
COURIER
Selects a 12 point, 10 pitch, portrait mode typeface
with 60 lines per page.
DEVICE=dev
Selects the port to which subsequent commands are sent.
The default port is LPT1.
ITALIC
Selects an italic type style for the current font.
LANDSCAPE
Places the page orientation to landscape.
LIGHT
Sets the weight to -3, or light print.
LINEPRINTER
Selects an 8.5 point, 16.66 pitch portrait mode font
with 80 line per page.
LITE
Same as LIGHT.
MEDIUM
Sets the print weight to 0 or medium print.
PITCH=#
Set the number of characters per inch (cpi) to the
value of #.
POINTSIZE=#
Selects the height of the font in points to the value of #.
PORTRIAT
Sets the page orientation to portriat.
RESET
Forces the printer into reset mode.
ROMAN
Selects a roman type style.
SYMBOLS=sym
Selects the symbol set used by the printer legal values are:
sym value Symbol set
--------- --------------------
0N ECMA-94 Latin 1
8U Roman-8
10U IBM-PC USA
11N IBM Danish/Norwegian
Consult your printer or cartridge manual for additional symbol sets.
TYPEFACE=#
Selects the typeface where # is one of the following.
# Typeface
- ------------
0 line printer
1 Pica
2 Elite
3 Courier
4 Helvetica
5 Times Roman
6 Gothic
7 Script
8 Prestige
9 Caslon
10 Orator
Consult your printer or cartridge manual for additional symbol sets.
VERTICALPITCH=#
Sets the vertical pitch, the number of lines per inch (lpi). Legal
values are: 1,2,3,4,6,8,12,16,24,48.
WEIGHT=#
Sets the weight factor for the typeface. Legal
values are: -7 to +7, where -7 is very light, 0 is normal
or medium, and +7 is very bold.
Restrictions:
-------------
The current implementation of 4LASER sets only attributes of the
primary font. I did not consider this to be a serious limitation
since you may encapsulate an unlimited number of configurations in
any number of 4DOS aliases.
Theory and Other Advance Concepts:
----------------------------------
As was noted in the introduction possibly the most useful idea in
4LASER is not the ability to configure your LJII but rather the
method of extracting information from a 4DOS command line and
selecting the appropriate action.
Rules and Actions:
------------------
4LASER uses the simple but powerful idea from production systems of
rule/action pairs. Productions consist of two parts a rule clause
and an action clause, e.g. rule {action}. In the case of 4LASER the
rule clauses are simply strings separated by whitespace and the
action clauses are blocks of code declared with a label of the same
string as the rule, e.g. COURIER is the rule and the :COURIER label
introduces the action clause within the 4LASER.BTM file. A rule in
4LASER is said to fire when it matches a label that is
lexicographical equal to the rule name. This is admittedly a gross
simplification but it provides a lot of power for little effort.
The job of the parser is then simply to identify rules, and any
subsequent arguments and to then invoke the action clause. This
process continues until the 4DOS command line is exhausted. The
process of selection, action and execution is performed by the main
processing loop within the :LOOP scope. The tokenization of the
command arguments is handled by the routine :LEX with the actual
execution being done by the :EXEC routine. This division of labor
makes a simple yet powerful parsing tool for 4DOS batch programs that
require a mnemonic command syntax.
Parser Architecture:
--------------------
The architecture of 4LASER has been generalized to permit its use for
any number of jobs. The architecture is:
-------------------
| |
|Parser/Dispatcher|
| |
-------------------
| |
| |
| Actions |
| |
| |
-------------------
The Parser/Dispatcher section may be separated from the 4LASER.BTM
file and placed on top of another, different, actions section. The
parser provides parsing for rules of the forms:
rule := name | name=arg
name := <any string>
arg := <any string>
The :LEX Function:
------------------
The :LEX function manages the command line and returns rule names and
their arguments on request. Internally rule names and arg's are
returned by the :LEX function in the variables %FUNC and %ARG. At
this time :LEX assumes arguments are introduced by the "=" symbol.
It is of value to note that :LEX is self contained and action clauses
may safely it if they require more input than initially supplied
by :LEX.
Action Clause Structure:
------------------------
Action clauses are handled as 4DOS subroutines. That means that
actions are invoked by a "GOSUB label" operation where the "label" is
the same as rule name. This means that architecturally actions are
in fact subroutines and therefore must return. The general structure
of an action clause is:
:rule-name
{action code goes here}
RETURN
Example:
The courier command is implemented with this action clause.
:c
:co
:cour
:courier
set code=eEe&l6De(10Ue(s0p10h12v0s0b3Tr
return
Note the use of several successive labels to declare the courier
action clause. This allows a short hand rule name to be used in
place of the full rule name.
Conclusion:
-----------
The 4LASER utility demonstrates how a simple but elegant command line
parser can be created using only the capabilities of a simple string
interpreter like 4DOS.