Internet Direct (Indy)
Home
PreviousUpNext
BytesToShort Function

Ordinal value of the TIdByte argument. 

Converts a TIdByte value to the ordinal datatype.

Pascal
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. 
Internet Direct (Indy) version 10.1.5
Copyright © 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Website http://www.indyproject.org.
Post feedback to the Indy Documentation newsgroup.