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

Home » Public Forums » archive » Help: Countlines on Win 95 version of IDL
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: Help: Countlines on Win 95 version of IDL [message #10541 is a reply to message #10502] Wed, 17 December 1997 00:00 Go to previous messageGo to previous message
Michael Werger is currently offline  Michael Werger
Messages: 34
Registered: May 1997
Member
PDW wrote:

> I am converting programs from Unix version of IDL to Windows 95, and have a
> problem with routines using SPAWN and "wc -l" to get the number of lines in
> a file in order to dimension an array. How can this be done on the PC
> version?

Try this:
;+
; Name:
; nlines
; Purpose:
; Return the number of lines in a file
; Usage:
; nl = nlines(file)
; Inputs:
; file = file to scan
; Optional Inputs or Keywords:
; help = flag to print header
; Outputs:
; nl = number of lines in the file.
; Common blocks:
; none
; Procedure:
; Assume ASCII data and read through file.
; Modification history:
; write, 24 Feb 92, F.K.Knight
;-
function nlines,file,help=help
;
; =====>> HELP
;
on_error,2
if keyword_set(help) then begin & doc_library,'nlines' & return,0 & endif
;
; =====>> LOOP THROUGH FILE COUNTING LINES
;
tmp = ' '
nl = 0
on_ioerror,NOASCII
if n_elements(file) eq 0 then file = pickfile()
openr,lun,file,/get_lun
while not eof(lun) do begin
readf,lun,tmp
nl = nl + 1
endwhile
close,lun
free_lun,lun
NOASCII:
return,nl
end


--
Michael Werger ESA ESTEC & Praesepe B.V.
Astrophysics Division mwerger@estec.esa.nl
Postbus 299 http://astro.estec.esa.nl
2200 AG Noordwijk +31 71 565 3783 (Voice)
The Netherlands +31 71 565 4690 (FAX)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: DC_Read_Free in IDL?
Next Topic: Re: Object-Oriented Programming Question

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

Current Time: Sun Oct 12 07:04:50 PDT 2025

Total time taken to generate the page: 1.20236 seconds