TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: ALL
from: WAYNE ZIMMERLE
date: 1995-10-30 23:44:00
subject: line count function

f$ = command$      'needs filename on command line print linecount(f$) 'or 
you can substitute a filename end                'for f$
              'this is very speedy and I adapted it
              'from Ethan Winers Basic Techniques and Utilities
              ' my question with it is am I setting myself
              'up for a problem in over reading the file
              'it seems to work correctly
              'but I wonder if I should be tallying linefeeds
              'instead of enters or maybe both?? FUNCTION linecount 
(filename$) PUBLIC f = freefile
OPEN filename$ FOR BINARY AS #f
do while not eof(f)
  BufSize = 4096
  Buffer$ = SPACE$(BufSize)
    GET #f, , Buffer$
  incr count,tally(Buffer$,chr$(13))
loop
close f
linecount = count
end function
'And in a semi related question.  Suspose you had a 'sequential file of about 
1000 lines that you wanted to read 'and place into an array very quickly.  
How would you 'go about it?  I'm using input to get my first and 'last name 
fields and then line input, dummy$ to proceed to 'the next line.  I would 
like to increase the speed of this. 'thanks
---
 * SLMR 2.1a * 
--- InterEcho 1.11
---------------
* Origin: The DataStream (Node 1), Peoria, IL (1:232/30)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.