Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5b

Application v 5.24b

  

 

Chapter FiveGeneral Functions (continued)

Get8String Function

Overview

The Get8String function retrieves an 8-bit string from a buffer at a specified byte position for a specified length.

Syntax/Parameters

Syntax

string = Get8String ( buffer data, int position, [int characters] );

Parameters

data

A buffer as bytes, chars, string, any variable type or to a Data Object. This is referenced on a byte by byte position to read all bytes.

position

An int specifying a zero-based position in bytes. This should point to the start of the data for the string. If the position plus the size of the data element is outside of the scope of the buffer, a range error will be returned.

characters 

An optional int specifying the number of characters to retrieve. If set to -1, the function will read until a zero (/0) terminator is encountered. If omitted, the value defaults to the total buffer size less the specified position.

Return Value

Returns a string comprised of the data read or empty on failure. Use the GetLastError function to retrieve error information.

When copying to the zero terminator (-1 for characters parameter), the last error will contain the number of characters copied without the zero terminator.

Remarks

The Get8String function allows a script to reach into a buffer and access a specific set of characters that presumably make up a string.

If the source information contains a zero byte, it will terminate the returned string at that position. Should the specified area not contain an ending zero byte, one will automatically be added. Using a size of -1 allows zero-terminated string to be copied from the buffer without knowing the length of the source string.

When the source data is a string or wstring type, the allowed data range is the allocated string size, not the string length (the character count to the terminating zero).

Use the GetLastError, IsError or IsNotError functions to differentiate between a return value of an empty string and an error.

Related Functions

Platform Support

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

Legato IDE, Legato Basic