The HotDocs Computation Archive

0140 - Send Only Overflow Text to Addendum


Description:

Demonstrates how to use as many lines as available in an Automator field, sending only the overflow text to the addendum.

 

• Explanation •

When the text of an Automator field overflows, all of the text is sent to the addendum. With long, multi-line fields, you may want to fill those lines and then send only the overflow text to the addendum. This computation and example demonstrate how to do this.


•  •  •  •  •  •  •


• Code •

// Is the text longer than our max length?
IF LENGTH( TextVar ) > 220

   // Take as much text as will reasonably fit in the field
   SET SplitA-t TO FIRST( TextVar, 220 )

   // Find the last space
   SET done TO FALSE
   SET ctr TO LENGTH( SplitA-t )
   SET loopLimit-n[ ctr ] TO 1
   REPEAT Loop
      IF NOT done AND MID( SplitA-t, ctr, 1 ) = " "
         SET SplitA-t TO FIRST( TextVar, ctr )
         SET done TO TRUE
      END IF
      SET ctr TO ctr - 1
      SET loopLimit-n TO UNANSWERED
   END REPEAT

   // Overflow text
   SET SplitB-t TO LAST( TextVar, LENGTH( TextVar ) - LENGTH( SplitA-t ) )
   SET SplitB-t TO "(continued from form) ... «SplitB-t»"

   // Add an elipsis
   SET SplitA-t TO SplitA-t + "..."

// It will fit
ELSE

   SET SplitA-t TO TextVar
   SET SplitB-t TO ""

END IF

• Explanation •

Create and group the lines for the text in the form. Be sure to use a fixed-width font, such as Courier. Now create a temporary text variable to hold the text (set its Advanced options to "Don't warn if unanswered," "Ask only in dialog," and "Don't save in answer file"). In the example we called our variable SplitA-t.

Next create a field to hold the "(continued in Addendum x)" text. Create another temporary variable for this field. In the example, we called ours SplitB-t. Set its Advanced options as you did for the other. Under its "Overflow" property, provide this "Reference" text (or something else, if you prefer):

(continued in Addendum <REFNR>)

Next you need to determine roughly how many characters will fit in the main field. Give a buffer of about 4 characters per line for words that will wrap before the end of the line. In the example above, the max is 220.

Finally, you must call the computation above prior to the field so that it can split the field if necessary. If the text will fit, it is all assigned to SplitA-t. If it won't fit, it is split at the maximum character count. The first half is assigned to SplitA-t and the last to SplitB-t, which will overflow into the addendum.

The computation is, of course, more involved than we are describing here. It also uses a loop (as described in Computation #0015: Loops via REPEAT) to find the last space in SplitA-t and re-effect the split there. Otherwise the split will almost always occur in the middle of a word.

You will likely want to consult the model template below to see a working version of this scheme in an Automator template.


•  •  •  •  •  •  •

 

• Model Template •

This template has everything you need set up and configured for you. It will work as-is, or can be adapted to your variable and dialog names. It contains: 1) sample Word and WordPerfect templates (or an Automator form) to demonstrate an implementation of the computation, 2) a component file containing the computation and all supporting dialogs and variables, and 3) instructions for adapting the computation for your use.

(Go to the download page)

 
 

• Contributors •

LegalCS