NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I send local string variable data to a text file?

Within my test sequence I am storing all my test results into a local string variable called ReportText.  I do this so that I can format it as required.  At the end of my test, I would like to send this string variable output to a text file for readibility.  There is an example on this website that I tried but it didn't work.  The example I tried is below.  When I run this in Test Stand I get the following error:
Could not find executable file: ''
-17208; File or directory not found.
 

EXAMPLE I found on NI site:

I'd like to create a text file or batch file programmatically as teststand runs, but I can't find any features to perform this action.



Solution:

Teststand does not support building text files or batch files programmatically, but we can use the command line to accomplish this feature. Use the Call Executable step, and call the executable cmd.exe, usually found at C:\WINDOWS\System32\cmd.exe. From the command prompt, the arguments that you will pass in are either:

Text File:

"/c echo (your message) >> C:\\test.txt"

Batch File:

"/c echo (your code) >> C:\\test.bat"

If you would like to put in multiple lines, you can use the '&' sign to cascade the commands which will result in a new line in the text file. For example:

"/c echo First line > C:\\test.txt & echo Second line >> C:\\test.txt

Something to note is that the command > will erase all previous text in a file while >> will append to the end of the file, and that the character for '\' in Teststand is represented by \\.

0 Kudos
Message 1 of 5
(10,402 Views)
Since you didn't provide a link to this example, I can't comment on what might be wrong. You are saving all test results in a single string? The easy answer is to simply pass the string to a code module. Whatever programming language you are using, I'm sure it has support for file writes. I'm curious though why you are using the built-in step result collection and the text report that the models provide? The text report is created by reportgen_txt.seq and because it's a sequence file, you can modify it to create the type of report you want.
0 Kudos
Message 2 of 5
(10,394 Views)
The reason I am creating a string for the text report is because this is the standard way of reporting results within our test group.  It allows flexibility in the way the results are presented.
In any event, here is the link to the example I cited in my original note:
 
0 Kudos
Message 3 of 5
(10,391 Views)

The reportgen_txt also provides for great flexibility without needing to use local variables and modifying how the the default process model works.

I don't get any error but I can't get it to write correctly. I still think the simplest way is to juse your string to a code module and do the write with the built-in file functions.

0 Kudos
Message 4 of 5
(10,388 Views)
Hey Buff,

I was able to get that example code working, and I posted a screenshot of what my step settings looked like for the Call Executable step.  However, I would recommend following Dennis's suggestion.  Reportgen_txt gives many more options, and it does not require modifying the process model.


Message Edited by Patrick P. on 07-20-2007 08:30 AM

Pat P.
Software Engineer
National Instruments
0 Kudos
Message 5 of 5
(10,367 Views)