home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / BBS / BKLA201D.ZIP / BKLA201M.BAS < prev    next >
BASIC Source File  |  1995-05-21  |  13KB  |  350 lines

  1.     DECLARE FUNCTION ExeName$
  2.     DECLARE FUNCTION QInstrB% (StartPos%, Source$, Search$)
  3.     DECLARE SUB MaxStats (Record$)
  4.     DECLARE SUB SystemName ()
  5.   
  6.     COMMON SHARED Bar$
  7.     COMMON SHARED /Bkla201M/ Caller$
  8.     COMMON SHARED /Bkla201M/ MaxH%
  9.     COMMON SHARED /Bkla201M/ MaxCPS&
  10.     COMMON SHARED /Bkla201M/ MaxFileSize&
  11.     COMMON SHARED /Bkla201M/ MaxOutgoingFile&
  12.     COMMON SHARED /Bkla201M/ MaxOutFTot&
  13.     COMMON SHARED /Bkla201M/ MaxInFTot&
  14.     COMMON SHARED /Bkla201M/ MaxSec%
  15.     COMMON SHARED /Bkla201M/ MaxFileCount%
  16.     COMMON SHARED /Bkla201M/ MaxSecTot%
  17.     COMMON SHARED /Bkla201M/ MissingFileSize&
  18.     COMMON SHARED /Bkla201M/ ExcludExt$()
  19.     COMMON SHARED /Bkla201M/ LastF%
  20.     COMMON SHARED /Bkla201M/ ExcludeFiles%
  21.   
  22.     CONST BinklaVersion$ = "2.01d"
  23.     CONST Copyright1$ = "Binkley Log Analyzer - BinkLA Version "
  24.     CONST Copyright2$ = "Copyright 1991 - 94 by RJ (Bob) Ross - ALL RIGHTS RESERVED"
  25.     CONST Copyright3$ = "SysOp - RJ's Byteline BBS - FidoNet 1:134/75"
  26.   
  27.     CONST False = 0
  28.     CONST True = NOT False
  29.   
  30.   ' Define color constants
  31.     CONST BLACK = 0
  32.   ' CONST BLUE = 1
  33.     CONST GREEN = 2
  34.     CONST CYAN = 3
  35.     CONST RED = 4
  36.   ' CONST MAGENTA = 5
  37.     CONST BROWN = 6
  38.     CONST WHITE = 7
  39.     CONST BRIGHT = 8
  40.     CONST BLINK = 16
  41.     CONST YELLOW = BROWN + BRIGHT
  42.   
  43.   ' Running out of space in the main module so had to break things up
  44.   
  45.   ' Second module for BinkLA - BKLA201M.BAS - also includes following Subs
  46.   ' MaxStats Sub
  47.   ' Help Sub
  48.   ' Copyright Sub
  49.   ' Sort Sub
  50.   ' PrtCtrDisp Sub
  51.   ' SystemName Sub
  52.  
  53. DEFINT A-Z
  54.     SUB Copyright
  55.         CLS
  56.         COLOR YELLOW
  57.         PRINT TAB(40 - (LEN(BinklaVersion$) + LEN(Copyright1$)) \ 2); Copyright1$; BinklaVersion$
  58.         PRINT TAB(40 - LEN(Copyright2$) \ 2); Copyright2$
  59.         PRINT TAB(40 - LEN(Copyright3$) \ 2); Copyright3$
  60.       '       PRINT
  61.         COLOR CYAN
  62.         PRINT STRING$(79, "▄")
  63.         COLOR WHITE
  64.     END SUB
  65.  
  66.     SUB Help
  67.         CLS
  68.       
  69.         COLOR CYAN + BRIGHT
  70.         PRINT TAB(40 - (LEN(BinklaVersion$) + LEN(Copyright1$)) \ 2); Copyright1$; BinklaVersion$
  71.         COLOR YELLOW
  72.         PRINT STRING$(79, "─")
  73.         COLOR WHITE + BRIGHT
  74.         PRINT "Use:"; SPC(3);
  75.         COLOR GREEN
  76.         PRINT "BINKLA [<-switches>] [LNG=langfilename] [LOG=logfilename]"
  77.         PRINT "       [SP=External_SortProgram] [@ResponseFile]"
  78.         PRINT
  79.         PRINT SPC(7); "Switches, LNG=langfilename, LOG=logfile, SP=SortProgram"
  80.         PRINT SPC(7); "and @ResponseFile are optional and may be given in any order."
  81.         PRINT SPC(7); "The default produces BKLARpt.Txt  in the parent/home directory"
  82.         PRINT SPC(7); "where BinkLA.Exe and Binkley.log reside."
  83.         COLOR WHITE + BRIGHT
  84.         PRINT "Switches:"
  85.         COLOR GREEN
  86.         PRINT TAB(8); "= No switch produces BKLARpt.Txt using Binkley.log and exits."
  87.         PRINT " -BBS  = Produce a colourized BKLARpt.Bbs suitable for a BBS display."
  88.         PRINT " -DF   = Make a data file BKLADat.nnn from Part I of the report."
  89.         PRINT " -DN   = Use the current day number as extension for report BKLARpt."
  90.         PRINT " -EXN  = -EXN,Zone:Net (ie -EXN,1:134). Exclude a Nets from BKLARpt.*."
  91.         PRINT " -H    = This brief help screen."
  92.         PRINT " -KTF  = Don't delete created temp files (.$$$, .$$S)."
  93.         PRINT " -L    = Produce BKLARpt.Txt and list it to the screen."
  94.         PRINT " -LL   = List the last created BKLARpt.Txt file to the screen."
  95.         PRINT " -MAX  = Display Maximus BBS uploads/downloads."
  96.         PRINT " -MD   = Provide mail detail in BKLARpt.*."
  97.         PRINT " -NHA  = Don't use high ascii characters in BKLAARpt.*."
  98.         COLOR YELLOW + BLINK
  99.         PRINT
  100.         PRINT " -- More --";
  101.         DO
  102.             a$ = INKEY$
  103.         LOOP UNTIL LEN(a$)
  104.         LOCATE CSRLIN - 2, 1
  105.         COLOR GREEN
  106.         PRINT
  107.         PRINT " -SN   = Configure BINKLA.EXE to display your System Name on the output report."
  108.         PRINT " -SUP  = Suppress filenames in Part II of BKLARpt.* (-SUP,.LZH,FNEWS)"
  109.         PRINT " LNG=  = Use an alternate BinkLA language/translate file."
  110.         PRINT " LOG=  = Log path\log filename.  Optional if Binkley.LOG in default directory."
  111.         PRINT " SP=   = Use an external sort program.  ie: SP=QSort."
  112.         PRINT " @     = ResponseFile<.ext>.  A text file containing command line switches."
  113.         COLOR YELLOW
  114.         PRINT STRING$(79, "─");
  115.         COLOR WHITE
  116.     END SUB
  117.  
  118. DEFSNG A-Z
  119.     SUB MaxStats (Record$)
  120.         P% = INSTR(25, Record$, "calling (U#")
  121.         IF P% THEN
  122.             Caller$ = MID$(Record$, 24, P% - 24)
  123.             P% = 0
  124.         END IF
  125.         P% = INSTR(19, Record$, "MAX  End,")
  126.         IF P% THEN
  127.             P% = 0
  128.             Caller$ = ""
  129.             MaxCPS& = 0
  130.             MaxFileSize& = 0
  131.             MaxOutgoingFile& = 0
  132.             MaxSec% = 0
  133.             MaxFilename$ = ""
  134.             EXIT SUB
  135.         END IF
  136.         P% = INSTR(24, Record$, "CPS: ")
  137.         IF P% THEN
  138.             MaxCPS& = VAL(MID$(Record$, 29))
  139.             P% = INSTR(Record$, "(")
  140.             IF P% THEN
  141.                 MaxFileSize& = VAL(MID$(Record$, P% + 1))
  142.             END IF
  143.         END IF
  144.         P% = INSTR(19, Record$, "MAX  DL-")
  145.         IF P% THEN
  146.             MaxPosn% = QInstrB%(-1, Record$, "\")
  147.         END IF
  148.         IF MaxPosn% THEN
  149.             MaxFilename$ = MID$(Record$, MaxPosn% + 1)
  150.             MaxFileExtension$ = UCASE$(RIGHT$(MaxFilename$, 4))
  151.             IF LEFT$(MaxFileExtension$, 1) <> "." THEN
  152.                 P% = INSTR(MaxFileExtension$, ".")
  153.                 IF P% THEN
  154.                     MaxFileExtension$ = MID$(MaxFileExtension$, P%)
  155.                 END IF
  156.             END IF
  157.             IF ExcludeFiles% THEN
  158.                 FOR X% = 1 TO LastF%
  159.                     IF ExcludExt$(X%) = MaxFileExtension$ THEN
  160.                         ExcludeMaxFile% = True
  161.                         EXIT FOR
  162.                     END IF
  163.                 NEXT
  164.             END IF
  165.             IF NOT ExcludeMaxFile% THEN
  166.               'do nothing
  167.               '   ELSE
  168.                 MaxFileCount% = MaxFileCount% + 1
  169.                 MaxOutgoingFile& = MaxFileSize&
  170.                 MaxOutFTot& = MaxOutFTot& + MaxOutgoingFile&
  171.                 PRINT #MaxH%, Bar$; LEFT$(Caller$, 18);
  172.                 PRINT #MaxH%, TAB(21); MaxFilename$;
  173.                 PRINT #MaxH%, TAB(37);
  174.                 IF MaxOutgoingFile& = 0 THEN
  175.                     MissingFileSize& = -1
  176.                     PRINT #MaxH%, SPACE$(8); "***";
  177.                 ELSE
  178.                     PRINT #MaxH%, USING "###,###,###"; MaxOutgoingFile&;
  179.                 END IF
  180.                 PRINT #MaxH%, TAB(64);
  181.                 PRINT #MaxH%, USING "#####"; MaxCPS&;
  182.                 IF MaxOutgoingFile& > 0 AND MaxCPS& > 0 THEN
  183.                     MaxSec% = MaxOutgoingFile& \ MaxCPS&
  184.                     MaxSecTot% = MaxSecTot% + MaxSec%
  185.                     MaxMin! = MaxSec% / 60
  186.                 END IF
  187.                 MaxPosn% = 0
  188.                 PRINT #MaxH%, TAB(71);
  189.                 PRINT #MaxH%, USING "###.#"; MaxMin!;
  190.                 PRINT #MaxH%, Bar$
  191.             END IF
  192.         END IF
  193.         P% = INSTR(19, Record$, "MAX  UL-")
  194.         IF P% THEN
  195.             MaxPosn% = QInstrB%(-1, Record$, "\")
  196.         END IF
  197.       
  198.         IF MaxPosn% THEN
  199.             MaxFilename$ = MID$(Record$, MaxPosn% + 1)
  200.             MaxFileExtension$ = UCASE$(RIGHT$(MaxFilename$, 4))
  201.             IF LEFT$(MaxFileExtension$, 1) <> "." THEN
  202.                 P% = INSTR(MaxFileExtension$, ".")
  203.                 IF P% THEN
  204.                     MaxFileExtension$ = MID$(MaxFileExtension$, P%)
  205.                 END IF
  206.             END IF
  207.             IF ExcludeFiles% THEN
  208.                 FOR X% = 1 TO LastF%
  209.                     IF ExcludExt$(X%) = MaxFileExtension$ THEN
  210.                         ExcludeMaxFile% = True
  211.                         EXIT FOR
  212.                     END IF
  213.                 NEXT
  214.             END IF
  215.             IF NOT ExcludeMaxFile% THEN
  216.               
  217.                 MaxFileCount% = MaxFileCount% + 1
  218.                 MaxIncomingFile& = MaxFileSize&
  219.                 MaxInFTot& = MaxInFTot& + MaxIncomingFile&
  220.                 PRINT #MaxH%, Bar$; LEFT$(Caller$, 18);
  221.                 PRINT #MaxH%, TAB(21); MaxFilename$;
  222.                 PRINT #MaxH%, TAB(51);
  223.                 IF MaxIncomingFile& = 0 THEN
  224.                     MissingFileSize& = -1
  225.                     PRINT #MaxH%, SPACE$(8); "***";
  226.                 ELSE
  227.                     PRINT #MaxH%, USING "###,###,###"; MaxIncomingFile&;
  228.                 END IF
  229.                 PRINT #MaxH%, TAB(64);
  230.                 PRINT #MaxH%, USING "#####"; MaxCPS&;
  231.                 IF MaxIncomingFile& > 0 AND MaxCPS& > 0 THEN
  232.                     MaxSec% = MaxIncomingFile& \ MaxCPS&
  233.                     MaxSecTot% = MaxSecTot% + MaxSec%
  234.                     MaxMin! = MaxSec% / 60
  235.                 END IF
  236.                 MaxPosn% = 0
  237.                 PRINT #MaxH%, TAB(71);
  238.                 PRINT #MaxH%, USING "###.#"; MaxMin!;
  239.                 PRINT #MaxH%, Bar$
  240.             END IF
  241.         END IF
  242.     END SUB
  243.  
  244. DEFINT A-Z
  245.     SUB PrtCtrDisp (PrtRec%, Ln%) STATIC
  246.         SELECT CASE PrtRec%
  247.         CASE IS = 1
  248.             LOCATE 14
  249.             PRINT SPC(Ln%); "Working    |"
  250.         CASE IS = 2
  251.             LOCATE 14
  252.             PRINT SPC(Ln%); "Working    / "
  253.         CASE IS = 3
  254.             LOCATE 14
  255.             PRINT SPC(Ln%); "Working    - "
  256.         CASE IS = 4
  257.             LOCATE 14
  258.             PRINT SPC(Ln%); "Working    \ "
  259.         CASE ELSE
  260.             IF PrtRec% > 4 THEN PrtRec% = 1
  261.         END SELECT
  262.       
  263.     END SUB
  264.  
  265.     SUB SORT (TMP1&(), TMP2&(), CNT%) STATIC
  266.       '
  267.       ' --- The Shell-Metzner Sort Subroutine --- <Fast!>
  268.       '
  269.         M% = CNT%
  270.         WHILE M% > 1
  271.             M% = INT(M% / 2)
  272.             FOR J% = 1 TO CNT% - M%
  273.                 FOR i% = J% TO 1 STEP -M%
  274.                     k% = i% + M%
  275.                   'IF TMP1&(i%) >= TMP1&(k%) THEN
  276.                     IF TMP1&(i%) <= TMP1&(k%) THEN
  277.                         i% = 0
  278.                     ELSE
  279.                         SWAP TMP1&(i%), TMP1&(k%)
  280.                         SWAP TMP2&(i%), TMP2&(k%)
  281.                     END IF
  282.                 NEXT i%
  283.             NEXT J%
  284.         WEND
  285.     END SUB
  286.  
  287. DEFSNG A-Z
  288.     SUB SystemName
  289.         EditColor% = 112
  290.         NormColor% = 112
  291.         LOCATE 8, 1
  292.         Temp1$ = SPACE$(40)
  293.         PRINT "This option will allow you to configure BinkLA.Exe to automatically place"
  294.         PRINT "the name of your BBS system at the top of BinkLA output report."
  295.         PRINT
  296.         PRINT "You may press Esc to abort this function, if desired, and return to DOS."
  297.       
  298.         DO
  299.             LOCATE 13, 1
  300.             PRINT "Your System Name: ";
  301.             CALL Editor(Temp1$, Length%, ScanCode%, 0, 0, NormColor%, EditColor%, 13, 18)
  302.             IF ScanCode% = 27 THEN
  303.                 LOCATE 17, 1
  304.                 PRINT "Aborted - System Name not changed."
  305.                 END
  306.             END IF
  307.             Msg$ = "OK?  "
  308.             YN$ = "N"
  309.             CALL YesNo(YN$, Msg$, ScanCode%, 7, EditColor%, 15, 1)
  310.             IF ScanCode% = 27 THEN
  311.                 LOCATE 17, 1
  312.                 PRINT "Aborted - System Name not changed."
  313.             END IF
  314.         LOOP UNTIL UCASE$(YN$) = "Y"
  315.         IF UCASE$(YN$) = "Y" THEN
  316.             Temp1$ = LTRIM$(RTRIM$(Temp1$))
  317.             Temp1$ = Temp1$ + "@"
  318.             LookingFor$ = "R^"
  319.             FileName$ = ExeName$
  320.             ' Filename$ = "BINKLA.EXE "    'to run in the QB Environment"
  321.             FilePointer& = 1
  322.             OurHandle% = FREEFILE
  323.             OPEN FileName$ FOR BINARY AS #OurHandle%
  324.             DO WHILE NOT EOF(OurHandle%)
  325.                 SEEK OurHandle%, FilePointer&
  326.                 a$ = INPUT$(4096, OurHandle%)
  327.                 Result% = INSTR(a$, LookingFor$)
  328.                 IF Result% THEN
  329.                     FilePos& = (SEEK(OurHandle%)) - ((LEN(a$) - Result% + 1))
  330.                     EXIT DO
  331.                 END IF
  332.                 FilePointer& = SEEK(OurHandle%) - LEN(LookingFor$)
  333.             LOOP
  334.             IF Result% THEN
  335.                 FilePos& = (SEEK(OurHandle%)) - ((LEN(a$) - Result% + 1))
  336.                 PUT OurHandle%, FilePos& + 2, Temp1$
  337.                 LOCATE 18, 1
  338.                 PRINT "Update completed "; FileName$; " modified."
  339.                 END
  340.             ELSE
  341.                 LOCATE 18, 1
  342.                 PRINT "Failed to update "; FileName$
  343.                 CALL SetLevel(1)
  344.                 END
  345.             END IF
  346.         END IF
  347.       ' END IF
  348.     END SUB
  349.  
  350.