FUNCTION buf2dword(lcBuffer) RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ; BitLShift(Asc(SUBSTR(lcBuffer, 2,1)), 8) +; BitLShift(Asc(SUBSTR(lcBuffer, 3,1)), 16) +; BitLShift(Asc(SUBSTR(lcBuffer, 4,1)), 24) FUNCTION buf2word(lcBuffer) RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ; Asc(SUBSTR(lcBuffer, 2,1)) * 256The names of the functions are some kind fuzzy, you probably can come with better ones. The BitLShift also poses some limits. Still it works, I use them all the time with API calls.
FUNCTION num2dword(lnValue) #DEFINE m0 256 #DEFINE m1 65536 #DEFINE m2 16777216 IF lnValue < 0 lnValue = 0x100000000 + lnValue ENDIF LOCAL b0, b1, b2, b3 b3 = Int(lnValue/m2) b2 = Int((lnValue - b3*m2)/m1) b1 = Int((lnValue - b3*m2 - b2*m1)/m0) b0 = Mod(lnValue, m0) RETURN Chr(b0)+Chr(b1)+Chr(b2)+Chr(b3) FUNCTION num2word(lnValue) RETURN Chr(MOD(m.lnValue,256)) + CHR(INT(m.lnValue/256))Also check this link on FoxPro Wiki: