HyperCard 2.0, 2.1: Create Report with Breaks (11/92)

HyperCard 2.0 and 2.1 can't print dynamically sized records that do not
break across columns or pages when printing reports. HyperCard
1.2.x can.

A Workaround
------------
There is a workaround involving a series of scripts (below) that will solve
this problem. To use the script, you need to

1) From the File menu, choose "Print Report...".

2) From the Edit menu, choose "New Report".

3) Set the top and bottom margins of the report to one-half inch.

4) Set the space between records to 0 inches.

5) From the Edit menu, choose "Report Items...".

6) From the Items menu, choose "New Item"..

7) Resize this item to the full height of the record by clicking and dragging
in its corner.

8) From the Items menu, choose "Item Info...".

9) In the Item box, type "specialReport()"

10) Click OK as many times as you need to to exit and save your changes.

11) Enter the handlers (below) into the stack or background script.

How It Works
------------
These scripts work by making the assumption that the default 12-point line
height has been specified for the items in the report -- if this is not
true, the script will need to be adjusted accordingly. A doMenu handler is
required as well, so if you already have one, you can simply add the lines
from the one below that are different from the one you already have to your
current doMenu handler.

Finally, the report itself must have half-inch top and bottom margins, and
no space between the labels, and must have fields corresponding to those in
the Address stack shipped with HyperCard 2.1. Where differences occur, the
script will have to be modified.

The Handlers
------------
on doMenu item
global lineCount -- For our special report
if item = "Print Report..." then put empty into lineCount
pass doMenu
end doMenu

function writeBLine number
if number is empty then put 1 into number
repeat number
put return & "╩" after theLine -- option-space here
end repeat
return theLine
end writeBLine

function specialReport
-- Assumptions:
-- a 12 point line height.
-- a half-inch top and bottom margin.
-- an 11-inch high page.
-- Other handlers needed:
-- on domenu (to reinitialize lineCount each time it's called)
-- function writeBLine (to write a line with only an option-space in it
-- because HyperCard's report generator removes trailing returns.
--
global lineCount
put 12 into lineHeight
--
if lineCount > 63 or lineCount is empty then put 0 into lineCount
--
if bg fld "Company" is empty
then
put bg fld "Name" & return & bg fld "Street" & ┬
return & bg fld "City" &", "& bg fld "State" && bg fld "Zip" ┬
& writeBLine(1) into adjustedAddress
else
put bg fld "Name" & return & bg fld "Company" & ┬
return & bg fld "Street" & return & bg fld "City" & ┬
", " & bg fld "State" && bg fld "Zip" & writeBLine(1) into adjustedAddress
end if
--
put (number of lines of adjustedAddress) into labelHeight
put round((36 / lineHeight) + linecount) into usedLines
put round(792 / lineHeight) into availableLines
put availableLines - usedLines into freeLines
--
if freeLines < (labelHeight)
then
repeat ((labelHeight - freeLines) - 1)
put writeBLine(1) before adjustedAddress
end repeat
end if
--
if (number of this cd) = (number of cds of this bg)
then put empty into lineCount
else add labelheight to lineCount
--
return adjustedAddress
end specialReport

This article is adapted from the Claris Tech Info database.

Support Information Services
Published Date: Feb 19, 2012