03-14-2019 09:58 AM
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
Solved! Go to Solution.
03-14-2019 10:16 AM - edited 03-14-2019 10:19 AM
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.
03-14-2019 12:51 PM
@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).
03-14-2019 01:23 PM
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
03-14-2019 01:27 PM
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?
03-14-2019 01:40 PM
I got rid of the error by doing the following:
mcduff
PS There is a lot that can be done to improve this code