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

Home » Public Forums » archive » binary data files with ascii header
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
binary data files with ascii header [message #1818] Tue, 08 March 1994 10:22
mtadams is currently offline  mtadams
Messages: 10
Registered: November 1993
Junior Member
Hello, all.

I'm trying to create binary data files that have an ascii header followed by a
string(12b) (a control-L, so that I can use 'more' to view just the headers), a
string(10b) (a return character), and then the binary data. For example,

pro test_write
arr=bytarr(256,256,36) ; thirty-six 256x256 images
openw,unit,'test.dat',/get_lun
printf,unit,'header'
printf,unit,'information'
printf,unit,'here...'
printf,unit,string(12b)
writeu,unit,arr
close,unit
free_lun,unit
return
end

Creating them seems to present no problem; it's in reading them that I get hosed:

function test_read
openr,unit,'test.dat',/get_lun
str=''
readf,unit,str ; read string 'header'
readf,unit,str ; read string 'information'
readf,unit,str ; read string 'here...'

; now skip over the ^L and return characters...
char=0b
if not (eof(unit)) then repeat readu,unit,char until ((char eq 10b) or (eof(unit))

; file pointer should now be pointing to first byte of binary data...
if (eof(unit)) then begin
print,'premature eof.'
close,unit
free_lun,unit
return,-1
endif else begin
arr=bytarr(256,256,36)
readu,unit,arr
close,unit
free_lun,unit
return,arr
endelse
end

There is often no eof() error; all data seems to be read ok, until I step through
my 36 images. Each image is column shifted by some amount (the same for each
image).

Any help? Is my error in combining printf & writeu or readf & readu?

thanks,

matthew
____________________
mtadams@columbine.hsc.colorado.edu
Matthew T. Adams
University of Colorado Health Sciences Center
4200 E 9th Ave, C268-68
Denver, CO 80262
[Message index]
 
Read Message
Previous Topic: Re: Vertical profiles
Next Topic: DXF File Reader for IDL

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

Current Time: Thu Oct 09 17:21:30 PDT 2025

Total time taken to generate the page: 0.79904 seconds