LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

my program creates a text file then on the second run i get error 8 trying to open it

Solved!
Go to solution

The program purpose is to save a count in a file on the PC at a folder location specified to it.

 

If the file doesn't exist it creates it.

 

I want it to write the count to the first text line in the file, overwriting the line that was there previously.

After the initial run when it creates the file the text file will have a "0" on the first line.

 

On the second run there will be an error 8 opening the file and the first line will be blank in the file.

THanks

 

0 Kudos
Message 1 of 6
(2,457 Views)

What exactly are you trying to do here?

 

You have a "3" wired to the "Open/Create/Replace file" vi yet that input only accepts values 0 through 2 if you are going to use integers

 

BTW: the 3 is probably getting coresed to a 2 and that is open the file in Read Only mode

 

Instead of using integers why don't you just right click on the terminal and select "create constant" so you know what is is supposed to be doing just by looking at it.

 

123Capture.PNG

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 6
(2,442 Views)

@RTSLVU wrote:

BTW: the 3 is probably getting coresed to a 2 and that is open the file in Read Only mode


Actually, that would be Write-Only, which would give you an error when you try to read.

 

Back to the OP, is there anything else supposed to be in that file?  If so, you might run into issues when the count grows to 10 (extra bye, you might overwrite data you don't want to).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 6
(2,407 Views)

I fixed it.  The "3" was suppose to wire to the next terminal for read/write function.

My intent is to write a complete line with the numeric converted to string.

 

When count needs updating just read the line -> convert string to number -> increment and write back to file after resetting the file pointer to zero. 

 

It seems to work.

Thanks all

0 Kudos
Message 4 of 6
(2,395 Views)

I still don't understand what exactly you are trying to do, and "Rube Goldberg" is the first thing that pops into my mind when looking at your code.

 

Could you please explain in detail what the little routine is supposed to do?

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 6
(2,393 Views)
Solution
Accepted by snarkysparky

I got rid of the error by doing the following:

  1. Change Operation to Open or create
  2. Access read/write
  3. Add a return/newline character
  4. Remove convert EOL

mcduff

PS There is a lot that can be done to improve this code

Snap24.pngSnap25.png

0 Kudos
Message 6 of 6
(2,392 Views)