BCX Console Demonstration Program S146.bas

 PRINT CountLines(COMMAND$)
 
 FUNCTION CountLines(F$)
   IF NOT EXIST(F$) THEN EXIT FUNCTION
   DIM RAW RC =  0 AS ULONG
   DIM RAW C  =  0
   DIM RAW NL = 10
   OPEN F$ FOR BINARY AS FP9
   WHILE NOT EOF(FP9)
     C = GETC(FP9)
     IF C = NL THEN
       INCR RC
     END IF
   WEND
   CLOSE FP9
   FUNCTION = RC
 END FUNCTION