NI TestStand

Showing results for 
Search instead for 
Did you mean: 

ReportText Newlines

I am using the ReportText output on the LabView standard adapter to put some analyzed data into the report, it the form of an html table. Because I am outputting a fair amount of html I would like to not have it on a single line, but if I put a newline in ReportText, it ends up being converted to a <br> in the final report. On the other hand, the string "\n" goes through uninterpreted. How can I get actual newlines into the html document?
0 Kudos
Message 1 of 8
Hi Jackson,

Turns out that there is a slight problem with the sequence responsible for replacing "\n" strings in the report text with a "
". To fix this, you will need to do the following:

1. Open the sequence file \Components\User\Models\TestStandModels\reportgen_html.seq.

2. Select the PutOneResultInReport sequence from the View ring.

3. Right click the step named "Add ReportText (Outbuffer)" and select Edit Expression.

4. Change the part of the expression that reads FindAndReplace(Locals.ReportText, "\n", "
") to FindAndReplace(Locals.ReportText, "\\n", "

Now when your report text property has a string that contains "\n", it will appear as a new line in the report. If your string contains
, this should wo
rk without making the above change.

Let me know if this works, or if you are using the DLL method to generate your HTML report.


Message 2 of 8
hmm, it appears we may be having a newline problem in your newline solution 🙂 Lemme see if I understand what you are saying. In my version of test stand, the expression for the "Add ReportText (Outbuffer)" step is currently:

Locals.ReportText = Parameters.Result.ReportText,
FindAndReplace(Locals.ReportText, "\n", "<BR>"),
Locals.ReportEntry += "<TR><TD COLSPAN=2 BGCOLOR=" + Parameters.ReportOptions.Colors.ReportTextBg + " valign=\"top\"><FONT SIZE=-1>" + Locals.ReportText + "\n"

This is different than what you have. If I assume that the difference is because the site translated your <br>'s into linebreaks, then your propsed solution would be:

Locals.ReportText = Parameters.Result.ReportText,
ReportText, "\\n", "<BR>"),
Locals.ReportEntry += "<TR><TD COLSPAN=2 BGCOLOR=" + Parameters.ReportOptions.Colors.ReportTextBg + " valign=\"top\"><FONT SIZE=-1>" + Locals.ReportText + "\n"

Am I correct to say that, in this case, Teststand would now convert a string with the escape code "\n", into a <br>, while leaving literal newlines and carriage returns (ASCII 0x0A and 0x0D) as they are?

Also, a side question on the binding strength of the comma operator. is the expression 'a = b , f(x)' interpreted as '(a = b) , f(x)' or 'a = (b , f(x))' ?

Oh, and yes I have been using the DLL method because it's faster. But lemme get back to you on that, because we may just end up outputting all this analyzed data I am talking about to a separate html file and just linking to it, from the TS generated html report. This would make my newline problem not a problem any more.

thank you!
0 Kudos
Message 3 of 8
Hi Jackson,

Looks like I overlooked that one 🙂 The correct statment would be:

Locals.ReportText = Parameters.Result.ReportText,
FindAndReplace(Locals.ReportText, "\\n", "<BR>"),
FindAndReplace(Locals.ReportText, "\n", "<BR>"),
Locals.ReportEntry += "<TR><TD COLSPAN=2 BGCOLOR=" + Parameters.ReportOptions.Colors.ReportTextBg + " valign=\"top\"><FONT SIZE=-1>" + Locals.ReportText + "\n"

This will leave your carriage returns alone and convert and "\n" to a new line.

The comma in TestStand is used to seperate expressions. Therefore, a = b, f(x) is evaluated as (a=b) and (f(x)).
0 Kudos
Message 4 of 8

In Teststand 2019, does FindAndReplace() exist?   I see only SearchAndReplace()

0 Kudos
Message 5 of 8

Michał Bieńkowski
Someone devote his time to help solve your problem? Appreciate it and give kudos. Problem solved? Accept as a solution so that others can find it faster in the future.
Make a contribution to the development of TestStand - vote on TestStand Idea Exchange.
0 Kudos
Message 6 of 8

Thank you.....


So, does this mean that known limitation No. 141627 happens because the FindAndReplace needs to be replaced with SearchAndReplace for the ReportGen_html?   

0 Kudos
Message 7 of 8

I think I found a possible workaround for ReportGen_html.seq (used Teststand 2019 as reference).,


  1. Went to PutOneResultInReport_Impl
  2. Then went to "Add Report Text (Outbuffer)". After some analysis, arrived to the conclusion that the original line FindAndReplace(Locals.ReportText, "\n", "<br>")  does nothing. A) FindAndReplace is no longer supported, and B) the text to be logged is in Locals.ReportEntry, and not in Locals.ReportText.
  3. Decided to fix the problem right after the corresponding text is introduced. This happens in the step "Add Flagged Values". This means that if in your parameters you decided to log to the report, then this steps grabs that and brings that text to the report generator.
  4. I made a new step right after this, called it "Fix Line Breaks", with this expression inside:   SearchAndReplace(Locals.ReportEntry, "\r\n", "<br>"),   This fix does the trick, at least for my application.



Message 8 of 8