[ Hex2Int ]


Convert an ascii hex string to a number. Accuracy is limited to 6 ascii chars.
The msbit (bit 23) is considered a sign bit and if set, the number is made
negative. Therefore, the converted number will be in the range -8388608 to
+8388607. No check is made on the ascii hex string (except a null string
check) so invalid hex chars are also converted.
On entry: a$ = the string to converrt.
On exit: a = the converted number.
Also uses b,c,d.
_AsciiHexToInteger:
  a$=ucase$(a$)              'convert all letters to upper case
  a=0                        'clear result
  b=len(a$) : if b=0 return  'a=0 if null string
  for c=b downto 1           'else loop thru string beginning at the right
     b$=char$(a$,c)
     d=asc(b$)               'get the ascii value of the char
     if d<=57 then           'if < "9" subtract "0"
        d=d-48
     else
        d=d-65+10            'if "A" to "F", subtract "A" and add 10
     endif
     a=a+d*(16^(b-c))        'mult converted char 1,16,256,4096,etc 
     if a>=8388608 a=a-16777216 'handle negative numbers here
  next
  return
  pages read