WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Numbers

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

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
File Created: 2002:09:05:13:51:20
Last Updated: 2002:09:05:13:51:20