CharToBin

Converts a binary 4 byte (Double Word) expression into VFP number.

CharToBin(lcBinString,llSigned)

Parameters

lcBinString
The binary string that contains the 32 bit binary data. This value is usually a value retrieved from a C structure or other memory based buffer.

llSigned
If the value is a signed number rather than an unsigned value set this flag. Note that VFP numeric integers are limited to signed sizes so a large unsigned number that exceeds 2 gigabytes may not translate correctly into a VFP number.

Remarks

This is a free standing function not a method.

This method works only with binary integer values that are exactly 4 bytes long (ie. a DWORD or LONG value).

Example

************************************************************************
FUNCTION GetTimeZone
*********************************
***  Function: Returns the TimeZone offset from GMT including
***            daylight savings. Result is returned in minutes.
************************************************************************

DECLARE integer GetTimeZoneInformation IN Win32API ;
   STRING @ TimeZoneStruct
   
lcTZ = SPACE(256)

lnDayLightSavings = GetTimeZoneInformation(@lcTZ)

*** First 4 bytes contain the timezone offset
*** Value is a signed 32 bit Integer
lnOffset = CharToBin(SUBSTR(lcTZ,1,4),.T.)

*** Subtract an hour if daylight savings is active
IF lnDaylightSavings = 2
   lnOffset = lnOffset - 60
ENDIF

RETURN lnOffSet

See also:

Class wwAPI

© West Wind Technologies, 2023 • Updated: 08/05/07
Comment or report problem with topic