LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

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

Solved!
Go to solution
Highlighted

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

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
(146 Views)

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

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

 

-------------------------------------------------------------------
Unfortunately, most readers of this Forum, including some real Experts, have not mastered the skill of being able to read the code that Posters fail to post. If we cannot see "what you did wrong", we are unable to tell you how to fix it. (Bob Schor 28 August 2018)
0 Kudos
Message 2 of 6
(131 Views)

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


@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).


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
0 Kudos
Message 3 of 6
(96 Views)

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

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
(84 Views)

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

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?

-------------------------------------------------------------------
Unfortunately, most readers of this Forum, including some real Experts, have not mastered the skill of being able to read the code that Posters fail to post. If we cannot see "what you did wrong", we are unable to tell you how to fix it. (Bob Schor 28 August 2018)
0 Kudos
Message 5 of 6
(82 Views)
Solution
Accepted by topic author snarkysparky
03-14-2019 12:00 PM

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

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
(81 Views)