LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there easier way to read specific strings from file?

Hi!

I would need to create GUI where user can select test cases from list box and execute them. When user selects one test case from list, test case description, details, etc. information should be displayed in string boxes to user. I did try use "read characters from file" and strings "match pattern" functions for this system, but I think it would come far too complex that way. Is there any easier way to do this or do I need to code this feature with C? User should be able to add more test cases to list so I can't use any "hard coded" values in my VI.
0 Kudos
Message 1 of 9
(3,502 Views)
you could save the information in XML form such as the following:


test case name string
file name string
tescription string
Detail string


.....next test case


Windows provides an activeX interface to get test cases and read the string values stored here. This will take a little work and there is a small learning curve for XML but such a format provides a few key advantages:
1. you can have an unlimited number of test cases
2. adding testcases can be done without programming (edit the text in a wordpad file
3. You can extend the format, add new tags to your test case as needed in the future.

To implement this you would add the code to the listbox value change event to read the xml file and get the matching node get the parent node, this is the test case node you are looking for and read the subtag text and pass the value string to the approperate indicator. I have been using XML to serialize data for the past year or so and have been pleased with the results but I am still a self taught novice when it comes to the full power of XML. But this is just a thought on your question, hope it helps.

-Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 2 of 9
(3,479 Views)
if all the information are delimited properly (using comma, semi colon, tab, etc), then you can read in the whole file (provided it is not too large), and use the "Spreadsheet string to Array" vi (under string pallete) to convert the string into 2D array of strings.

This however is not efficient if there are other data between each tests, in thoses cases, you might still want to use the matach patter vi in a loop.

-Joe
0 Kudos
Message 3 of 9
(3,479 Views)


@JanneT. wrote:
Hi!

I would need to create GUI where user can select test cases from list box and execute them. When user selects one test case from list, test case description, details, etc. information should be displayed in string boxes to user. I did try use "read characters from file" and strings "match pattern" functions for this system, but I think it would come far too complex that way. Is there any easier way to do this or do I need to code this feature with C? User should be able to add more test cases to list so I can't use any "hard coded" values in my VI.


Oops, the editor removed all the XML formatting, I will try it again

you could save the information in XML form such as the following:


test case name string
file name string
tescription string
Detail string


.....next test case


-paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 4 of 9
(3,475 Views)
Sorry I cant get the XML tsgs to go through, you can see the xml format in the attached .txt file
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 5 of 9
(3,474 Views)
Hi!

In my solution information is delimited with tab in .txt file. Problem is how I can read information from first column to list box and then depending on choices what user makes show specific information from other columns in string boxes (e.g. first is displayed test case names and after user select one of test cases, all information from same row will be displayed in string boxes).

If I use only "Spreadsheet string to Array" VI all columns are read at same time. Can I programmatically select in "Spreadsheet string to Array" VI which row in specific column will be read? Also if I have understood correctly "Spreadsheet string to Array", VI reads numerical values. How I can read ASCII strings with that?
(and if some one can show me how I can make conversion from "Spreadsheet string to Array" VI's array to 1D list box and vice versa, I would be very grateful).

If I would use XML notation instead of txt file, what benefit I could get on that? Would it make reading information separately from file easier with some VI? Also does LabView support direct programmatically writing to XML format, because in my solution user uses same GUI to create new test cases.
0 Kudos
Message 6 of 9
(3,457 Views)
Hi

Yes, LV provides vis to read and write xml-files.
In a project I'm working on I use xml-files. I see the following advantages:

1. It's easy to read because it is structured
2. As mentioned LV provides the necessary vis to use it

Attached is a zip-file containing a read-xml and a write-xml vi I use in this project.

Hope this helps.

Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 7 of 9
(3,444 Views)
The "Spreadsheet String to Array" is polymorphic, wire the input with desired array (1D or 2D), and the standeard format string (for string elements, a string constant is fine). See the attached image.

-Joe
0 Kudos
Message 8 of 9
(3,436 Views)
Check out the Configuration File VIs on the File I/O palette. They are simple to use, relatively fast, and the files can be trivially modified by hand.
0 Kudos
Message 9 of 9
(3,407 Views)