10-31-2014 03:09 PM
Ok, check this out. This just does not make any sense to me. First, you'll need to run it and create the two files. You're going to get an error at the close. Now...here's what doesn't make any sense to me. If you enable the disabled diagram and read that same file, you can look at how the file is being read and the data interpreted. How is that any different and not causing an error? I took the U8 and changed it back to its original Boolean Array[8] format and received no error. Which means the data was read as a U8 at some point. But...for whatever reason, cannot be read and displayed as a U8. What's up with that? What am I not understanding?
Solved! Go to Solution.
10-31-2014 03:23 PM
I'm really confused about what cases should be enabled and what not.
The only possible error I see in here is when you write the file you then try to read it before closing the file. But the file pointer is still at the end of the file, so you should get an End Of File error. If you set your file pointer to be at the start of the file after you wrote, then you would read your byte just fine.
10-31-2014 03:35 PM
Huh....no read and write. Either read or write. Gotcha.
10-31-2014 03:44 PM - edited 10-31-2014 03:45 PM
@DailyDose wrote:
Huh....no read and write. Either read or write. Gotcha.
Not quite. It is a matter of where the file pointer is.
The file pointer is what location in the file will be read from or written to, depending on what you do next. When you write to a file, the file pointer is set to be directly after what you just wrote. So when you write a new file, the file pointer is at the end of the file. So when you try to do a read when the file pointer is at the end of the file, an attempt of a read at the end of the file happens. But there is nothing left for it to read. Therefore you get an End Of File error.
So if you just added a Set File Position to set the file pointer to the start of the file, you can read your byte with no error.
10-31-2014 04:04 PM
I understand now. Thank you good sir!
10-31-2014 06:47 PM
Actually, where the file pointer is set to depends a lot on the open mode for the File Open function. Open, Open and Create will indeed set it to the end of file. Create or Replace will however truncate the file to 0 length and place the file pointer at the beginning (well after truncation the beginning and end of file is the same).