Topic Path: Symbol Reference > Functions > BytesToShort Function
ContentsIndexHome
PreviousUpNext
BytesToShort Function

Ordinal value of the TIdByte argument. 

Converts a TIdByte value to the ordinal datatype.

File
function BytesToShort(
    const AValue: TIdBytes; 
    const AIndex: Integer = 0
): Short;
Parameters 
Description 
AValue 
Values to be converted.
 
AIndex 
Initial offset into the array of bytes top use when converting to the ordinal dat type. Default value is 0. 

BytesToShort is a utility function used to convert byte values specified in AValue to the ordinal data type. 

AIndex indicates the initial byte position in AValue to use when converting byte values to the ordinal data type. 

Please note that AValue should have an allocated length large enough to store the required number of bytes for the ordinal data type starting at the offset indicated in AIndex. When AValue is too small, an EAssertionFailed exception will be raised and the return value for the function is 0 (zero). 

 

For the .Net platform, the ToInt16 method from the FCL System.BitConverter class is called using the specified offset into the array of bytes to prepare the return value for the function. 

 

For all other platforms where pointer operations are supported, the return value for the function is derived by casting and de-referencing a pointer for the ordinal data type using the specified offset into the array of bytes in AValue. 

Use one of the following utility functions to convert TIdByte values to another ordinal datatype: 

 

Exceptions 
Description 
EAssertionFailed 
Raised when AValue is too small to store the required numnber of bytes for the ordinal data type starting at the specified offset into the array of bytes. 
Copyright © 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Post feedback to the Indy Docs Newsgroup.