Click or drag to resize

Bin2L Function

X#
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.19
Syntax
 FUNCTION Bin2L(
	cSignedInt AS STRING
) AS LONG
Request Example 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: Long
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#
1ptrHandle := FOpen2("sales.dbf", FO_READ)    // Sales.dbf contains 84 records
2FSeek(ptrHandle, 4, FS_SET)            // Point to byte 4
3cRecords := Space(4)
4FRead(ptrHandle, @cRecords, 4)            // Read the number of records
5? LTrim(Str(Bin2L(cRecords)))            // 84
6FClose(ptrHandle)
See Also