GetByte


The GetByte method reads byte (8 bit) sequence from file and returns number of elements actually read. File position is moved forward by the number of bytes read.
C++
long GetByte(
  BYTE *ByteBuffer,                // buffer that receives data
  long NumberOfElements,           // number of elements to read
  long FilePosition = -1           // position of data in file
);
BASIC
GetByte(
  ByteBuffer As Variant,           // variant that receives data
  NumberOfElements As Long = -1,   // number of elements to read
  FilePosition As Long = -1        // position of data in file
) As Long

Parameters

ByteBuffer
C++
Pointer to buffer that receives data.
Buffer must be large enough to accept at most NumberOfElements bytes of data.
BASIC
Variant that receives data.
Variant type must be compatible with Byte data type; it can be either single variable or one-dimensional array.
Variant can be uninitialized; in such case it is converted to Byte.
NumberOfElements
Number of elements in data sequence to read.
BASIC
If this parameter is -1 length of sequence is determined by the size of ByteBuffer.
FilePosition
Position in file to read data at.
If this parameter is -1 data is read at current file position.

Return Values

If the method succeeds, the return value is the number of elements actually read.
The return value is 0 if end of file was encountered.
If the method fails, the return value is failure code and error code is set. Call GetError to get error code.

Remarks

Method returns the number of elements actually read, which may be less than expected if end of file is encountered prematurely.
BASIC
ByteBuffer can be either single variable or one-dimensional array depending on how many elements are to be read. If only one element is to be read, ByteBuffer can be a single variable of type Byte or an uninitialized variant; in the second case variant is converted to Byte type. If more than one element is to be read ByteBuffer must be a one-dimensional Byte array either fixed- or variable-size. If it is a fixed-size array its size must be large enough to accept at most NumberOfElements elements. If it is a variable-size array it may be redimensioned to appropriate size for accepting all elements; please note that array is redimensioned only if its size is too small - array size is never decreased.

See Also

GetByteAlloc, PutByte, GetBit, GetShort, GetLong, GetFloat, GetDouble, GetText, GetUnicodeText, GetVariant, GetBinary, Reading and Writing Data