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

Home » Public Forums » archive » Re: BYTES to LONG
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: BYTES to LONG [message #22338 is a reply to message #22334] Tue, 07 November 2000 00:00 Go to previous messageGo to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Kelly Dean (krdean@lamar.colostate.edu) writes:

> I am reading in a combination ASCII/BINARY file with USGS DLG
> information as a binary file.
>
> I am able to convert the bytes into ASCII with STRING([72B, 101B, 108B,
> 108B, 111B]).
>
> However, I cannot figure out how to convert the 4 bytes into LONG, whihc
> is the UTM X and Y numbers. Any suggestions?

This is the purpose of the Offset parameter in the LONG
function. If you use an offset into a byte array, it will
then extract the next 4 bytes as a long integer.

Here is a little example program to show you how it works.
The important part is where the byteValues are converted
to LONGs:

PRO TEST

data = [1L, 4L, 8L, 12L]
OpenW, lun, 'test.dat', /Get_Lun
WriteU, lun, data
Free_Lun, lun

byteValues = BytArr(16)
OpenR, lun, 'test.dat', /Get_Lun
ReadU, lun, byteValues
Free_Lun, lun

longValues = LonArr(4)
For j=0,3 DO longValues[j] = Long(byteValues, j*4)
Print, longValues

END

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
Read Message
Read Message
Read Message
Read Message
Previous Topic: Electrical Engineer/Controls Specialist Wanted
Next Topic: Re: UTM conversion

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

Current Time: Fri Oct 10 06:48:23 PDT 2025

Total time taken to generate the page: 0.80615 seconds