Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5d

Application v 5.25a

  

 

Chapter FiveGeneral Functions (continued)

BinaryReadRecord Function

Overview

The BinaryReadRecord function directly read data into a series of variables from a buffer, Data or File Object.

Syntax/Parameters

Syntax

int = BinaryReadRecord ( param source, int position, param data, ... );

Parameters

target

A parameter as variable data or as a handle. If source is a variable, the binary content will be read. If a handle type is supplied, it must be to a Data Object or File Object.

position

An int specifying the zero-based position in bytes to put the new information within data. If set to -1, and the source is a File Object, data is read from the current position.

data

One or more variables to write to the target. The variables must be of specific types and configuration.

Return Value

Returns an int as the bytes read on success or a formatted error code on failure. Use the GetLastError and GetLastErrorMessage functions to retrieve a formatted error message or detailed error message.

Remarks

BinaryReadRecord allows formatted binary data to be read, presumably from external systems for data formats. Formatting is determined by the size and order of items.

Variables read must be of fixed size and type. Types string, wstring and handle cannot be read. Arrays must be of fixed size. For strings, use the char or wchar type as a fixed array.

Up to 30 variables can be written.

Integer data is read natively and expected to be in little-endian format (LSB, MSB). To change to big-endian, use swap functions such as Swap32Word.

Some systems perform byte packing, for example, a char buffer of 30 characters followed by a 32-bit integer. The external system may dword aline such that the integer starts on the 32nd byte, thus extending the last string. to adjust for packing, add byte or char padding variables as required.

The entirety or specified data is read from the source from the specified position or read from the current position if position is set to -1 and the source is a File Object. The return value is the size of the record read. The size can also be used to determine if the record matches the required imported size.

Related Functions

Platform Support

Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL

Legato IDE, Legato Basic