' FILEREC%(0.0) Count Number of File Records 06/02/2001-06/02/2001 ' -------------------------------------------------------------------------- ' Copyright (C) 2001 by Vladimir Veytsel www.davar.net ' Type --------------------------------------------------------------------- ' Function ' Declaration -------------------------------------------------------------- ' DECLARE FUNCTION FILEREC%(File.Name$) ' Parameter ---------------------------------------------------------------- ' File.Name$ - File name ' Value -------------------------------------------------------------------- ' If specified file exists, ' then file is opened, read through, while counting number of it's ' records, closed, and record counter is returned to the point ' of function invocation; ' else -1 is returned to the point of function invocation to indicate ' a problem to the calling program. ' Start Function ----------------------------------------------------------- FUNCTION FILEREC%(File.Name$) PUBLIC ' Check File Specification Validity and Count Number of It's Records ------- IF ((File.Name$="") OR _ (LEN(DIR$(File.Name$))=0)) THEN File.Records%=-1 ELSE OPEN File.Name$ FOR INPUT AS #1 WHILE NOT EOF(1) LINE INPUT #1, Record$ File.Records%=File.Records%+1 WEND CLOSE #1 END IF ' Return Function Value to the Point of Invocation ------------------------- FILEREC%=File.Records% ' Finish Function ---------------------------------------------------------- END FUNCTION