Support Links

Technical Bulletins

Customer Downloads

Code Generators

SmartCAM Email Forum

Patches and Utilities

Misc Resources

The Learning SmartCAM Tutorial

SmartCAM V11 Exploring Guides

Contacts


Maintenance Customer
Premium Content

SmartCAMcnc Technical Support

Topic: 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

    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]