GoFiler Legato Script Reference
Legato v 1.5d Application v 5.25a
|
Table of Contents | < < Previous | Next >> |
Chapter Six — File Functions (continued)
Overview
The FileToBuffer function loads the contents of a file into a contiguous buffer.
Syntax/Parameters
Syntax
int = FileToBuffer ( string name, var buffer, [int size] );
Parameters
name
A string containing a qualified filename and path. This parameter supports UTF encoding for filenames with Unicode characters.
buffer
A variable (typically a char or byte array) that will receive the resulting data. The buffer type must resolve to integer base type.
size
An optional int specifying the size of the data to read in bytes. If omitted, size is set to the size of the buffer parameter or to the file’s size. See Remarks below.
Return Value
Returns a int specifying the number of bytes read or 0 on failure. Since a file can be empty, 0 can be a valid value. Use the GetLastError function to retrieve error information. Additional narrative error information is available using the GetLastErrorMessage function.
Remarks
The file is opened with read and write share options and closed upon completion of the read operation.
The buffer parameter is typically a fix character or byte array, however, can be any type so long as it resolves into integer type data. For multiple dimension arrays, the data is essentially poured into the memory area without regard to axis size.
If buffer is declared as auto allocate (empty [ ]), the read operation will automatically expand the size of the array to accommodate the incoming data so long as the size parameter has not been provided. Auto allocation works only on a single-dimension arrays. The depth of the array is set to the size of the area rounded up by the size of the variable elements. For example, an int array will always have a total byte size in increments of four. See Section 3.6 Dimensional Data for more information on allocation.
If the buffer cannot be expanded and the incoming data is too large for the buffer, the entire buffer will be loaded and an ERROR_OVERFLOW condition set. Use the IsError or GetLastError function to check for an overflow.
If the file is larger than the buffer, an ERROR_OVERFLOW condition will be set and the returned bytes will equal the size requested or maximum size.
Related Functions
Platform Support
Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL
Legato IDE, Legato Basic
Table of Contents | < < Previous | Next >> |
© 2012-2024 Novaworks, LLC. All rights reserved worldwide. Unauthorized use, duplication or transmission prohibited by law. Portions of the software are protected by US Patents 10,095,672, 10,706,221 and 11,210,456. GoFiler™ and Legato™ are trademarks of Novaworks, LLC. EDGAR® is a federally registered trademark of the U.S. Securities and Exchange Commission. Novaworks is not affiliated with or approved by the U.S. Securities and Exchange Commission. All other trademarks are property of their respective owners. Use of the features specified in this language are subject to terms, conditions and limitations of the Software License Agreement.