[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: reading dem

Sylvain Carette <sylvainc@total.net> writes:

> --------------A4C74D0ACADA4F254E47B596
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
> Well it didnt work.. :-(
> I got:
> % Input line is too long for input buffer of 32767 characters.
> % READF: Error encountered reading from file. Unit: 100, File:
> D:\gis\DEM250\montrealw.dem
> Now I'm stuck... is there a way to make readf read only no more than 32767
> char?

Okay, so you can read <31 1024-blocks at a time, unformatted.  Then
you convert to a string and use reads.

ii = 0L
bb = bytarr(1024L*31) && ll = lonarr(170L*31)
while ii LT nvals do begin
  readu, lun, bb           ;; Read blocks
  reads, string(bb), ll    ;; Change to a string and parse into LONGs
  im(ii:ii+170-1) = ll     ;; Insert into image array
  ii = ii + n_elements(ll) ;; Advance array index

This doesn't handle the case of the first block, which only has 135
elements, but you should get the idea.  Now why not try a little
experimentation on your own...

Good luck,

P.S. I used a long integer because the values are defined in the spec

Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response