I2Bin Function | |
Convert a short integer to a string containing a 16-bit signed integer.
Namespace:
XSharp.Core
Assembly:
XSharp.Core (in XSharp.Core.dll) Version: 2.19
Syntax FUNCTION I2Bin(
siValue AS SHORT
) AS STRING
public static string I2Bin(
short siValue
)
Request Example
View SourceParameters
- siValue
- Type: Short
The value to convert. Decimal digits are truncated.
Return Value
Type:
StringRemarks
I2Bin() is a conversion function that converts a short integer to a 2-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 Bin2I().
Examples
This example opens a database file using file functions and writes a new date of the last update to bytes 1-3:
1ptrHandle = FOpen2("sales.dbf", FO_READWRITE)
2
3cYear := I2Bin(1990)
4
5
6cMonth := _Chr(12)
7cDay := _Chr(15)
8
9FSeek(ptrHandle, 1, FS_SET)
10
11
12FWrite3(ptrHandle, cYear, 1)
13FWrite3(ptrHandle, cMonth, 1)
14FWrite3(ptrHandle, cDay, 1)
15FClose(ptrHandle)
See Also