home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a084 / 2.ddi / CKSAMPLE / HEX2INT.PRG < prev    next >
Encoding:
Text File  |  1993-05-25  |  563 b   |  23 lines

  1. function hex2int
  2. parameter in_str,flipit
  3.  
  4. * This routine takes a string of hex bytes and 
  5. * converts them to an integer.  The order in 
  6. * which the bytes are evaluated is set by flipit.
  7.  
  8. int_value = 0
  9. multiplier = 1
  10. in_str = alltrim(in_str)
  11.  
  12. if flipit
  13.     for x = 1 to len(in_str)
  14.         int_value = int_value + (asc(substr(in_str,x,1))*multiplier)
  15.         multiplier = multiplier*256
  16.     endfor
  17. else
  18.     for x = len(in_str) to 1 step -1
  19.         int_value = int_value + (asc(substr(in_str,x,1))*multiplier)
  20.         multiplier = multiplier*256
  21.     endfor
  22. endif
  23. return int_value