LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Overwriting existing file

Hello everyone

 

I am using the "file dialog" to feed the "open/create/replace file" with the path and a filename suggestion. I put them inside a small while loop because I want to have the "file dialog" showed again on the screen if the file already exists and the user press "cancel" after the message "This file already exists. Do you want to replace it?".

 

My VI is working like a charm for my purpose but I would like to know if I can achieve the same behavior without using the small while loop. I am asking that because I really don't like to use a while loop inside the main while loop. Too dangerous.

 

Thanks

 

Dan07

 

Screen.jpg

 

0 Kudos
Message 1 of 5
(3,506 Views)

Hi dan,

 

Try using a case structure that will send it back round to the intial state using the select function and enums.

Basically a state machine architecture, this should be the option you are looking for.

If you are not familiar with this then read through this link: State Machines

Hope this helps!

John McLaughlin
Academic Account Manager
National Instruments UK & Ireland
Message 2 of 5
(3,486 Views)

Hi John

 

I was thinking about a State Machine but the problem is that the real code is not exactly as this example. In the real life I have a main VI with two while loops: producer and consumer. Inside the producer there is a Event Structure that detects changes on some controls in front panel of main VI and Enqueue states that will be used in a state machine inside the consumer loop.

 

The code with the "file dialog" will be inside a SubVI that will be in one of the cases of the case structure of the consumer loop and I am afraid about using a while loop in this SubVI. To follow your suggestion I have to have a while loop that will keep the SubVI "alive" and then I can use a State Machine as you suggested.

 

At this scenario, do you think that would be better to have (inside the SubVI) a small while loop (as the example that I sent in the previous message) or a big while loop around the whole code of the SubVI and a state machine that would manage the "file dialog" ?

 

Thanks

 

Dan07

0 Kudos
Message 3 of 5
(3,474 Views)

Hello John

 

Could you help me with my last question? This issue is very important for me.

 

Thanks

 

Dan07

0 Kudos
Message 4 of 5
(3,433 Views)

Dan - 

 

You could consider changing the mechanical action of the BOOL to "Switch When Released". This allows programmatic setting of the value using Property Nodes, whereas the latching action precludes Value PN's. Use "Val(Sgnl)" to continually retrigger the event in the case that the user cancels. Note, in the False case of the Case Structure I added, there's a regular Value PN to reset the value False again (since it's not automatically Unset, as when using Latching methods)

 

Fundamentally, I don't know if I agree with this UI behavior, so you may consider if it's a nuisance or expected behavior to "force" the user to choose a good filename. 

 

Hope this helps, minus the crazy Ref Control created from using a Snippet: (reference the screenshot below the snippet to see the code as I see it)

 

SavingDataContinually.png

 

How I see it:

SavingDataContinually2.png

 

0 Kudos
Message 5 of 5
(3,414 Views)