Click or drag to resize

DW2Bin Function

X#
Convert a double word to a string containing a 32-bit unsigned integer.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.21
Syntax
 FUNCTION DW2Bin(
	dwValue AS DWORD
) AS STRING
Request Example View Source

Parameters

dwValue
Type: DWord
The value to convert. Decimal digits are truncated.

Return Value

Type: String
A 4-byte string containing a 32-bit unsigned integer.
Remarks
DW2Bin() is a conversion function that converts a double word to 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 Bin2DW().
Examples
This example uses DW2Bin() to record our current memory settings to a debugging file:
X#
 1FUNCTION RecordMemory() AS LOGIC
 2    LOCAL nh
 3    LOCAL lSuccess := FALSE AS LOGIC
 4    nh := FOpen2("debug.doc", FO_READWRITE)
 5    // Assumes that file debug.doc already exists
 6    IF nh != F_ERROR
 7        FWrite3(nh, DW2Bin(Memory(1)), 4)
 8        FWrite3(nh, DW2Bin(Memory(2)), 4)
 9        FWrite3(nh, DW2Bin(Memory(3)), 4)
10        FClose(nh)
11        lSuccess := TRUE
12    ELSE
13        ? "An error occurred when opening debug.doc"
14        FError()
15    ENDIF
16    RETURN lSuccess
See Also