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 #22069 is a reply to message #21979] Fri, 13 October 2000 00:00 Go to previous messageGo to previous message
mole6e23 is currently offline  mole6e23
Messages: 31
Registered: December 1998
Member
Silly me -

Of course, you need to divide by the size of each element when using the
fstat function to get the array size:

array = fltarr( stat.size / 4 ) ;; 4 bytes to a float

Todd

> I always use the fstat routine, which gets a bunch of information about
> the file, but the only one I ever use is the size field:
>
> ;-----
> openr,lun,'file.dat',/get_lun
> stat = fstat( lun )
>
> array = fltarr( stat.size )
>
> readu,lun,array
>
> free_lun, lun
> ;----
>
> Alternatively, if you're on UNIX, you can use the /nostdio keyword which
> lets you just read willy nilly until the end of the file, and then get the
> transfer count from the readu procedure. It's not a good way of doing
> things, in my opinion, but it works:
>
> ;; Allocate a much bigger array than you need
> array = fltarr( 1e5 )
> openr,lun,'file.dat',/get_lun,/nostdio
> readu,lun,array,transfer_count=count
> array = temporary(array)[0:count-1]
> free_lun, lun
[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: Wed Oct 08 18:26:43 PDT 2025

Total time taken to generate the page: 0.00801 seconds