05-12-2012 11:30 AM
I have a text file which looks like this:
ref#1 2.1 3.0 -10
ref#2 3.3 -2.3 -1.5
I'd like the user to be able to:
A. key in a line number in the VI numeric control, and the numeric displays in the VI display the corresponding numbers in that line.
e.g. If user key in "1", the three numeric displays show "2.1", "3.0" and "-10"
B. key in a string in the VI string control, and the numeric displays in the VI display the corresponding numbers in that line which contain the string
e.g. If user key in "ref#2", the three numeric displays show "3.3", "2.3" and "-1.5"
Any sample code?
Solved! Go to Solution.
05-12-2012 11:50 AM
We cannot really tell what you text file looks like. What are the delimiters? (tabs? spaces?).
Here's what I would do (if the file is clean (one unique column delimiter, etc.)):
See how far you get ...
05-12-2012 12:06 PM
To get you started, I would read the file using the "Read from Spreadsheet file.vi" and delete off the first column. You can then index off the row of numbers. You can also use the Search 1D Array with the deleted column in order to search for you row index. Give it a try from here. If you need additional help, show us what you have tried and we'll get you there.
05-12-2012 12:17 PM
I am actually programming VBAI (NI's Vision Builder for Automatic Inspection) and use LV's VI as custom user interface - which means VBAI would feed data to the VI.
One restriction of using VI with VBAI is that, dependencies are not allowed - which means in my VI I cannot have and subVIs.
Therefore the "Read from Spreadsheet file" subVI cannot be used in my case.
05-12-2012 12:29 PM
Then read the entire file as a string and use the Spreadsheet string to Array primitive.
05-12-2012 12:49 PM
I would actually recommend using the Run LabVIEW VI Step, which does allow for dependencies and then you can use all the Fil I/O and parsing functionality of LabVIEW. You can pass the line number requested in the Custom UI to the Run LabVIEW step and the Run LabVIEW step can return the three numbers, which a Update Custom UI step can use to update the values on your custom UI.
Hope this helps,
Brad
05-13-2012 03:26 AM
Oh yes this solved the dependencies problem 🙂