home *** CD-ROM | disk | FTP | other *** search
/ Boston 2 / boston-2.iso / DOS / PROGRAM / BASIC / POWBASIC / LIBRARY2 / MAKE2.ZIP / MAKE.BAS < prev   
BASIC Source File  |  1990-09-27  |  7KB  |  213 lines

  1. 'This is a bug fix and an upgrade to Make version 1.0.
  2. '
  3. 'BUG FIXED:   There are 3600 seconds in an hour, not 360.
  4. 'IMPOVEMENT:  1. This version checks for included files in the unit modules.
  5. '          2. Units do not require extension of .bas anymore.
  6. '
  7. '############################################################################
  8. '                      VERSION 1.1
  9. 'FILE: MAKE.BAS  : This is the main FILE
  10. 'PURPOSE: UTILITY TO COMPILE ALL .PBU FILES THAT ARE NOT CURRENT
  11. 'WARNING: 1. THIS DOESN'T TRAP ERRORS OCCURRING DURING COMPILING.
  12. '         2. ALL FILES MUST BE IN CURRENT DIRECTORY.
  13. '         3. THIS UTILITY CREATES A BATCH FILE NAMED TMP-MKE.BAT,
  14. '            AND WILL OVERWRITE ANY OTHER FILE OF THAT NAME.
  15. '
  16. '
  17. 'Author: Al Musella
  18. 'Upload date: 9/27/90
  19. 'Send comments (Good or Bad) to me at Compuserve: # 76114,637
  20. '############################################################################
  21. $STACK 32766
  22.  
  23.  
  24. '--------------- INITIALIZE ------------------------------
  25. DEFINT A-Z
  26.  
  27. COLOR 15,1:CLS
  28. DIM L$(200,2)  'holds FILEnames for ,1-> .pbu  ,2 -> .bas
  29. DIM Comp$(200)  'holds names of FILEs to compile
  30. CompCount=0  'Count of items in Comp$
  31. BatchFile$="TMP-MKE.BAT"   'Name of batch file that will compie the ubits
  32.  
  33. 'Erase previous batch file
  34. OPEN BATCHFILE$ FOR OUTPUT AS #3  'have to create one to avoid error on
  35. CLOSE #3                         'kill statement
  36. KILL BATCHFILE$
  37. OPEN BATCHFILE$ FOR OUTPUT AS #3  'create batch file with names of files to
  38.                        'compile
  39.  
  40. 'display title page
  41. PRINT STRING$(79,"*")
  42. PRINT"                               Make Utility"
  43. PRINT"                               Version 1.1"
  44. PRINT"                        Programmed By : Al Musella"
  45. PRINT STRING$(79,"*")
  46. PRINT
  47. 'get name of main file and display it.
  48. FileSpec$=UCASE$(GETFILENAME$)   'function getfilename returns name of project
  49. PRINT
  50. PRINT"             Main File: ";FileSpec$
  51. PRINT
  52. 'Check if on file - abort if not on file
  53. IF NOT FILEEXISTS(FileSpec$) THEN PRINT"This filename is not on file.":_
  54.        PRINT"Try running this utility again with valid filename!!!":BEEP:END
  55.  
  56. 'find all $link"*.pbu" files that are involved with this project
  57. GOSUB  GETLINKS  '-------------------- Gets names of all Linked files into L$()
  58.  
  59. 'check date and time of files
  60. 'if no links found, don't waste time checking their dates
  61.  
  62. IF LinkCount=0 THEN    'This is start of long If statement
  63.        PRINT"THERE WERE NO $LINK STATEMENTS IN THIS PROJECT!"
  64. ELSE     'only check dates and times if there are LINKS to compile.
  65.       'NOW L$ (,1) HAS ALL FILES LINKED IN AS : *.PBU
  66.       GOSUB GETSOURCE   'just changes .PBU to .BAS
  67.       PRINT
  68.       COLOR 15,1
  69.       PRINT"----- UNITS ------------------------------- SOURCE FILES ----------------  ";
  70.      'now get name of files that have to be compilied
  71.      FOR I = 1 TO LinkCount
  72.       IF L$(I,1)<>"" AND L$(I,2)<>"" THEN
  73.      COLOR 14,2
  74.      PRINT
  75.      'Get time and date stamp of files
  76.      CALL DtStamp$(L$(I,1),DPbu$,TPbu$)  'Stamp of .pbu
  77.      CALL FindDtStamp$(L$(I,2),DBas$,TBas$) 'stamp of newest include file
  78.      'convert to pseudo julian to compare easier
  79.      JPbu#=JULIAN#(DPbu$,TPbu$)  'function julian returns julian date
  80.      JBas#=JULIAN#(DBas$,TBas$)
  81.     IF JBas#>JPbu# THEN  'if not current, add names to Comp$()
  82.        COLOR 0,4
  83.        INCR CompCount
  84.        Comp$(CompCount)=L$(I,2)
  85.      END IF
  86.     PRINT L$(I,1);tab(15);DPbu$;" ";TPbu$;tab(40);L$(I,2);tab(55);DBas$;" ";TBas$;
  87.       END IF
  88.     NEXT I
  89.     COLOR 14,1  'yellow/blue
  90.     LOCATE 24,1
  91.     PRINT
  92.     IF CompCount>0 THEN
  93.      'add them to batch file
  94.      FOR I = 1 TO CompCount
  95.        Text$="PBC -CU "+Comp$(I)
  96.        PRINT#3,Text$
  97.        PRINT "Adding to list: ";Text$
  98.      NEXT I
  99.    ELSE
  100.      PRINT
  101.      PRINT"No .Pbu files need to be recompiled"
  102.      BEEP
  103.    END IF
  104.  
  105. END IF  'This is the end of IF statement on line  56
  106.  
  107. 'Now add main file to batch file
  108. Exe$=FileSpec$  'Convert filename to .exe extension
  109. P = INSTR(Exe$,".")
  110. MID$(Exe$,P+1,3) = "EXE"
  111. CALL DTSTAMP$(Exe$,DExe$,TExe$)
  112. CALL DTSTAMP$(FileSpec$,DBas$,TBas$)
  113. Text$="PBC -CE "+FileSpec$
  114. PRINT "Adding to list: ";Text$
  115. PRINT CompCount+1 ;" Files will be compilied"
  116. PRINT
  117. PRINT"--------------------------------------------------------------------------"
  118. PRINT
  119. PRINT"MAIN PROJECT:" FileSpec$,DBas$,TBas$
  120. PRINT"COMPILED    :" Exe$,DExe$,TExe$
  121. PRINT
  122. PRINT#3, Text$
  123. CLOSE#3
  124. PRINT:PRINT:PRINT"Executing ";BatchFile$
  125. PRINT
  126. EXECUTE BATCHFILE$  'do the compiling
  127.  
  128. END
  129.  
  130.  
  131.  
  132.  
  133. GETSOURCE:  'Convert .Pbu extension to .Bas for array L$
  134.         'Array L$(1 to LinkCount,1) holds .Pbu Filenames
  135.         'convert these to .Bas (or whatever) and store in L$(,2)
  136.      FOR I = 1 TO LinkCount
  137.     FPbu$=L$(I,1)  '.Pbu file
  138.         'for now, assume .bas - but this can be changed.
  139.         'Remove .Pbu , add .bAS
  140.     FBas$ =  REMOVE$(FPbu$,".PBU")+".BAS"
  141.     IF FILEEXISTS(FBAS$) THEN
  142.        L$(I,2) = FBas$
  143.     ELSE
  144.       FStar$=REMOVE$(FPbu$,".PBU")+".*"
  145.       F$=DIR$(Fstar$) 'find first match
  146.       Ext$=RIGHT$(F$,3)  'file extension
  147.       WHILE (Ext$="EXE" or Ext$="BAK" or Ext$="PBU")
  148.          F$=DIR$  'Find next match
  149.          Ext$=RIGHT$(F$,3)  'file extension
  150.       WEND
  151.       L$(I,2) = F$
  152.       IF F$="" THEN
  153.        PRINT"WARNING!!! The source file for ";FPbu$;" is not in"
  154.        PRINT"current directory, or doesn't have an extension of .BAS"
  155.        PRINT"This file will not be checked!!!"
  156.        CALL WAITING
  157.        L$(I,1)=""   'DON'T CHECK THIS FILE
  158.       END IF
  159.     END IF
  160.      NEXT I
  161. RETURN
  162.  
  163.  
  164. GETLINKS:  ' Find all .Pbu files mentioned in the project,
  165.         ' and store them in array L$(1->LinkCount,1)
  166.         'LinkCount is returned as # of files in the array
  167.  
  168.   DIM INCS$(200)  'Hold Included filenames - to search through later
  169.    Pointer = 0  'Pointer to next filename in Inc$()
  170.    IncCount=0  'Count of Included filenames
  171.    LinkCount=0 'Count of Linked filenames
  172.    NF$ = FileSpec$  'NF$ = Next filename to check for more Links
  173.    DO WHILE FILEEXISTS(NF$)
  174.       PRINT"SEARCHING: ";NF$
  175.       OPEN NF$ FOR INPUT AS #1
  176.     DO WHILE NOT EOF(1)
  177.        LINE INPUT #1,T$   '1 line of text from file
  178.        IF INSTR(T$,"$") THEN  'Use this to speed it up by only
  179.              'checking lines with a $ in them
  180.          T$=UCASE$(REMOVE$(T$,ANY CHR$(9,32)))  'Remove tabs and spaces
  181.          IF LEFT$(T$,5)="$LINK" AND INSTR(T$,".PBU") THEN
  182.         F$=MID$(T$,7,12)  'Isolate filename
  183.         QUOTE = INSTR(F$,CHR$(34))  'Remove quote
  184.         IF QUOTE>0 THEN F$=LEFT$(F$,QUOTE-1)
  185.                PRINT TAB(10) "FOUND :";F$
  186.             INCR LinkCount
  187.             L$(LinkCount,1)=F$
  188.          END IF
  189.          IF LEFT$(T$,8) = "$INCLUDE" THEN
  190.            F$=MID$(T$,10,12)  'Isolate filename
  191.            QUOTE = INSTR(F$,CHR$(34))  'Remove quote
  192.            IF QUOTE>0 THEN F$=LEFT$(F$,QUOTE-1)
  193.          PRINT TAB(10) "FOUND :";F$
  194.           IF FILEEXISTS(F$) THEN
  195.              INCR IncCount
  196.              INCS$(IncCount)=F$
  197.           ELSE
  198.              PRINT"WARNING!! ";F$;" is not in current directory,"
  199.              PRINT "and will not be checked!!!":beep:CALL WAITING
  200.           END IF
  201.          END IF
  202.        END IF
  203.        LOOP
  204.       CLOSE #1
  205.       INCR Pointer
  206.       NF$=INCS$(Pointer)
  207.    LOOP
  208.    PRINT"--------------------------------------------------------------------------"
  209. RETURN
  210.  
  211. $INCLUDE"LibMake.Bas"  'library of functions and subs
  212.  
  213.