This subroutine will load the entire contents of the given file into the specified buffer. The given buffer does not need to be initialized yet, as this call includes the required init procedure. However, it will not hurt, if the buffer is already initialized or even used and filled with data. But note, that in this case all previous content of the buffer is discarded and replaced by the loaded file data.
The call will also clear all markers and find data. The current buffer position is set to the first byte and the buffer will use the OS native line endings.
SYNTAX:
FileToBuf buf$(), fileSpec$
INPUTS:
buf$() (STRING array)
- This must be a 1-dimensional REDIMed (dynamic) STRING array of at least one element, it will be initialized and filled by this routine to become a usable buffer. In alternative it can also be the array of any existing buffer.
fileSpec$ (STRING)
- The name of the file to load into the buffer. You may also add a path, if required. Make sure the specified file exists to avoid errors.
NOTES:
- Although the buffer is in OS native line endings mode after loading, the loaded file is not converted automatically into the respective format, as this would probably corrupt files containing binary data.
- If you work with pure text files from different OS's you may want to call the ConvBufToNativeEol() subroutine right after loading the text file.
- In alternative you can also force the buffer to use the one or other line endings logic using the subroutines ConvBufToWinEol() or ConvBufToLnxMacEol().