How Can We Help?
< All Topics

How can I replace a Carriage Return/Line Feeds (CR/LF) in macros?

How can I replace a Carriage Return/Line Feed (CR/LF) with another character or replace other characters with a CR/LF?

The solution is to save a CR/LF to a text string variable. Using the Variable Set to ASCII Character command, save the ASCII value (13) for a carriage return to a text string variable. Then save the ASCII value (10) for a line feed to another text string variable.

Use the Variable Modify String command to join the two together. The macro steps would look like this in Macro Express 5 or Macro Express Pro. It would be similar in Macro Express 3.

Variable Set to ASCII Char 13 to %T[1]%
Variable Set to ASCII Char 10 to %T[2]%
Variable Set String %T[3]% to “%T[1]%%T[2]%”

Variable %T[3]% now represents a CR/LF.

After saving a text string to a variable, use the Variable Modify String command – Replace Substring option. Replace any CR/LF’s in the string by inserting %T[3]% in the Text to Replace field. Or replace other text with CR/LF’s by inserting %T[3]% into the Replace Text With field.

Or if using the Text Type command, insert %T[3]% into the text to play back a CR/LF.

– Applies to: Macro Express and Macro Express Pro