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

Home » Public Forums » archive » Re: moving within a file
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: moving within a file [message #11052] Wed, 04 March 1998 00:00
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
Gerhard D. Rappold wrote:
>
> Hello IDL users,
>
> I'm just a beginner of IDL and want do know how I could read an open
> file (or a part of it) severeal times. If you have openend the file
> (e.g. StrArr(6, 100) to read the file you do:
>
> data = StrArr(6,100)
> readf, data
>
> if you now want to read the 3 colume without starting over and doing the
>
> Free_lun,
> openF, lun, etc.
> again.
> How can you do it?
>
> thanks
>
> Gerhard

since you are reading in a string array, you can convert this to numbers
by calling

READS,data(i),var1,var2,var3,...

(or you can download D. Foster's GET_TOKEN.PRO from
ftp://bial8.ucsd.edu/pub/software/idl/share/idl_share.tar.gz
)


If you really need to (re)position your file pointer,
res = fstat(ilun) ; get fileinfo structure
filepos = res.cur_ptr

point_lun,ilun,filepos ; set file pointer
(filepos must be LONG !)

Martin.

--
------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Earth&Planetary Sciences, Harvard University
186 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA

phone: (617)-496-8318
fax : (617)-495-4551

e-mail: mgs@io.harvard.edu
IDL-homepage: http://www-as.harvard.edu/people/staff/mgs/idl/
------------------------------------------------------------ -------
Re: moving within a file [message #11058 is a reply to message #11052] Wed, 04 March 1998 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Gerhard D. Rappold (rappold@zedat.fu-berlin.de) writes:

> I'm just a beginner of IDL and want do know how I could read an open
> file (or a part of it) severeal times. If you have openend the file
> (e.g. StrArr(6, 100) to read the file you do:
>
> data = StrArr(6,100)
> readf, data
>
> if you now want to read the 3 colume without starting over and doing the
>
> Free_lun,
> openF, lun, etc.
> again.
> How can you do it?

If you just want to "rewind" the file (or go some other place
in it), you can use the POINT_LUN procedure. For example, if
you want to rewind a file to its beginning, you can type this:

Point_Lun, lun, 0

If what you are asking is how do you read the 3rd column in
that 6 by 100 string array, then I would do it like this:

col3 = Reform(data[2,*])

You can find other tips about reading and writing data in
IDL on my web page.

Cheers,

David
-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: backing store
Next Topic: Re: functions considered as variables

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

Current Time: Sun Nov 30 09:36:42 PST 2025

Total time taken to generate the page: 0.88508 seconds