The HotDocs Computation Archive  

// Start with the whole address Addresst // Turn the first line break into a comma SET Tempn TO POSITION( RESULT, "\r" ) IF Tempn > 0 FIRST( RESULT, Tempn  1 ) + ", " + LAST( RESULT, LENGTH( RESULT )  Tempn  1 ) END IF // Turn the second line break into a comma SET Tempn TO POSITION( RESULT, "\r" ) IF Tempn > 0 FIRST( RESULT, Tempn  1 ) + ", " + LAST( RESULT, LENGTH( RESULT )  Tempn  1 ) END IF // Turn the third line break (if any) into a comma SET Tempn TO POSITION( RESULT, "\r" ) IF Tempn > 0 FIRST( RESULT, Tempn  1 ) + ", " + LAST( RESULT, LENGTH( RESULT )  Tempn  1 ) END IF // Turn the fourth line break (if any) into a comma SET Tempn TO POSITION( RESULT, "\r" ) IF Tempn > 0 FIRST( RESULT, Tempn  1 ) + ", " + LAST( RESULT, LENGTH( RESULT )  Tempn  1 ) END IF
Addresses in HotDocs are often handled by a single, multiline field that holds the complete address. While this is a simple approach, it can make things difficult when a singleline address is needed.
This computation takes a multiline address field and returns the address in singleline format. So,
Acme Consulting
Box 945
123 Some Street
Anytown, USA 12345
becomes
Acme Consulting, Box 945, 123 Some Street, Anytown, USA 12345
The computation first retrieves the value in the text field Addresst. It then begins looking for line breaks ("\r"). Each time it finds a line break, it separates the text before and after the line break, and then reassembles them with a separating comma. This computation will remove up to four line breaks, which should be sufficient.
The computation requires a temporary number variable, Tempn, which is used to store the character position of the line break.
As an alternative, you could use the looping technique described in Computation #0015  Loops via REPEAT to locate and remove the line breaks. An example is provided in Computation #0130, Multiline to Singleline. That method is used in the model template below.
NOTE: In determining where a line break occurs, it is important to remember that a line break is actually two characters long (line feed character + carriage return character).
This template has everything you need set up and configured for you. It will work asis, 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.