Bin2W Function | |
Convert a string containing a 16-bit unsigned integer to a word.
Namespace:
XSharp.Core
Assembly:
XSharp.Core (in XSharp.Core.dll) Version: 2.21
Syntax FUNCTION Bin2W(
cUnsignedInt AS STRING
) AS WORD
public static ushort Bin2W(
string cUnsignedInt
)
Request Example
View SourceParameters
- cUnsignedInt
- 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.
Return Value
Type:
WordRemarks
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().
Examples
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)
2
3
4FSeek(ptrHandle, 10, FS_SET)
5cRecSize := Space(2)
6FRead(ptrHandle, @cRecSize, 2)
7? NTrim(Bin2W(cRecSize)))
8FClose(ptrHandle)
See Also