` Printed Icetips Article

Icetips Article



Par2: Hex to decimal conversion
1999-01-31 -- Lee White
 
Not sure if this is what you're looking for...

Hex2Dec FUNCTION(? hString)

lVal                LONG,AUTO
sPos                BYTE,AUTO
Correction          BYTE,AUTO
hCstring            CSTRING(11),AUTO

  CODE
  hCstring = CLIP(hString)
  lVal = 0
  Correction = CHOOSE(UPPER(SUB(hCstring,-1,1)) = 'H',1,0)
  LOOP sPos = 1 TO LEN(hCstring)-Correction
   lVal = lVal*16+(INSTRING(hCstring[sPos],'0123456789ABCDEF',1,1))-1
  END
  RETURN(lVal)

Probably better ways but this should get you started.



Printed November 23, 2024, 10:21 pm
This article has been viewed/printed 35206 times.