W2Bin Function | |
Convert a word to a string containing a 16-bit unsigned integer.
Namespace:
XSharp.Core
Assembly:
XSharp.Core (in XSharp.Core.dll) Version: 2.21
Syntax FUNCTION W2Bin(
wValue AS WORD
) AS STRING
public static string W2Bin(
ushort wValue
)
Request Example
View SourceParameters
- wValue
- Type: Word
The value to convert. Decimal values are truncated.
Return Value
Type:
StringRemarks
W2Bin() is a conversion function that converts a word into 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 Bin2W().
Examples
This example uses W2Bin() to store the current procedure line to a debugging file:
1FUNCTION ErrorLines() AS LOGIC
2 LOCAL nh
3 LOCAL lSuccess := FALSE AS LOGIC
4 nh := FOpen2("data.bin", FO_READWRITE)
5
6 IF nh != F_ERROR
7 FWrite(nh, W2Bin(ProcLine()))
8 FWrite(nh, W2Bin(ProcLine(1)))
9 FClose(nh)
10 lSuccess := TRUE
11 ELSE
12 ? "An error occurred when opening debug.bin"
13 FError()
14 ENDIF
15 RETURN lSuccess
See Also