Owning Palette: File I/O VIs and Functions
Requires: Base Package
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.
|data type sets the type of data the function uses to read from the binary file. The function interprets the data starting at the current file position to be count instances of data type. If the type is an array, string, or cluster containing an array or string, the function assumes that each instance of that data type contains size information. If an instance does not include size information, the function misinterprets the data. If LabVIEW determines that the data does not match the type, it sets data to the default for the specified type and returns an error.|
|prompt (Open existing file) is the message that appears above the list of files and directories, or folder, in the file dialog box.|
|file (use dialog) can be a refnum or absolute file path. If it is a path, this function opens the file specified by the path. This function creates the specified file if it does not already exist. The default is to display a file dialog box and prompt you to select a file.If you specify an empty or relative path or if the file does not exist, this function returns an error.|
|count (1) is the number of data elements to read. Data elements can be bytes or instances of data type. The function returns count data elements in data, or if it reaches the end of the file, it returns all the complete data elements read thus far and an end-of-file error. By default, the function returns a single data element. If count is –1, the function reads the entire file. If count is less than –1, the function returns an error.If count calls for an array of elements and the specified data type is an array, the function automatically returns a cluster of arrays or cluster array because LabVIEW does not allow arrays of arrays.
|byte order sets the endian form of the resulting data. Byte order, or endian form, indicates whether integers are represented in memory from most-significant byte to least-significant byte or vice versa. The function must read the data in the same byte order that the data was written.
|error in (no error) describes error conditions that occur before this node runs. This input provides standard error in functionality.|
|refnum out is the refnum of the file that the function read. You can wire this output to another file function, depending on what you want to do with the file. The default is to close the file if it is referenced by a file path or selected from the file dialog box. 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.|
|data contains the data read from the file in the specified data type. It can consist of a string, an array, a cluster of arrays, or a cluster array, depending on which data type you are reading and how count is set.|
|cancelled is TRUE if you cancel the file dialog box. Otherwise, cancelled is FALSE, even if this function returns an error.|
|error out contains error information. This output provides standard error out functionality.|
Refer to the following VIs for examples of using the Read from Binary File function: