|
GetShort
|
|
|
The GetShort method reads short integer (16 bit) sequence from file and returns number of elements actually read. File position is moved forward by the number of bytes read.
C++
long GetShort(
short *ShortBuffer, // buffer that receives data
long NumberOfElements, // number of elements to read
long FilePosition = -1 // position of data in file
);
BASIC
GetShort(
ShortBuffer 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
- ShortBuffer
-
C++
Pointer to buffer that receives data.
Buffer must be large enough to accept at most 2 * NumberOfElements bytes of data.
BASIC
Variant that receives data.
Variant type must be compatible with Integer data type; it can be either single variable or one-dimensional array.
Variant can be uninitialized; in such case it is converted to Integer.
- NumberOfElements
- Number of elements in data sequence to read.
BASIC
If this parameter is -1 length of sequence is determined by the size of ShortBuffer.
- 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 or there is not enough data in file.
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.
Only complete elements can be read - at least 2 bytes must be available in file for reading to get next element.
If there is not enough data in file for next full element processing is finished and file is positioned after last complete element.
BASIC
ShortBuffer 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, ShortBuffer can be a single variable of type Integer or an uninitialized variant;
in the second case it is converted to Integer type. If more than one element is to be read ShortBuffer must be
a one-dimensional Integer 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
GetShortAlloc,
PutShort,
GetBit,
GetByte,
GetLong,
GetFloat,
GetDouble,
GetText,
GetUnicodeText,
GetVariant,
GetBinary,
Reading and Writing Data