09-18-2015 02:00 PM
So I'm trying to read a text file line by line, and I've already seen some VI's that do this. However, I want to go a step further and save some strings as local variables. My background is in Matlab, where there's a 'workspace" where all local variables are saved and can be used/called later. I was wondering a "workspace" of saved local variables exists within LabVIEW- and if not, how I would go about saving particular lines from my text file as some sort of variable that I can access later, or in a another sub-VI.
Thanks
09-18-2015 02:30 PM
09-18-2015 02:42 PM
You can think of wires as variables.
You really need to get a handle on dataflow though, and let go of text-based languages.
If you plop an ADD function on your diagram, the function needs two input wires. As soon as somebody "writes" a wire, whoever is waiting on that data can execute.
The ADD function waits until BOTH inputs have a new value, then it executes, and puts the result on the wire going out of it, where some other function might be waiting on it.
There are places where actual storage happens, but think of wires as variables and you will get over the beginner's hurdle.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
09-18-2015 02:42 PM
The primary LabVIEW equivalent of "variables" are "wires". Try to step back a bit from the paradigms you've learned in Matlab as you learn LabVIEW ones. There are secondary features of LabVIEW that can be used more like the "dataspace" you're thinking of, but LabVIEW is inherently multithreaded, which works badly with such by-reference data access.
09-18-2015 03:30 PM
In case it wasn't clear from the previous answers, the wires can be thought of as variables.
09-18-2015 06:15 PM - edited 09-18-2015 06:19 PM
Can we think of wires as variables?
Edit:
In seriousness, if you want to initialize variables, a common way is to use the configuration palette with a ".ini" file.
If you just want to know how to access variables later, then a global or action engine (functional global) might serve you well. You will find a lot of information if you type "labview action engine" into google, and you can start with a "storage" case which reads a text file and stores the data you want, as well as a "read" case which lets you access the data.
09-21-2015 08:55 AM
Think data flow...wires...variables...am I too late to the party? Need to check this more often on the weekend I guess.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
09-21-2015 09:33 AM
I think it depends on what you are trying to achieve. If you have a specific project, some details would enable us to give you the correct method.
LabVIEW does have global variables that you can use, it is covered in Core 2 training. But as to whether you would use that, would completely depend on what the specific task was. Global variablies are not used that frequently because there is better ways of doing many things in LabVIEW.
You could think of a wire as a variable but the only way to access that data is to link the wire to something. Its not saved somewhere that you can recall in another section of code unless they are linked by wires or you use global variables.
09-21-2015
10:18 AM
- last edited on
12-16-2024
04:07 PM
by
Content Cleaner
LabVIEW programming is based entirely on dataflow and parallelism. This is incredibly powerful and has lead to its success over the years (coupled with the graphical programming), but is usually one of the first things that new developers stumble over. The Highlight Execution feature is a great way to watch how your application utilizes dataflow through the wires (vars).
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
09-21-2015 06:03 PM
Thanks for the answers so far, I understand now that saving the variables may not be the best way to think about solving this problem . Here's some more details as to what the exact problem is. I have a text file formated like this:
x,y, length, hieght
5,5,10,6
names of files
kappa.exe
smorc.txt
Theres a line with a description, and some numbers or strings that follow. What I want to manipulate are the "variables" like 5,5,10,6 or kappa.exe and smorc.txt. The parts of the text file that should remain unchanged are the descriptions like "names of files" and x,y,length,height. At the end of the day, the GUI will have some boxes where a user can change these "variables" to their liking (like changing some but not others) and save a new text file. So far, I've made a VI th/at concatenates strings into the format u see above; I created numeric and string controls where applicable so that the user can create a new txt file in this format. However, what if there already exists a text file with some variables?
This is where I am struggling. I also want the VI to read the text file and display what variables are already in place in those numeric and string control boxes. Then the user should be able to manipulate the variables in those boxes and save a new text file. So this is where I started thinking that reading and then saving a line as a workspace variable, since this would be one way of doing it in matlab. I'm trying to recreate this process in LabVIEW, but it looks like itll have to be done another way.
any ideas or help would be greatly appreciated!