Drawing Boxes Around Memos in Reports
Mark Ware
Dress up your reports by drawing a box around your memo fields.
The dBASE IV report writer is a very effective tool for creating almost any
type of report.  With it you can merge mail, print ordinary reports such as
columnar reports, or create something fancier that can be used to print
checks or to fill in pre-printed computer forms.

However, there is one thing that the report writer will not do automatically;
draw a box around a memo field. dBASE IV does provide the ability to do this
on screen using the DEFINE BOX command, but this method is not available in a
report form.  After years of dedicated research I have finally cracked this
nut.  I have finally discovered the secret of the "Box around the Memo" and
will share it with you here.

The first thing to do is USE a database that contains a memo field.  Now enter
the report writer, either from the Control Center or from the dot prompt by
typing CREATE REPORT.  Next, place the memo field in the detail band of the
report.  The initial width will be determined by the setting of MEMOWIDTH,
which defaults to 50.  So, assuming the default, you will see arrow of 50 Vs
which represent the memo.  The V means vertical stretch.  That is, the entire
memo field will print in a 50 character wide column, with page breaks
occurring appropriately.

Now that we have the memo field where we want it, let's create the box.
First, move the cursor one space to the left of the memo field (or to the
position where you want the left side of the box to appear).  Press F5 to Add
field.  Let's call this new field BoxSide and select CALCULATED for the field
type.  For the Expression option, enter the following:

REPLICATE(CHR(186), MEMLINES(<memo field name>))
Note: CHR(186) is the vertical double-line character.  You can use any
character that you desire.

Press Return and then Ctrl-End to save the field.  What this will do is create
a string of CHR(186) (double-vertical bar) characters.  How many of these are
printed is determined by the MEMLINES() function, which returns the number of
lines the memo will occupy based on the setting of MEMOWIDTH.  The trick here
is to make the BoxSide field a one-character-wide vertical stretch field.

To select the BoxSide field, make sure the cursor is placed on it, then press
F6 and Return.  Now, we are going to size this field so that it is only one
character wide.  Press Shift-F7 then the Left arrow key to adjust the width
of the field to that of one space.  Press Return to show the adjusted field.
Now we need to enable the vertical stretch picture function.  Press F5 to
access the field menu.  Select Picture functions and navigate to the Vertical
stretch option.  Press Return to turn Vertical stretch ON.  Press Ctrl-End to
save the modification.

To create the right side of the box, we can simply copy the left side.  Press
F8 Copy and move the cursor one space (or however many desired) to the right
of the memo field then press Return. This takes care of the left and right
sides of the box.  Now on to the top and bottom.

Position the cursor so that it is above the detail band and select Band: Add a
group band.  This will bring up another menu which will ask you how the
report should be grouped.  Select Record count and enter 1.  Now each record
will be treated as a group, which is the key to getting the top and bottom of
the box to work effectively.

After completing the above steps, cursor into the new group intro band.  Now,
move the cursor so that it is directly above the left box character in the
detail band.  Press F5 to Add field and again select CALCULATED.  We'll call
this one BoxTop and for the Expression enter the following:

CHR(201) +REPLICATE(CHR(205), SET("MEMOWIDTH") +2) +CHR(187)
Press Ctrl-End to save the new field.  If MEMOWIDTH is set to the default of
50, this will produce the following:


But, remember that a field will only print as long as its template, so you
must size the field.  Press Shift-F7 and the Right arrow key to extend the
template from the left side of the box all the way to the right side of the
box.

One thing to note here is the SET("MEMOWIDTH")+2 in the expression above.  If
we placed the left and right side of the box so that there is one space
between them and the memo field,we need to add two extra horizontal bar
characters to align the box properly.  If you want to leave two spaces
between the sides and the memo, use +4 in place of +2 and so on.  If a double
bar prints instead of the upper right corner character, the field expression
needs to be adjusted.  This completes the top of the box.    

Now for the bottom of the box.  Move the cursor to the group summary band so
that it appears directly below the left box character.  Press F5 to Add field
and select CALCULATED.  Enter the following Expression:

CHR(200)+REPLICATE(CHR(205),SET("MEMOWIDTH")+2)+CHR(188)
This results in the following (assuming the 50 character MEMOWIDTH default):


Well, that's all you need to produce a box around your memo fields, but
there's a few things I should mention.  First, the above example assumes you
only have one line in your detail band.  If you have more than one line, you
can keep the box "connected" by creating a calculated field containing a
single CHR(186) (vertical bar) and placing it beneath (or above) the left and
right sides of the box in the detail band.  

Secondly, if the memo is empty, the sides of the box won't print, since
MEMLINES = 0, but the top and bottom will.  To prevent this, you can define
the top, bottom and any single CHR(186) calculated fields with an IIF()
condition.  For example, to suppress the top of the box from printing when
the memo is empty, change the Expression to the following:

IIF(MEMLINES(<memo field name>) > 0, [CHR(201) + REPLICATE(CHR(205),
SET("MEMOWIDTH") + 2) + CHR(187)], SPACE(0))

Finally, be advised that this method will not work with anything other than
memo fields, since we are using functions that specifically apply to memo
fields.

Printing the Report
In order to have dBASE IV print the actual box, you will need to use one of
the following printer drivers:

ASCII.PR2 
HPLAS2I.PR2	Hewlett-Packard Series II Only
HPLAS2ID.PR2	Hewlett-Packard Series IID (Duplex) Only 
IBMGP.PR2	IBM Graphics and Compatibles

Be advised that on some IBM Graphics compatible printers the double-bar
graphics character may appear as a single-bar.

These are the only drivers in dBASE IV that support the IBM extended character
set, which is necessary for printing the double-bar characters used in this
article.	s

