Convert a string containing a 32-bit signed integer to a long integer.
XSharp.Core (in XSharp.Core.dll) Version: 2.2a
Syntax View Source
cSignedInt AS STRING
) AS LONG
public static int Bin2L(
- 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.
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().
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():
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