LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Iterate while loop on command

This seems like it should be a relatively simple application of a while loop, but I can't seem to find the solution 😕 Basically I have a string control on my front panel for a filename (minus path/extension), and when I start up the VI I check if the file already exists. If it does, I'd like to start a while-loop in which each subsequent iteration only occurs when the string control is changed by the user.

 

The way I have it wired up now works fine (see attached), but it loops every 50 ms even while there's an invalid string. If possible I'd like to pass to the next iteration only after the control value has changed. This way I can display an error dialog of some sort that won't pop up every 50 ms. (Note: this is a piece of code from a subVI, hence the refnums and property nodes.)

 

Thank you!

0 Kudos
Message 1 of 9
(3,676 Views)

Use an event structure and a value changed event for the input control.

 

Overall, your code makes very little sense. Is this supposed to be a subVI? There are no connectors defined.

0 Kudos
Message 2 of 9
(3,668 Views)

Look into how to use an event structure and then use that to detect a change in the string control.  You also need to brush up on datflow concepts.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 9
(3,665 Views)

Okay okay, I only took the portion of the subVI that actually had the loop in it so I could illustrate what I am currently doing and what I wish to do and I made it its own file. There's obviously more to it than what I put in here, but I didn't include the rest of it because I didn't feel it was necessary. The reason for all the refnums is that I'm trying to check controls that are on the main front panel while I'm within this subVI loop. If you have a better idea than that, feel free to let me know. As far as I know references are the only way to access a control that may be changing once you've already entered a subVI.

 

Thanks for the tip on the event structure, I'll give that a shot tomorrow.

0 Kudos
Message 4 of 9
(3,655 Views)

You could bundle all your control refs into a cluster.  Typedef the cluster.  Use that cluster on your subvi front panel.  Update the typedefs you add more controls to your main front panel.  That way you don't have to keep updating the subvi front panel every time you add a control to the main front panel.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 9
(3,650 Views)

@phogan wrote:

The reason for all the refnums is that I'm trying to check controls that are on the main front panel while I'm within this subVI loop. If you have a better idea than that, feel free to let me know. As far as I know references are the only way to access a control that may be changing once you've already entered a subVI.

 

Thanks for the tip on the event structure, I'll give that a shot tomorrow.



Yes, refs are the only way to control front panel objects from another vi, but do you need to? Send the value to the checking vi and react to that, if need be return a Valid boolean or similar, that's how it's usually done.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 9
(3,615 Views)

The inputs to the subVI are set once the process is begun, no? So if I have to monitor user-input while a loop is running then I have to pass references in order to have the latest values. 

0 Kudos
Message 7 of 9
(3,608 Views)

@phogan wrote:

The inputs to the subVI are set once the process is begun, no? So if I have to monitor user-input while a loop is running then I have to pass references in order to have the latest values. 


Yes, but then you have some poor design choices, why should the sub-vi monitor main controls? You can send information as events or queues, or even store the information in an AE that's used in the sub-vi.

Still, the only button that should be needed to sent is "start" and "exit"

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 9
(3,595 Views)

Fair enough, I'm just working with what I inherited ;). The code originally had image creation as just one small piece of a subVI, but when you're collecting images as data you'd like to not accidentally overwrite a file because you forgot to change the filename. I was hoping to contain all the file checking within the same subVI since it's used in a few different main programs.

0 Kudos
Message 9 of 9
(3,585 Views)