LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Conditional Create File

I would like to somehow create a conditional create file. Like this way a user can press a boolean button and that will determine whether the VI will write to file or not. However, when I tried to use the case structure, that would not work, because it required an output for the case of "Fase" ie do not write. Any suggestions would be appreciated.

Robert
0 Kudos
Message 1 of 9
(2,857 Views)
That is by design of the case structure. What is the output of the case structure? Is the file creation inside or outside the case structure? What's your code look like? How about posting a screenshot or the VI?
0 Kudos
Message 2 of 9
(2,851 Views)
Image is attached...thanks. I am trying to have it so it will only write to file when I want it to. IE some of the time it makes little sense for me to need to write to file.
0 Kudos
Message 3 of 9
(2,845 Views)
That's a little different than your original question, which was to conditionally create a file. I can't quite see what you're doing with the Boolean control, but for one thing, there's no need to convert the Boolean to a number, and then check to see if it's greater than 1. Just wire the Boolean directly to the case structure! Same thing!

It seems that you're now asking that you want the Boolean to not only disable the conditional create, but also to turn off all writing. In this case, you have to wrap each write with a case that's driven by the front-panel Boolean.

Tip: In the loop you seem to be wanting to add a EOL to each number and using a loop to do it. Just use the Write to Spreadsheet File function. This will allow you to wire the numerical array directly without needing to use a loop.
0 Kudos
Message 4 of 9
(2,822 Views)
You are correct regarding my intentions with the VI. However, I am still uncertain about how to accomplish what you suggested. Don't you need to have something in the case statements for the false condition...
0 Kudos
Message 5 of 9
(2,816 Views)
You do. You just need to wire through what you wired in, or right-click on the terminal and select "Use default if unwired" if there's nothing wired in. If you use the mid-level file I/O functions this would be the file refnum and the error. If you use the Write to Spreadsheet File there's nothing to wire through. See attached example (LabVIEW 8.2).


Message Edited by smercurio_fc on 02-29-2008 11:45 AM
0 Kudos
Message 6 of 9
(2,808 Views)
Maybe you shouldn't have just the file create in the case structure, but the file create and the file write.  That way, nothing has to come out of the structure.


Message Edited by JeffOverton on 02-29-2008 12:51 PM
0 Kudos
Message 7 of 9
(2,801 Views)
Thank you so much for your assitance. I will look over your code and implement it into my VI.

Thanks again.
Robert
0 Kudos
Message 8 of 9
(2,794 Views)
The example I posted was for demonstration only. If using the standard File IO functions, then the two cases outside the for-loop can obviously be combined. You still need the error cluster to wire through and the refnum for the writing inside the loop since that depends on the refnum created by the open file function.
0 Kudos
Message 9 of 9
(2,789 Views)