Convert a string containing a 16-bit unsigned integer to a word.
XSharp.Core (in XSharp.Core.dll) Version: 2.6
Syntax Request Example
cUnsignedInt AS STRING
) AS WORD
public static ushort Bin2W(
- Type: String
A 16-bit unsigned integer represented as a string — least significant byte first. Only the first 2 bytes are used by the function; all others are ignored.
Bin2W() is a conversion function that converts the first 2 bytes of a string to a word. 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 W2Bin().
This example opens a database file using file functions and reads the number of bytes per record (bytes 10-11).
The result is the same as RecSize():
1ptrHandle := FOpen2("sales.dbf", FO_READ)
4FSeek(ptrHandle, 10, FS_SET)
5cRecSize := Space(2)
6FRead(ptrHandle, @cRecSize, 2)