Table Of Contents

Read from Binary File (G Dataflow)

Version:
    Last Modified: April 3, 2017

    Reads binary data from a file, interpreting the data as a specified data type.

    connector_pane_image
    datatype_icon

    data type

    The data type that this node uses to read the binary file. By specifying the data type, you control how the node interprets the binary data. If the node determines that the data in the file does not match the specified data type, it sets the data output to the default value for the specified data type and returns an error.

    Size Information for Arrays, Strings, and Clusters

    If data type is an array, string, or cluster containing an array or string, the node assumes that each instance of that data type contains size information. If an instance does not include size information, the node misinterprets the data.

    Behavior of Array Data Types

    If you wire data to count and the specified data type is an array, the node automatically returns a cluster of arrays or cluster array because this node does not allow arrays of arrays.

    Default: 1D array of U8 numerics

    datatype_icon

    prompt

    Custom message in the title bar of the file dialog box that appears when you do not wire a value to the input path.

    datatype_icon

    file path

    The file that this node reads.

    This input can be a reference to a file or an absolute file path. The node opens the specified file without requiring you to call Open/Create/Replace File first.

    If you wire a path to file, this node opens the file before reading from it and closes it afterwards.

    If you specify an empty path, a relative path, or a path to a non-existent file, this node returns an error.

    datatype_icon

    count

    The maximum number of data elements to read. Data elements are instances of the specified data type.

    If this node reaches the end of the file before reading the specified number of data elements, the node returns the available data elements along with an end-of-file error.

    If count is -1, the node reads the entire file, characters or lines, unless the size of the file is too large to be represented by a 32-bit integer. In this case, the node returns an error. If count is less than -1, the node returns an error.

    spd-note-note
    Note  

    If you wire a file size with a data type other than a 32-bit integer to count, this node coerces the data type to a 32-bit integer. This means the program may not read the amount of data you intend. If you wire -1 to count and the size of the file you want to read is too large to be represented by a 32-bit integer, the program returns an error.

    Default: 1

    datatype_icon

    byte order

    The endian form that the node uses to interpret the binary file. Byte order, or endian form, indicates whether integers are represented in memory from most-significant byte to least-significant byte or vice versa. When reading a binary file, you must interpret the data in the same byte order in which the data was written.

    Name Description
    big-endian, network order

    The most-significant byte occupies the lowest memory address. This endian-form is used when reading data written on a different platform.

    native, host-order

    Uses the byte-ordering format of the host computer. This endian form increases read and write speed.

    little-endian

    The least-significant byte occupies the lowest memory address.

    Default: big-endian, network order

    datatype_icon

    error in

    Error conditions that occur before this node runs.

    The node responds to this input according to standard error behavior.

    Standard Error Behavior

    Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

    error in does not contain an error error in contains an error
    If no error occurred before the node runs, the node begins execution normally.

    If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

    If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

    Default: No error

    datatype_icon

    refnum out

    A reference to the file that this node uses.

    datatype_icon

    data

    The data read from the file in the specified data type. It can consist of an array, a cluster of arrays, or an array of clusters, depending on which data type you are reading and the value you wired to count.

    datatype_icon

    cancelled?

    A Boolean value that indicates whether the user cancelled the dialog box that appears if no input file was wired to this node.

    True The dialog box was cancelled.
    False The dialog box was not cancelled, or the dialog box did not appear.
    datatype_icon

    error out

    Error information.

    The node produces this output according to standard error behavior.

    Standard Error Behavior

    Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

    error in does not contain an error error in contains an error
    If no error occurred before the node runs, the node begins execution normally.

    If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

    If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

    Read and Write Permissions for Read from Binary File

    This node opens files as read-only. This node returns a permissions error if you wire the refnum outoutput of this node to the file input of a write node. Use the Open/Create/Replace File node to open the file with the default read/write access and wire the refnum to the read and write nodes. Use the Set File Position node if you need to perform random access.

    Where This Node Can Run:

    Desktop OS: Windows

    FPGA: This product does not support FPGA devices


    Recently Viewed Topics