Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.4j

Application v 5.22b

  

 

Chapter FiveGeneral Functions (continued)

BinaryCompare Function

Overview

The BinaryCompare function compares two buffers of binary data and returns a result of the comparison.

Syntax/Parameters

Syntax

int = BinaryCompare ( param a, param b, [int size] );

Parameters

a   b

Parameters as literal or variable data. The binary content of which will be used for the comparison.

size

An optional int specifying the size or area to compare in bytes. Size cannot be larger than the size of the smaller of a or b in bytes. If omitted, the smaller of a or b is used as the size. If a string type is used as a variable, the size is calculated as the string length (to the terminating zero byte but not including the zero byte).

Return Value

Returns an int as -1, 0 or 1 depending on whether a < b, a == b or a > b, respectively or a formatted error code on failure. The GetLastError function can be used to retrieve error information and also will contain the size of the buffer tested. The IsError or IsNotError functions can be used to determine if an error occurred (testing a -1 condition as the return value will result in a false positive).

Possible errors returned are all related to the size of the buffers. If size is specified and is larger than either a or b, an ERROR_RANGE will be returned and if size is negative (other that -1 for default), an ERROR_RANGE will also be returned. The lower word of the error will contain the parameter that failed as 1, 2, or 3 for a, b, and size respectively.

Remarks

Strings are always treated as a zero-terminated for the purposes of sizing, even if the allocated amount is larger that the data content.

Related Functions

Platform Support

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

Legato IDE, Legato Basic