Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5b

Application v 5.24b

  

 

Chapter FiveGeneral Functions (continued)

BinaryCopySegment Function

Overview

The BinaryCopySegment function copies a binary segment of data (raw memory) from a specified area of a variable or another specified variable.

Syntax/Parameters

Syntax

int = BinaryCopySegment ( param source, param destination,
                      [int s_pos], [int d_pos], [int size] );

Parameters

source

A parameter as literal or variable data or a handle. If a string type is supplied, the zero terminating byte is not included in the size. If a handle, it must be to a Data Object.

destination

A parameter as a variable or a handle. The binary content of which will be altered. If a handle, it must be to a Data Object.

s_pos

An optional int specifying the zero-based position in bytes to copy from source. If omitted, the value is 0.

d_pos

An optional int specifying the zero-based position in bytes to copy to dest. If omitted, the value is 0.

size

An optional int specifying the size of of the data to copy in bytes. If omitted, the available size of destination is used. Note that if a string type is used as the destination parameter, the size of the current string content will be used, less the zero terminator.

Return Value

Returns an int as ERROR_NONE on success or a formatted error code on failure.

Remarks

If source and destination are the same variable, BinaryCopySegment will compensate for the overlap. The function will not allow data to be copied from or to an area outside the scope of the specified variable.

When a string or wstring is a source or a destination, the size is calculated by using an internal string length function. For the source, this can make running off the end of the string easy, even as it is allocated to larger buffer than the length of the string. For the destination, the size should be specified to avoid the function stopping as a result of a buffer overrun.

BinaryCopySegment differs from BinaryPutSegment in that data can be copied within a variable and it works strictly with variables.

Related Functions

Platform Support

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

Legato IDE, Legato Basic