Tuesday, July 6, 2010

strFmtLB and the newline character (\n) in label files

You want to split your info message into multiple lines, so you use the \n newline character.
You write the following code:-
You tested it's working and the output message is split into 2 lines as below:-

Now you've converted the string into a label, so you update your code such as the one below:-
But when you re-run the code, you realised that the newline character is no longer working and printed directly on screen. The message is displayed as one line instead of two as below:-

To display the message correctly, you need to use the global method strFmtLB:-
If your string message contains placeholders (%1, %2, etc.), then you can use both strFmtLB and strFmt methods together:-
info(strFmtLB(strFmt("@SYS39890", "Line1", "Line2")));
Result of running the above code:-

No comments: