Click or drag to resize

Bin2L Function

Convert a string containing a 32-bit signed integer to a long integer.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.10
Syntax
 FUNCTION Bin2L(
	cSignedInt AS STRING
) AS LONG
View Source

Parameters

cSignedInt
Type: String
A 32-bit signed integer represented as a string — least significant byte first.  Only the first 4 bytes are used by the function; all others are ignored.

Return Value

Type: Int32
Remarks
Bin2L() is a conversion function that converts the first 4 bytes of a string to a long integer.  Typical applications include reading foreign file types in their native format then saving, reading, decrypting, and transmitting numeric data in their compressed binary form instead of in strings.  Its inverse is L2Bin().
Examples
This example opens a database file using file functions and reads the number of records (bytes 4-7).  The result is the same as LastRec():
X#
ptrHandle := FOpen2("sales.dbf", FO_READ)        // Sales.dbf contains 84 records
FSeek(ptrHandle, 4, FS_SET)                        // Point to byte 4
cRecords := Space(4)
FRead(ptrHandle, @cRecords, 4)                        // Read the number of records
? LTrim(Str(Bin2L(cRecords)))                        // 84
FClose(ptrHandle)
See Also