How do I enter a line break (or other non-text characters usually solved with escape characters) in a StringVar in Crystal Reports?
Wanted output:
line 1
line 2
I've tried StringVar s := "line 1 \n line 2";
, but that does not work.
If you need to add a line break in a formula field just use the ChrW function which “returns the single character text string associated with the Unicode value passed in” with the value of 13. The Unicode value associated with 13 is the carriage return. "This formula field " + ChrW(13) + " contains a line break!"
You can also select this option from the Format menu. Use the Format Line tab to set the formatting specification for a line in the report. This list shows all the available styles for the line, such as: Single, Dashed, Dotted, and so on. Click the button that represents the line width you want to use.
Chr(10) is the Line Feed character and Chr(13) is the Carriage Return character.
i have simply used following code for line break
"This formula field " + ChrW(13) + " contains a line break!"
It may not be much of an improvement, but you could build a string-formatting, custom function:
// sf()
Function (Stringvar text)
Stringvar Array keys := ["\n"];
Stringvar Array values := [Chr(10)+Chr(13)];
Numbervar i;
For i := 1 to Ubound(keys) do (
text := Replace(text, keys[i], values[i])
);
text;
//{@ text}
sf("line 1 \n line 2")
This would offer you some extensibility should you need to support additional escape sequences.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With