Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.4j

Application v 5.22b

  

 

Chapter FiveGeneral Functions (continued)

RunLengthEncode Function

Overview

The RunLengthEncode function processes a buffer of information by performing a RLE encode.

Syntax/Parameters

Syntax

int = RunLengthEncode ( var in[], var out[], [dword escape] );

Parameters

in

A variable as the source buffer to encode. The variable source be a single-dimension array or a string. See Remarks for details.

out

A variable to receive the decoded data. The variable source be a single-dimension array or a string. See Remarks for details. The variable is not auto allocated and as such must be large enough to receive the result.

escape

An optional dword containing the encoding escape character. The default valuer is 0xEEEEEEEE.

Return Value

Returns an int as the number of returned bytes or zero on failure. Use the GetLastError and GetLastErrorMessage to retrieve a formatted error code and message.

Remarks

Run Length Encoding (RLE) is a simple method to quickly compress data. Repeated values are escaped by the escape parameter. Since the escape value may be used in the data, it will also be escaped in the encoding.

The buffer data types are restricted to char, string, wchar, wstring, byte, short, word, int, and dword. The type will break down to 1, 2 or 4 byte segments and the encoding will be performed on that basis. As such, the source data should be optimized to the structure of the incoming data. For example, a 24-bit bitmap stores data in 32-bit dwords, therefore the best encoding will happen with 4 byte values or a dword array.

The size of the in buffer is determine either as the axis depth or, if a string type, the string size.

The out buffer must be preallocated to the appropriate size or an ERROR_OVERFLOW will occur. In addition to the return value, the axis depth of the output buffer is set to indicate the size of the data.

Related Functions

Platform Support

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

Legato IDE, Legato Basic