'===========================================================================
' Subject: COMPILER UTILITY V1.10             Date: 01-02-00 (13:51)       
'  Author: Philipe Rubio                      Code: QB, QBasic, PDS        
'  Origin: loco92@hotmail.com               Packet: MISC.ABC
'===========================================================================
'
' Quickbasic 4.x and 7.1 "Compiler-Utility" version 1.10
'
' ***************************************************************************
' * Name:        Compiler utility.                                        *
' * File:        Compile.bas                                              *
' * Author:      Philipe Rubio (Koppin22 Software)                        *
' * Does:        Compiles all files in directory.                         *
' * History:     Started April 7 - 1999. PR                               *
' *              Bugfixing, april 8 - 1999  PR                            *
' *              April 8 - 1999, Version 1.0 ready  PR                    *
' *                                                                       *
' *              Found and fixed a bug, July 29 - 1999 PR                 *
' *              July 29 - 1999, Version 1.01 ready  PR                   *
' *                                                                       *
' *              Added compile options, August 15 - 1999 PR               *
' *              Testing software - Ok - August 16 - 1999 Ko22            *
' *              August 16 - 1999, Version 1.10 ready  PR                 *
' *                                                                       *
' * E-Mail:      Loco92@hotmail.com or koppin22@hotmail.com               *
' * Web-Site:    aurskogcity.8m.com or angelfire.com/ar/koppin22          *
' *************************************************************************
'
'       This software is proudly presented by koppin22 software.
'       The compile utility is a usefull tool for the Qbasic programmer.
'       We made this tool to help you basic programmers, this tool makes
'       it easy to compile up to 1000 files at the same time.
'       If you have a lot of Source files that must be compiled the same
'       way, then this is the utility for you. This software requires the
'       files BC.EXE ,LINK.EXE and LIB.EXE. This Software is Public
'       domain and that meens that you can edit this source code,
'       but if you edit this code we would like you to send the edited
'       code to us. But if you edit the code you can put your name under
'       History at the start of this file.One more thing, you <MUST> give
'   	credit where credit is to be given.



' Ooooh, big part of code this must be the Nirvana part.

CLS
PRINT
PRINT "COMPILE 1.10 - Compile Utility by Koppin22 Software."
  PRINT "Public Domain by Koppin22 Software."
   PRINT : PRINT : PRINT                          'What the hell's this
   option$ = LTRIM$(RTRIM$(COMMAND$))
   IF option$ = "" THEN
   IF option$ = "CLEAN UP" OR option$ = "clean up" THEN 20
   PRINT "Usage COMPILE <+ Option>": PRINT
   PRINT "Example: COMPILE SA EXE            - Output is stand alone EXE files"
   PRINT "Example: COMPILE EXE               - Output is EXE Files, requires BRUN45.EXE"
   PRINT "Example: COMPILE OBJ               - Makes OBJ files"
   PRINT "Example: COMPILE CLEAN UP          - Only deletes error.txt and dir.pcl"
END
END IF
  a$ = ""
   CLS : DIM arr$(1000), li$(26)                  'Compile limit of 1000 files
   PRINT "Building Directory..."
   start$ = TIME$
    OPEN "error.txt" FOR OUTPUT AS #5: CLOSE #5
     SHELL "dir *.bas > dir.pcl"                  'Makes a directory list
      OPEN "dir.pcl" FOR INPUT AS #1
     FOR x = 1 TO 4: INPUT #1, a$: NEXT x         'skipps the first 4 lines
    x = 0
   WHILE NOT EOF(1)
  INPUT #1, a$
IF MID$(a$, 10, 3) = "BAS" THEN x = x + 1: arr$(x) = LEFT$(a$, 8)
WEND

' The Creed part, "My Own Prison".  La La La...

FOR y = 1 TO x

' This is the "Alice In Chains" part.

CLS
LOCATE 1, 1: PRINT "Working on file "; y; " of "; x;
file$ = LEFT$(arr$(y), 8): file$ = LTRIM$(RTRIM$(file$))
LOCATE 2, 1: PRINT "File Name         : "; file$

' This is the Soundgarden part.

IF option$ = "sa exe" OR option$ = "SA EXE" THEN
  s1$ = "BC " + file$ + "/X/O/C:512;"
   s2$ = "LINK /ex /noe /seg:256 " + file$ + "+qb.lib," + file$ + ".exe,nul;"
    END IF

IF option$ = "EXE" OR option$ = "exe" THEN
  s1$ = "BC " + file$ + "/X/T/C:512;"
   s2$ = "LINK /ex " + file$ + "+qb.lib," + file$ + ",nul;"
    END IF

IF option$ = "OBJ" OR option$ = "obj" THEN
  s1$ = "BC " + file$ + "/X/O/C:512;"
   END IF

  SHELL s1$                                     'Runs BC.exe
   FOR y% = 1 TO 24
   FOR zz% = 1 TO 80
  li$(y%) = li$(y%) + CHR$(SCREEN(y%, zz%))
NEXT zz%
NEXT y%

' This part is like a Wagner symphony / I like Smashing Pumpkins better.

FOR y% = 1 TO 24
sev = INSTR(li$(y%), "Sev")
  IF sev > 0 THEN
   howmanysev = SCREEN(y%, sev - 2)
    hms$ = CHR$(howmanysev)
     hms = VAL(hms$)
      IF hms > 0 THEN
       OPEN "error.txt" FOR APPEND AS #5
        PRINT #5, "Severe Error(s) in "; arr$(y); "  Did not compile succesfully!"
         CLOSE #5
          END IF
           END IF
            NEXT y%

'     Here comes the ending ...

10  IF option$ = "OBJ" OR option$ = "obj" THEN GOTO ProgramExit:
       SHELL s2$                                 'Runs link.exe
      a$ = INKEY$: IF a$ = "q" THEN END          'Press q to end compilation
     FOR y% = 1 TO 24: li$(y%) = "": NEXT y%
    NEXT y                                       'Compiles next file.
   KILL "*.obj"                                  'Deletes all *.obj files
    PRINT                                        'What the hell's this
     PRINT
ProgramExit:
      PRINT "Start Time : "; start$              'show how long the compile/
       PRINT "End   Time : "; TIME$              'link process took
        PRINT
         END                                     'ends the compilation program

20   KILL "dir.pcl"
     KILL "error.txt"
' This is the end, my only friend the end.
