comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: [Q]: reading hexadecimal numbers from text files
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: [Q]: reading hexadecimal numbers from text files [message #24514 is a reply to message #24512] Mon, 02 April 2001 16:58 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Erin McKay (intrigue@ozemail.com.au) writes:
>
> I'm working with some DICOM files that are not supported by IDL's built-in
> access functions. I've written a DICOM parser and would like to make use
> of an external DICOM dictionary. But I can't figure out how to interpret
> ASCII strings as hexadecimal coded integers (its always the little
> things...). For example, I need to read lines like:
>
> 7FE0, 0010, 'CS', 'Pixel Data'
>
> and interpret the first 3 fields as unsigned short integers. I also need
> to print these values back out as they are displayed here.

I have no idea how to read 'CS' into a short integer, but
hexadecimal values are quite straightforward. You use
the "Z" format to transfer the data back and forth:

IDL> variable = 0U ; Create an unsigned short integer.
IDL> Read, variable, Format='(Z4)'
: 7FE0
IDL> Help, variable
VARIABLE UINT = 32736

You do the same thing to write it out:

IDL> Print, variable, Format='(Z4)'
7FE0

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: [Q]: reading hexadecimal numbers from text files
Next Topic: Re: IDL vs. Matlab

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:03:47 PDT 2025

Total time taken to generate the page: 0.00399 seconds