Rem Sub Findcode v1.0a PD 2001.
Dim Routines(1024) As String
Color 15, 0
Print "Subroutine finder v1.0a:"
CommandLine$=Command$
If Len(CommandLine$) Then
   Var=Instr(CommandLine$,"/X")
   If Var Then
      CommandLine$=Left$(CommandLine$,Var-1)+Mid$(CommandLine$,Var+2)
      OutputFile=-1
   Endif
Endif
If CommandLine$="/?" Or CommandLine$="-?" Then
   Color 14, 0
   Print "Finds subroutines in Basic source files;"
   Print "Specify subroutine to find on command line."
   Print "Do not prefix 'Sub'."
   Color 7, 0
   Print "Exiting to system:"
   End
Endif
If CommandLine$="" Then
   Color 15, 0
   Print "Enter subroutine name";
   Input CommandLine$
Endif
Search$="Sub "+CommandLine$
Color 15, 0
Print "Finding: "; CHR$(34);
Color 14, 0
Print Search$;
Color 15, 0
Print CHR$(34); " ";
VarF!=Timer
Routine1=0
CommandLine$=Ltrim$(CommandLine$)
CommandLine$=Rtrim$(CommandLine$)
CommandLine$="sub "+CommandLine$
CommandLine$=Lcase$(CommandLine$)
Length=Len(CommandLine$)
FileSpec$="*.bas"
Filename$=Dir$(FileSpec$)
While Len(Filename$)
   Close
   Open Filename$ For Input As #1
   Gosub Dot.Display
   Do While Not Eof(1)
      Line Input #1,InputLine$
      If Left$(Lcase$(Ltrim$(InputLine$)),Length)=CommandLine$ Then
         Routine1=Routine1+1
         Routines(Routine1)=Filename$
         Exit Do
      Endif
   Loop
   Filename$=Dir$
Wend
Print
If Routine1>1 Then
   For Sort1=1 To Routine1
      For Sort2=Sort1+1 To Routine1
         If Routines(Sort1)>Routines(Sort2) Then
            Swap Routines(Sort1),Routines(Sort2)
         Endif
      Next
   Next
Endif
Color 15, 0
Select Case Routine1
Case 0
   Print "No Subroutines found."
Case 1
   Print "Total of 1 subroutine found."
Case Else
   Print "Total of";Routine1;"subroutines found."
End Select
Page=1
Color 14, 0
If Routine1>0 Then
   If OutputFile Then
      Close
      Open "finddata.dat" For Output As #1
   Endif
   For Var=1 To Routine1
      Filename$=Routines(Var)
      Filename$=Filename$+Space$(15-Len(Filename$))
      If OutputFile Then
         Print #1,Filename$;
      Else
         Print Filename$;
      Endif
      Line1=Line1+1
      If Line1=5 Then
         If OutputFile Then
            Print #1,""
         Else
            Print
            Page=Page+1
            If Page=23 Then
               Page=0
               Color 15, 0
               Print "More:";
               While Inkey$=""
               Wend
               Print
               Color 14, 0
            Endif
         Endif
         Line1=0
      Endif
   Next
Endif
Color 7, 0
If OutputFile Then
   Print #1,""
Else
   Print
Endif
Print "Exiting to system:"
End

Dot.Display:
 VarG!=Timer-VarE!
 If VarG!<0! Then
    VarG!=Elapsed.Time!+86400!
 Endif
 If VarG!>=1! Then
    VarE!=Timer
    If VarD=0 Then
       VarC=VarC+1
       Print ".";
       If VarC=5 Then
          VarD=-1
          VarC=0
       Endif
    Else
       VarC=VarC+1
       Locate Csrlin,Pos(0)-1,0
       Print " ";
       Locate Csrlin,Pos(0)-1,1
       If VarC=5 Then
          VarD=0
          VarC=0
       Endif
    Endif
 Endif
 Return
