NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read in text string pairs from an external txt file?

I have an external txt file containing 26000 pairs of strings in the format

 

string1a   string1b

string2a   string2b

.

.

.

string26000a string26000b

 

all strings are always 4 characters in length.  For example,

 

a123   jkdh

b456   uusp

 

How can use TestStand 2013 to input this data into local string array varaibles?  I also have legacy testers running TestStand 3.5, so I need a TestStand 3.5 solution as well.  Thanks in advance for any ideas.  Hopefully this can be done in TestStand without the use of LabView or LabWindows/CVI.

0 Kudos
Message 1 of 7
(6,387 Views)

Unfortunately, it is not possible to directly use TestStand to read this type of file and assign the values to a string array. Instead, you can use a simple code module written in a language of your choice to read in the data. The code module can pass an array back to TestStand to set the values. The advantage to this approach (as opposed to TestStand implementing file access functions) is that you have complete control over how your data is read from the file and processed into an array.

 

You mentioned not wanting to use LabVIEW or LabWindows/CVI--could you provide some insight into why you would like to avoid that? Perhaps if there is a specific roadblock you encountered while trying to implement this, we could suggest possible solutions.

 

Hope it helps!

0 Kudos
Message 2 of 7
(6,374 Views)

Daniel E., thanks for the reply. 

 

     It is very frustrating to have to implement workarounds in order to access text in an external file when using TestStand.  TestStand already reads in text ini files, so it would probably take a TestStand software developer all of 1/2 day to write the code and 1/2 day to debug it.  Here I will restate the obvious.  Engineers have to deal with data, sometimes data generated from other applications.  Sharing data in a text file is one of the most basic functions (and one of the easiest to implement).  When I think of all the effort needed to support ActiveX, but NI did not see it fit to give TestStand users simple text file read/write functionality, it does not make sense to me.  Maybe it was too simple or mundane a task so it did not get developed?  Whatever the reason, I think users of TestStand deserve this basic functionality.

 

     Even if TestStand cannot read the data directly into array variables, it should provide some mechanism to read the text from the file, either line by line or all file text into a string, so the data could then be parsed into the array variables I need.

 

     I will pursue a CVI or LabView solution.  Please also know that I am not directing these comments at you, I do appreciate your reply.

 

Regards,

Ron

0 Kudos
Message 3 of 7
(6,357 Views)

1) For feature requests, I recommend posting to the idea exchange - http://forums.ni.com/t5/NI-TestStand-Idea-Exchange/idb-p/teststandideas

 

2) If you save a file as xml (see the sequence file properties for a file), you will get a text-based format that TestStand understands. If you create an empty sequence with a local variable with an array of strings with a few elements in it, you will get a better idea of what that format looks like. If you can convert your file into something of that format, teststand would be able to read it. You could similarly use the ini format if you prefer, though I think you'll find the xml format more understandable. You can also use the Engine.SerializeObjects/Engine.UnserializeObjects APIs specifying SerializationOption_UseXml to serialize or unserialize individual properties programmatically as xml (or other formats).

 

Hope this helps,

-Doug

0 Kudos
Message 4 of 7
(6,349 Views)

I am not asking for help. I am providing another example of how NI does not provide tools/functions to properly use the software across all of their platforms.

 

Our environment uses TestStand, LabWindows, as the preferred coding method, and LabVIEW. We have various versions of each. I am using the Digital Waveform Editor to create my hsDIO waveform files. These files are stored in a .hws formatted file. I have to use the LabVIEW nihws.llb library to read those files into TestStand. There is no .dll file for niHWS that would be located in the IVI foundation folders. I created a script file for my .hws files using the NI Script Editor. That program stores the scripts into a .txt text file. Now I need to determine how to read those text files into TestStand so that I can pass the script to my hsDIO function. I will probably have that working, using LabWindows, before anyone could respond to a post.

 

0 Kudos
Message 5 of 7
(6,332 Views)

I solved my issue by executing the Windows functions for opening, reading, and closing a text file. The read gets the entire file contents which is what I need. I have enclosed the sequence file in the event that may help you.

0 Kudos
Message 6 of 7
(6,303 Views)

After some testing and strange behavior, I have corrected what I previously submitted. I added a function to get the file size, in bytes, so that I could tell the read command how much data to read. The strange behavior is that, after the read, my script data, most of the time, contained some extra garbage at the end of the script data. This would happen more often than not. The cause could be that I have not set something up correctly in TestStand. I always welcome someone educating me and pointing out my mistakes. My solution was to add a post-expression to the read command which would only accept the left most "number of bytes equal to the file size" thus truncating the garbage at the end.

 

0 Kudos
Message 7 of 7
(6,237 Views)