[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
Box on HP Make a real gray scale box on a HP laserjet
The following user-defined functions are provided to users of R&R Report
Writer by Concentric Data Systems, Inc. You may use and distribute these
functions as you wish. Bear in mind that these functions are hardware
specific and do not work in all report situations, so read the directions
below carefully. On the other hand, used properly, these functions are
quite powerful and may satisfy many application needs.
---------------------------------------------------------------------------
BOX.UDF is a collection of R&R Version 5 user-defined functions for
creating lines, boxes, and shading on a Hewlett Packard PCL compatible
laser printer. Lines, box borders, and the area within boxes can be any
degree of gray-scale shading from 0 (invisible) to 100 (solid).
. _hline Type: Character
_hline(c_w,c_t,c_b) = CHR(27)+"*c"+w+"h*c"+t+"v*c"+b+"g2P"
. _pop Type: Character
_pop() = CHR(27)+"&f1S"
. _position Type: Character
_position(c_h,c_v) = CHR(27)+"&a"+h+"h"+v+"V"
. _push Type: Character
_push() = CHR(27)+"&f0S"
. _shade Type: Character
_shade(c_w,c_h,c_s) = CHR(27)+"*c"+w+"h*c"+h+"v*c"+s+"g2P"
. _vline Type: Character
_vline(c_h,c_t,c_b) = CHR(27)+"*c"+h+"v*c"+t+"h*c"+b+"g2P"
. BOX Type: Character
BOX(c_w,c_h,c_t,c_b,c_s) =
IIF(t#"0".AND.b#"0",IIF(w#"0",_hline(w,t,b)+IIF(h#"0",_vline(h,t,b)+
_push()+_position("+"+LTRIM(STR(MAX(0,VAL(w)-VAL(t)))),"+0")+_vline(h,t,b)+
_pop()+_push()+_position("+0","+"+LTRIM(STR(MAX(0,VAL(h)-VAL(t)))))+
_hline(w,t,b)+_pop(),""),IIF(h#"0",_vline(h,t,b),"")),"")+
IIF(s#"0".AND.w#"0".AND.h#"0",_shade(w,h,s),"")
---------------------------------------------------------------------------
When you create a calculated field using BOX, place it on the report
layout as close to the left margin as possible, and set the field width as
wide as possible. This is necessary to insure that the escape sequence is
not truncated.
All arguments to the BOX function are character strings. So, either place
the desired value within quotes, e.g. "100", or else use the STR function,
e.g. STR(100). Note that there are 720 decipoints per inch.
BOX(w, h, t, b, s)
w = width, the width of the box, line, or shaded area in decipoints,
or 0 for a vertical line
h = height, the height of the box, line, or shaded area in decipoints,
or 0 for a horizontal line
t = thickness, the box or line thickness in decipoints, or 0 for a shaded
area with no border
b = border, the gray-scale density of the line or box border from 1 to 99,
or 0 for a shaded area with no border, or 100 for a solid line or border
s = shading, the gray-scale density within the box or rectangular area
from 1 to 99, or 0 for a box with no shading within
A workaround for boxes you want closer to the right margin is to create a
calculated field expression in the following format, which stores the
current printer cursor position, moves it to the right a specified number
of decipoints (999 in this example), prints the box, and then restores the
cursor to its original position:
_push()+_position("+999","0")+BOX(...)+_pop
Note also that in R&R Version 4 you can overlap fields on the report
layout and that you can set line heights to 0 points. These are useful
tricks for over-printing report data with boxes and shading. Otherwise,
R&R will leave space on the report as if the calculated field containing
the box escape sequence contained actual report data.
The UDFs called by the BOX UDF, namely _push, _position, _hline, _vline,
and _pop, may be useful in other applications. Study the BOX UDF formula
to see how they are used. In fact, you could implement them directly in a
dBASE, Fox, Clipper, Quicksilver UDF and use them in your programs for
other applications.
Another hint is that variable sized lines, boxes, and shaded areas can be
created by computing the arguments to the BOX function. For example, you
might pre-process a count to see how many records there are, and multiply
that number by the record height in decipoints to create a variable height
shaded area dependent on the number of records in the group!
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson