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

Home » Public Forums » archive » Re: Need more than 32767 characters!
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Need more than 32767 characters! [message #16555] Mon, 02 August 1999 00:00
Liam Gumley is currently offline  Liam Gumley
Messages: 473
Registered: November 1994
Senior Member
Robert King wrote:
> I'm adding a file viewer to one of my programs, it reads an ASCII text file
> and displays the whole thing to a text widget.
>
> I'm using something like:
>
> _____________________
>
> line=''
> txt='File contents:' +STRING([13B,10B])
> WHILE NOT EOF(lun) DO BEGIN
> ReadF, lun, line
> txt = txt + line + STRING([13B,10B])
> ENDWHILE
> Widget_Control, mytext_id, SET_VALUE=txt
>
> _____________________
>
> The problem is that the file is longer than 32,767 characters (about 32
> times larger..). Is there a way of showing the whole file (other than using
> 32 different text widgets) ?

You need to read the file into a string array, rather than a string
variable, e.g.

;---cut here---
FUNCTION READTEXT, FILE

; Read a text file into a string array
; Usage: RESULT = READTEXT(FILE)

;- Open the file

openr, lun, file, /get_lun

;- Create string variables

maxlines = 100000L
data = strarr(maxlines)
line = ' '
nlines = 0

;- Read the file until EOF

while not eof(lun) do begin
readf, lun, line
data[nlines] = line
nlines = nlines + 1
endwhile

;- Truncate the string array

data = data[0 : (nlines - 1) > 0]

;- Close the file and return the result

free_lun, lun
return, data

END
;---cut here---

Or you could use XDISPLAYFILE, e.g.

xdisplayfile, file

Cheers,
Liam.

--
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: reconstruction
Next Topic: reconstruction

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

Current Time: Wed Oct 08 18:07:03 PDT 2025

Total time taken to generate the page: 0.00382 seconds