06-24-2011 10:23 AM
Labview fundamentals question....
I have a reference.....my understanding is a reference is like a pointer.
I would like to copy the reference so that I have two separate and equal references.
Example, a reference to a graph.
06-24-2011 10:24 AM
Drag and drop your existing reference while holding down the control key.
06-24-2011 10:29 AM
Sorry, wasn't detailed enough.
I would like to copy the reference programatically. Each time the program runs I would like to have two identical references.
I generate the graph, then create a reference from that graph. I would then like a copy of that reference, so that I have copied all the memory for one graph to another reference location. Giving me two identical graphs with different references.
06-24-2011 10:43 AM
A control reference is a handle that is used to locate the resource associated with a control and in your case a graph.
Copying the reference can be done by simply branching your wire coming from the reference OR you can do as you were told earlier OR pop-up on the graph and create another ref.
But that will only copy the 32 bit number that is used to start the search for the resources.
If you want to use references to copy from one exisitng graph to another exisitng graph (they must both be created at edit time) then after creating your second grpah and creating a reference for it...
Use property nodes to read all of the data and setting you read using one of the refs to popertyt nodes for the second graph.
Gird-up your loins!
Copying all of the properties for everything in a graph is a challlenge that I have never risen too. Pcik the properties you really need and stick with them.
If your graph has multiple plots or scales etc, then you will have to loop through each of them using the "Active whateever" to select which one you are reading from and which one you are writting to.
And before you run into another issue...
You can only set porperties an method on plots scales etc that exist in the graph. If the first time you try to copy 140 plots from the first to the second, it will fail if the second has never seen 140 plots.
I hope that gets you started.
Ben
06-24-2011 10:51 AM
Yes, I had thought of that, but it seems to over complicate a problem that should be done in an easier fashion.
Using the control click drag method is not programatic and only copies the reference one time, I want to copy it each time the program run.
branching doesn't work because then you havn't copied the information stored where the reference points to, you just copied the address. This results in any property modifications, modifiying the original, meaning it's not a copy.
Is there not a way to copy the memory location?
If I wanted to copy the data a pointer points to,
Data || Memory location
data || pointer 2 = data || pointer 1
06-24-2011 10:59 AM
A reference is not a pointer. There are no pointers in LabVIEW (unless you're making calls to DLLs). Could you perhaps explain the problem you're trying to solve, rather than the approach you're trying to use to solve it, and see if we can come up with a better solution? If you just need to get at the data from a graph, you can use the History Data property; wiring that to another graph will copy the data from one graph to another.
06-24-2011 10:59 AM
@eximo wrote:
Yes, I had thought of that, but it seems to over complicate a problem that should be done in an easier fashion.
Using the control click drag method is not programatic and only copies the reference one time, I want to copy it each time the program run.
branching doesn't work because then you havn't copied the information stored where the reference points to, you just copied the address. This results in any property modifications, modifiying the original, meaning it's not a copy.
Is there not a way to copy the memory location?
If I wanted to copy the data a pointer points to,
Data || Memory location
data || pointer 2 = data || pointer 1
Controls and indicators are not data buffers!
Yes some of them have data buffers but in LV they should be thought of as being GUI widgets.
If you want the same dat to show on both just wire the same data to the terminal or property node >>> value of both.
LV will copy the data to both.
One more suggestions:
LV is not like other languages and the sooner you leav those other language ideas and concepts the better of you will be.
Ben
06-24-2011 12:35 PM
is there no way to duplicate a graph from it's reference?
06-24-2011 12:50 PM
@eximo wrote:
is there no way to duplicate a graph from it's reference?
I outlined the work in my earlier post.
It is possible if you do what I said.
I suspect you are getting confused because you are thinking about LV as if it is a text based langauage. It is not. LV handles all of the resource allocations and all of that tedious nonsense from other languages for you. That is why all you have to do is wire the data from one graph to another using either terminals or property node >>> value nodes.
So we are not keeping any secrets from you.
Ben
06-24-2011 01:06 PM
As Ben said, it would be a lot of work to do what you want.
The question is what are you REALLY trying to do? Why do you need to copy the graph and all its settings? Where is the original graph and where is the second graph and what are you using it for?