FUNCTION n_lines,file ; This function opens the specified file, determines its length in ; bytes, and reads it in as a BYTE-valued array. It then returns ; the number of occurrences of 10B in the file. 10B is the ASCII ; code for a line feed, which marks the end of a line of text (in ; UNIX, at least). ; Modified 10 January 1995 by D P Steele: ; If called under VMS, this function dodges the whole issue of ; counting lines and SPAWNs a call to WC.COM, which uses EVE (the ; Extensible Vax Editor) to count the number of lines and return ; the result. Obviously, WC.COM must be accessible to the function. f=RFindFile(file,Count=nf) IF nf EQ 0 THEN BEGIN Message,file+' not found!',/INFORMATIONAL Return,-1 ENDIF IF !VERSION.OS EQ 'vms' THEN BEGIN SPAWN,'@USER$:[STEELE.IDL]WC '+file,n n=LONG(n(0)) ENDIF ELSE BEGIN OPENR,unit,file,/GET_LUN f=FSTAT(unit) IF f.SIZE EQ 0 THEN n=0L ELSE BEGIN b=BYTARR(f.size) READU,unit,b n=LONG(TOTAL(b EQ 10B)) ENDELSE FREE_LUN,unit ENDELSE RETURN,n END