ReadBinaryFile (FPScript)

21.09.2021

Reads a data series from a binary file.

Syntax

ReadBinaryFile(File, Start, NumberOfBlocks, BlockSize, Skip, DataType)

 

The syntax of the ReadBinaryFile function consists of the following parts:

Part

Description

File

String with the path of the binary file to be read.

Permitted data structures are scalar value. Supported data types are string (file name).

If the argument is a list, then the function is executed for each element of the list and the result is also a list.

Start

The number of bytes to be skipped at the start of the file.

Permitted data structures are scalar value. All integral data types are permitted.

If the argument is a list, then the function is executed for each element of the list and the result is also a list.

NumberOfBlocks

The number of blocks to be converted. If zero is passed, all of the blocks are converted up to the end of the file.

Permitted data structures are scalar value. All integral data types are permitted.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

BlockSize

The number of values per block.

Permitted data structures are scalar value. All integral data types are permitted.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

Skip

The number of bytes to be skipped between the blocks.

Permitted data structures are scalar value. All integral data types are permitted.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

DataType

The data type in which the values are available.

The argument DataType can have the following values:

Constant

Meaning

TYPE_INTEGER8

The values present as 8-bit integers.

TYPE_INTEGER16

The values present as 16-bit integers.

TYPE_INTEGER32

The values present as 32-bit integers.

TYPE_INTEGER64

The values present as 64-bit integers.

TYPE_FLOATINGPOINT32

The values present as 32-bit floating point values.

TYPE_REAL48

The values present as 48-bit floating point values in Turbo Pascal format.

TYPE_FLOATINGPOINT64

The values present as 64-bit floating point values.

TYPE_CALENDARTIME

The values are present as 64-bit floating point values and are interpreted as the number of seconds since 1/1/1970 00:00:00 UTC.

TYPE_TIMESPAN

The values are present as 64-bit floating point values and are interpreted as time span in seconds.

+ BIN_UNSIGNED

If this constant is added to TYPE_INTEGER8, TYPE_INTEGER16 or TYPE_INTEGER32, then the data are interpreted as unsigned integers. 64-bit integer values can only be read in signed.

+ BIN_SWAP

If this constant is added, then the bytes of a value are read in reverse order (high byte first).

Permitted data structures are scalar value. Supported data types are 16-bit integer und 32-bit integer.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

Remarks

The result always has the data structure data series.

From a certain position, the function reads a sequence of associated blocks between which there may be a gap of a constant size.

The result is a data series for which the data type corresponds to that of the values to be read. The following formats, which must be output at a higher resolution, form exceptions:

Data type

Is imported as:

TYPE_INTEGER8

16-bit integers.

TYPE_INTEGER8 + BIN_UNSIGNED

16-bit integers.

TYPE_INTEGER16 + BIN_UNSIGNED

32-bit integers.

TYPE_INTEGER32 + BIN_UNSIGNED

64-bit integers.

TYPE_REAL48

64-bit floating point values.

Available in

FlexPro View, Basic, Professional, Developer Suite

Examples

ReadBinaryFile("c:\\examples\\file.bin", 10, 0, 16, 4, TYPE_FLOATINGPOINT32)

The binary file c:\examples\file.bin will be read. The first 10 bytes will be skipped. Data will be read until the end of file. There are 16 values read per block with a 4-byte space between the blocks. The values are present in 32-bit floating point data type.

See Also

ReadTextFile Function

File Import

Share article or send as email:

You might be interested in these articles