LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"Read From Binary File" function Help ambiguity

I must be getting tired, but for some reason a doubt crept in my mind as I was designing a new piece of code this morning:

"is the "Read From Binary File" using the last file position or is it starting from the beginning of the file?"

"That's a stupid question", I told myself.

"I used this function a million times and have always assumed it is reusing the last file position. Moreover, there is no file offset input to that function, so WTH am I afraid of?"

 

So, for kicks, I fired up the Help window and read the following description (*):

 

Reads binary data from a file and returns it in data. How the data is read depends on the format of the specified file. This function does not work for files inside an LLB.

 

(*) BTW, has anybody ever complained that you can't select and copy anything from the floating Help Window?

 

Not much there. I particularly admire the phrasing of the second sentence... What about: "This function can do a lot of things, but it would much to complex to describe this is extensive details, so if you are asking, you probably can't afford using it"?

Anyhow, I clicked on the "Detailed Help" and got this (among other things):

 

Use the Set File Position function if you need to perform random access.

 

WHAT? I am pretty darn sure I DO NOT USE the Set File Position when I read a file in successive and contiguous chunks. I just pass the file refnum into a shift register and back to the function and that's it.

 

Now, the description of the "Refnum Out" ouput says: If file is a refnum or if you wire refnum out to another function, LabVIEW assumes that the file is still in use until you close it. Translated in plain English, is that supposed to mean that if the file is not closed it is open, or is that implying that it contains more info that just "the file is open and can be found here"?

I started searching around and finally ended up with the entry for "refnums, file I/O". Down the bottom of the (long) article, I found this under the heading "References to Objects or Applications" (but nothing specific to files, BTW):

 

...LabVIEW creates a refnum associated with that file, device, or network connection...

[...]  LabVIEW remembers information associated with each refnum, such as the current location for reading from or writing to the object and the degree of user access, so you can perform concurrent but independent operations on a single object. If a VI opens an object multiple times, each open operation returns a different refnum. LabVIEW automatically closes refnums for you when a VI finishes running, but it is a good programming practice to close refnums as soon as you are finished with them to most efficiently use memory and other resources.

 

So it seems that my recollection was correct. I do not know what the "degree of user access" for a file is, but that's not the topic of today's post. 

 

So, my point is: the Help File for this function is incomplete or ambiguous at best. Please correct it. And provide a link to the "refnum, file I/O" Help entry in its detailed Help. It would H E L P...

Thanks for reading.

 

 

0 Kudos
Message 1 of 3
(2,154 Views)
Reading in succesive chunks is *NOT* random access. An open file always has a current position, which is updated with each read or write operation. You only need to set the file position if you want to start elsewhere.
0 Kudos
Message 2 of 3
(2,146 Views)

Paraphrasing the clueless Inspector Clouseau: "I knoow that!". My point is that there is a lot of implicit knowledge assumed from the user in this function's help (as it should, to some extent), but the clarification of my sudden drawn blank required a lot more research than I would have expected.

Anyhow, happy Thanksgiving to all the turkey fans out there...

0 Kudos
Message 3 of 3
(2,140 Views)