Click or drag to resize

L2Bin Function

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

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

Parameters

liValue
Type: Int32
The value to convert.  Decimal digits are truncated.

Return Value

Type: String
Remarks
L2Bin() is a conversion function that converts a long integer into a 4-byte string.  Typical applications include reading foreign file types in their native format and then saving, reading, decrypting, and transmitting numeric data in their compressed binary form instead of in strings.  Its inverse is Bin2L().
Examples
This example creates a new binary file, then writes a series of numbers to the files using L2Bin() to convert the numeric value to 32-bit binary form:
X#
LOCAL nNumber, ptrHandle
ptrHandle := FCreate("MyFile", FC_NORMAL)
FOR nNumber := 1 UPTO 100
        FWrite3(ptrHandle, L2BIN(nNumber), 4)
NEXT
FClose(ptrHandle)
See Also