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

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