? NumToDWord(DWordToNum([¯º00])) && correct show ? NumToDWord(DWordToNum([0¯º0])) && correct show ? NumToDWord(DWordToNum([00¯º])) && correct show ? NumToDWord(DWordToNum([¯º¯º])) && incorrect show *** where input are Zero as dummy inside. FUNCTION NumToDWord LPARAMETER tnNum LOCAL c0, c1, c2, c3 lcResult = REPL(CHR(0), 4) if tnNum < (2^31 - 1) c3 = chr(int(tnNum/ (256^3))) tnNum = mod (tnNum, 256^3) c2 = chr(int(tnNum/ (256^2))) tnNum = mod (tnNum, 256^2) c1 = chr(int(tnNum/ (256))) c0 = chr(mod(tnNum/ (256))) lcResult = c0+c1+c2+c3 ENDIF RETURN lcResult ENDFUNC FUNCTION DWordToNum LPARAMETER tcDWORD local ln0, ln1, ln2, ln3 ln0 = ASC(SUBSTR(tcDWORD, 1, 1)) ln1 = ASC(SUBSTR(tcDWORD, 2, 1)) * (256) ln2 = ASC(SUBSTR(tcDWORD, 3, 1)) * (256^2) ln3 = ASC(SUBSTR(tcDWORD, 4, 1)) * (256^3) RETURN ln3+ln2+ln1+ln0 ENDFUNC>
>* the following fails on pan-chinese win nt 4.0 sp 5 >* VFP 6.0 sp 5 ver. 06.00.8961.00 >lowbyte = 192 >hibyte = 63 >word = chr(lowbyte) + chr(hibyte) >? "l",asc(substr(word, 1, 1)) && 192 - correct >? "h",asc(substr(word, 2, 1)) && 63 - correct >? "w",asc(substr(word, 1, 1)) + asc(substr(word, 2, 1)) * 256 && 16320 - correct >? "fWORDToNum1", fWORDToNum1(word) && 65342 - wrong >? "fWORDToNum2", fWORDToNum2(word) && 65342 - wrong >wait > >function fWORDToNum1 > *Take a binary WORD (16 bit USHORT) and convert it to a VFP Numeric > lparameter tcWORD > return asc(tcWORD) + bitlshift(asc(substr(tcWORD, 2, 1)), 8) >endfunc > >function fWORDToNum2 > *Take a binary WORD (16 bit USHORT) and convert it to a VFP Numeric > lparameter tcWORD > return asc(tcWORD) + asc(substr(tcWORD, 2, 1)) * 256 >endfunc >