SmartCAM Technical Bulletin
Inserting new lines in Macro variables

Technote 217
Date: 03/06
Product: All
Version: All

Problem:
How do I add new lines in a single string variable? How do I insert carriage returns?

Solution:
Use the STRTMP function and the new line character \n, followed by a physical carriage return.

Note: The information in this technical bulletin applies to all SmartCAM applications. For users running SmartCAM v14.5 or greater, there are new, better methods for handling multi-line strings and string concatentation. See the Automating SmartCAM sections of both the SmartCAM Customization Guide and Learning SmartCAM for more information. Both are available from Help - Online Manuals in your SmartCAM applications.

For example, suppose you have a set of variables declared as String and wish to concatenate them into a single variable, #var_main, separated by carriage returns. The Macro command would look like this:

#var_main=STRTMP("
%#var_1\n
%#var_2\n
%#var_3\n
%#var_4\n
%#var_5\n
%#var_6\n
%#var_7")]

These MUST be separated by physical carriage returns. Placing them all on the same line will output the literal \n and no new lines.

The following is a working example that you can copy and paste into a macro file. The last PAUSE command will display the #var_main variable on a seven row tall message box.

STRING: #var_1
STRING: #var_2
STRING: #var_3
STRING: #var_4
STRING: #var_5
STRING: #var_6
STRING: #var_7
STRING: #var_main

#var_1="1st var"
#var_2="2nd var"
#var_3="3rd var"
#var_4="4th var"
#var_5="5th var"
#var_6="6th var"
#var_7="7th var"

#var_main=STRTMP("
Line 1: %#var_1\n
Line 2: %#var_2\n
Line 3: %#var_3\n
Line 4: %#var_4\n
Line 5: %#var_5\n
Line 6: %#var_6\n
Line 7: %#var_7")]

PAUSE[TX=#var_main, SR=7]