DOCUMENT #718
=======================================================================
DRAW LINES AROUND VARIABLE LENGTH FIELDS
=======================================================================
PRODUCT: R:BASE VERSION : 3.1 or Higher
=======================================================================
CATALOG: Reports AREA : Drawing Lines
=======================================================================
Lines are often used in a report to emphasize a section of text and set
it apart from the rest of the report. It's easy to draw lines in R:BASE
reports using the Draw option on the menu. The lines are placed in the
report definition as text; they are not part of the field location. This
works fine for fields that are located for a specific size. But when you
locate a TEXT or NOTE field using just the W marking to indicate wrap for
as many lines as there is data, the lines are only printed for the first
and last lines of data. R:BASE only wraps the data, it does not wrap
other text on the line.
To have the report "draw lines" around all of a variable length TEXT or
NOTE field use a TEXT variable instead of the line draw character on
each end of the field location. The variable contains one line draw
character for each line of data that wraps. The variable is itself
wrapped and thus prints alongside the data.
Step 1
=======
Create a lookup table to hold the line draw characters. The lookup
table has two columns, an INTEGER column for the number of lines and
a TEXT column to hold that number of line draw characters. For example:
CREATE TABLE Borders (numline INTEGER, border TEXT 20)
The TEXT column length must match the maximum number of lines printed
for the field to be wrapped. The table defined above draws lines around
fields wrapped up to 20 lines long.
Step 2
=======
Next, determine the ASCII code of the line draw character. If the
lines are single line borders, use ASCII code 179, for double line
borders, use ASCII code 186.
Step 3
=======
Load the Borders table with data. Enter consecutive numbers (to number
each row) in the numline column. Enter that many line draw characters
in the border column. Make sure you enter enough rows. For a single-line
border around a field that will be a maximum of 10 lines long, load the
Borders table with this data:
numline border
------- -------
1 |
2 ||
3 |||
4 ||||
5 |||||
6 ||||||
7 |||||||
8 ||||||||
9 |||||||||
10 ||||||||||
The data can be loaded by selecting the Borders table from the Info
menu. To enter the single line character, hold down the [Alt] key and
press 179 on the number pad. The Copy data option can be used to make
data entry quicker. Alternatively, the LOAD command can be used from
the R> prompt.
Step 4
=======
Modify the report. Define two new variables in the report, one to
compute how many lines the field wraps on, and one to lookup the
matching number of line draw characters. For example,
vnumline INTEGER = ((SLEN(note_column)) / 40 + 1)
vborder = border IN borders WHERE numline = .vnumline
The variable vnumline equals the number of lines required to print
the note_column column for a given row. It is calculated as follows:
SLEN finds the number of characters of data in the column for that
particular row, that value is divided by the located width (40) and
one is added to account for the last line. The variable vborder
contains the same number of line draw characters as there are lines
to print.
Locate vborder at both ends of the location for the note_column
column. You can locate vborder on top of the existing line draw
characters. Locate vborder only one character wide by pressing S
to mark the beginning, backspace, press W (on top of the S) to wrap,
and then press [ESC] twice. This wraps the border lines as the text
is being wrapped. The report format might look like this:
two locations for vborder
/ \
/ \
| |
D +-----------------------------------+
D WS WW
D +--------------|--------------------+
|
location of the wrapping column
If you have data that still doesn't print a complete box for some
rows of data try SET WRAP OFF. With WRAP ON, fields may wrap with
extra spaces causing the line count to be wrong.