Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


UDF - Long to Dword

Keywords: 	 UDF - Long to Dword

Below is a UDF to convert a long number to a DWORD:
#DefineFunction UDFLong2Dword(long)
   X2_32="4294967296"
   X2_31="2147483648"
   Bill2=2000000000
   Bill3=1294967296
   Bill4=294967296
   if long >= 0 then return(long)
   long = -long
   ;Message(0,long)
   ;figure out billion range
    billion=2
    if long<=bill3 then billion=3
    if long<=bill4 then billion=4
    if billion==4
         dword=strcat(billion,strfixleft(bill4-long,0,9))
    else
         if billion==3
            dword=strcat(billion,strfixleft(bill3-long,0,9))
         else
            dword=strcat(billion,strfixleft(bill2-long,0,9))
         endif
    endif
 
   return (dword)
#EndFunction



x=-123456789
y=UDFLong2Dword(x)
Message(x,y)
;Message(x,y+0) can be used to verify numeric equivalence

Article ID:   W15317