FILEREC% PBCC (32-bit) Function |
FILEREC% function evaluates to the number of records in a file that is specified as function parameter. If file name is incorrect, or file doesn't exist, function evaluates to "-1" that is an error indicator for an invoking program. FILEREC% Source Program Debugging program Debugging logout |
' FILEREC%(0.0) Count Number of File Records 06/02/2001-02/09/2010 ' ------------------------------------------------------------------------------ ' Copyright (C) 2001-2010 by Vladimir Veytsel pbc.davar.net ' Type ------------------------------------------------------------------------- ' Function ' Parameter -------------------------------------------------------------------- ' File_Name$ - File name ' Value ------------------------------------------------------------------------ ' IF specified file exists, ' THEN file is opened, read through, while counting number of its ' 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$) ' 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
FILEREC% Debugging Program Source program Debugging logout |
' FILEREC%(0.0) Count Number of File Records 06/02/2001-02/09/2010 ' ------------------------------------------------------------------------------ #INCLUDE "FILEREC" FUNCTION PBMAIN PRINT "FILEREC%(0.0) Count Number of File Records "; DATE$; PRINT " "; LEFT$(TIME$,5) PRINT STRING$(62,"-") PRINT PRINT "FILEREC%('')="; _ FILEREC%("") PRINT "FILEREC%('C:\PBASIC\ZZZZZZZ.ZZZ')="; _ FILEREC%("C:\PBASIC\ZZZZZZZ.ZZZ") PRINT "FILEREC%('C:\PBASIC\FILEREC.BAS')="; _ FILEREC%("C:\PBASIC\FILEREC.BAS") END FUNCTION
FILEREC% Debugging Logout Source program Debugging program |
FILEREC%(0.0) Count Number of File Records 02-09-2010 18:19 -------------------------------------------------------------- FILEREC%('')=-1 FILEREC%('C:\PBASIC\ZZZZZZZ.ZZZ')=-1 FILEREC%('C:\PBASIC\FILEREC.BAS')= 46 |
View [and save] FILEREC.BAS text View [and save] ZFILEREC.BAS text (Use [Back] button or [Alt]+[CL] to return here from the viewed text) Copyright © 2001–2010 by Go to: Davar site entry | Site contents | Site index | Personal Computer | PBCC | Text top |