Converting Hexadecimal Strings to Numbers

QUESTION: I have a hexadecimal value, 38fb, that I have read out of a file as a string. How can I convert this value to a long integer? If I try to use LONG I get a string conversion error.

ANSWER: You want to use the IDL function READS to read the string with a hexadecimal format and do the conversion for you. Your code will look like this:

  IDL> theString = '38fb'
  IDL> theNumber = 0L
  IDL> ReadS, theString, theNumber, Format='(Z)'
  IDL> Print, theNumber
       14587

Google
 
Web Coyote's Guide to IDL Programming