Click or drag to resize

DW2Bin Function

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.10
Syntax
 FUNCTION DW2Bin(
	dwValue AS DWORD
) AS STRING
View Source

Parameters

dwValue
Type: UInt32
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#
FUNCTION RecordMemory() AS LOGIC
        LOCAL nh
        LOCAL lSuccess := FALSE AS LOGIC
        nh := FOpen2("debug.doc", FO_READWRITE)
        // Assumes that file debug.doc already exists
        IF nh != F_ERROR
                FWrite3(nh, DW2Bin(Memory(1)), 4)
                FWrite3(nh, DW2Bin(Memory(2)), 4)
                FWrite3(nh, DW2Bin(Memory(3)), 4)
                FClose(nh)
                lSuccess := TRUE
        ELSE
                ? "An error occurred when opening debug.doc"
                FError()
        ENDIF
        RETURN lSuccess
See Also