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

Home » Public Forums » archive » BINARY 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: BINARY FILES [message #22073 is a reply to message #21979] Fri, 13 October 2000 00:00 Go to previous messageGo to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
David Fanning wrote:
>
> mohamed nur (mohamed_nur@my-deja.com) writes:
>
>> I've been dealing with binary files and every case i had to know before
>> hand the dimensions of the array to setup an IDL variable of the said
>> dimesions and read the unformatted data into.
>>
>> But is it possible or is there a method (in IDL 5.2/5.3) to read it in
>> with no knowledge of the dimensions of the array.
>
> A free Second Edition IDL Programming Techniques book
> to the first person who can find the simple word I
> embedded in this binary sequence:
>
> 0 1 1 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1
> 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0
> 0 0 0 0 0 0 0 0 1 1 1 0 1 1 0 0 0 0 0
> 0 0 0 0 0 1 1 0 1 0 0 1 0 0 0 0 0 0 0
> 0 0 1 1 0 0 1 0 0 1 0 1 0 0 0 1 0 1 1
> 0 0 0 0 1 0 0 0 1 1 0 1 1 0 0 0 0 1 0
>
> Cheers,
>
> David
>
> P.S. Let's just say this is a *much* easier problem
> than the one you propose. :-)
>
> --
> 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

Hmmmm, David: please count the digits next time -- these truely don't
mnake sense.
Yet, I tried - first padding the string with a few more zero's.

First step:
copy the text into a string (mouse)
IDL> a='0 1 1 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 1 0 0 0 ...'

Then:
a=strcompress(a,/remove_all)3
print,strlen(a)
; 114 (which divided by 8 is 14.25)
a=a+'000000'
b=bytarr(8,15)
reads,a,b,format='(120a1)'
value=lonarr(15)
for i=0,14 do
value =long(b[0,i])+2*(b[1,i]+2*(b[2,i]+2*(b[3,i]+2*(b[4,i]+2*(b[5 ,i]+2*(b[6,i]+2*b[7,i]))))))
print,string(byte(value))

; (doesn't make sense, though ...)


Cheers,
Martin

--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 41173-298 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: selecting radnom number from 2D array
Next Topic: LOADCT is not working

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

Current Time: Thu Oct 09 14:54:02 PDT 2025

Total time taken to generate the page: 1.91979 seconds