Showing results for 
Search instead for 
Did you mean: 

File I/O : file is opened/created and modified without problem but error 1 on closing

Go to solution


Rather bizarre a problem, I successfully open/create a file, then edit it without problem. But I get error 1 input parameter invalid when closing the file.

The program is structured as a state machine implemented using case structure wired to an integer control. The file refnum is stored in an indicator after creation for use via local variables in other cases. I have used refnum to path for visualising it throughout the course of the program. It appears that in the last case, the refnum suddenly changes to "not a filepath", which then goes in to the close file vi.

Any help?

0 Kudos
Message 1 of 6

Probably just a bug. We cannot help if you do not provide the code.

Marc Dubois
HaroTek LLC


0 Kudos
Message 2 of 6

There's probably a "Use default if unwired" tunnel in there somewhere.  Easy to find if you had attached the code, otherwise we are guessing what error you made (and it is almost certainly an error, not a bug).  Attach your Code, or Find it Yourself.


Bob Schor

0 Kudos
Message 3 of 6

Hi, thanks for your responses. The actual code is huge (running a couple of cDAQs), so I took some screen shots of the file creation and close segments. The writing is done in another loop, which stops well before the file is to be closed. Opening the file manually shows that the values were indeed written correctly.

I'm not sure if it is best practice to use local variables for propagating refnums, but this isn't the first time I've done it, and it has always worked for me. Frankly, I don't see why the refnum goes blank (path indicating not a file) just when I want to close the file. In all preceding steps, the refnum to file converter continues to show the correct path. What am I missing? 4 months of work and I'm stuck at this one snag!

0 Kudos
Message 4 of 6
Accepted by topic author fsahmed
05-20-2019 05:39 PM

UPDATE : Stupid error. The close file was in a state from which the exit depended on a button i.e. multiple loop cycles (facepalm). Ashamed of myself. Thanks for all your help. 

0 Kudos
Message 5 of 6

I'm not wasting your or my time looking at pictures of your code which probably does not include the error (or else you would have found it).  Don't worry about the size of the code -- I need it all, and will throw out the parts that are irrelevant to this problem and reduce it in size (you could have done this, but chose not to, persisting in the unsafe practice of using local variables).


Attaching the VI seems a trivial price to pay for four months of work.  It doesn't guarantee we'll find the problem, but makes it much more likely ...


Bob Schor

0 Kudos
Message 6 of 6