LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

string from while-loop to an other while loop

We have a string in a while loop, which we want to export to an other while loop. In this 2nd loop we want to send the string with the Datasocket Write. On the receive side there is no string shown. We do have a connection. We personally think that the problem is the string exporting to the other while loop. Could this be the problem? 
0 Kudos
Message 1 of 6
(3,357 Views)
Could be. How are you exporting it from one loop to the other? In the loop that's doing the datasocket, have you put a probe on the data input of the datasocket write function to see if there's any data? Post a picture (no bmp please) or the actual VI you've written.
0 Kudos
Message 2 of 6
(3,343 Views)
It is unclear exactly what you are trying to do, but I have made a VI that may do the trick.

0 Kudos
Message 3 of 6
(3,337 Views)
We tried some other options, but it still isn't working. We've put a probe between the loops, but inside the upper loop there's a string. Once we put it outside the loop, it's gone.    So we posted a jpg of the project. I think you will know the answer to our problem.
0 Kudos
Message 4 of 6
(3,315 Views)
Ahh... it is now clear what is being done.  The while loop (top) does not "transmit" anything until you have hit the "stopprogramma" button and stopped the while loop (top).  Likewise, the while loop (bottom) will not start to operate until it has received all its inputs (including the input from the top loop). 
So when you run,the top loop will begin itterating and the bottom loop wont start until you hit "stop programma".  At that point, it will send to the bottom loop which will begin to itterate. 

Anyway, there are numerous ways to do this (assign to a hidden control or indicator as I did on my last submission) but this is a good chance to use notifications.  Attached is an example of how this might occur (though I might do it a little differently, I was trying to follow your format).  What is good is that the bottom loop will only change if the top sends a notifier.  In your picture, the bottom loop is itterating very quickly, sending the same string to your data socket over and over until you hit "stop verbinding."

Of course, maybe you want this.
0 Kudos
Message 5 of 6
(3,310 Views)
The actual reason data is not being transfered is because there is no iteration (step) to send the data to the next loop.  The while loops will cycle until the stop condition is met, but the background will only do one iteration per program run.  Think of the blank block diagram as a one shot run, and the structures in the execution control menu as mini block diagrams capable of doing multiple runs or in a sequence.  The only data that would ever enter into the second loop on startup would be data that is allready present on the input line. 
 
The solution to this is, and I might even suggest doing this also for those stop buttons, is to create an indicator in the top while loop for the data you want transfered.  Right click on this indicator, in the block diagram, and hide it if you do not wish it to be seen.  Right click on it again and go down to the create > option, and select local variable.  This will create a local variable that is a copy of the data at that indicator.  Blank local variables are also found in the structures menu.  You may also change what it is linked to by left clicking on the word.  Drag this local variable into the second while loop.  The default for local variables is to write to, right click on it and select Change to Read.  Wire the output on the local variable into where you want the data sent in the second loop. 
 
This can also be used with those stop buttons unless you want the option to stop one of the loops before the other.  Right click on the control, create the local variable, change to read and replace the second button on the block diagram with your new local variable.
0 Kudos
Message 6 of 6
(3,303 Views)