12-27-2022, 05:26 PM
Code: (Select All)
$If WIN Then
Const Slash$ = "\"
$Else
const Slash$ = "/"
$End If
target$ = ".\source\qb64pe.bas"
outfile$ = ".\qb64onefile.bas"
If target$ = "" Then
Print "Give me a QB64 program to unravel => ";
Input target$
Print "Give me a name to save the new file under => ";
Input outfile$
End If
Open outfile$ For Output As #1
MergeFile target$
Sub MergeFile (whatfile$)
f = FreeFile
CurrentDir$ = _CWD$
i = _InStrRev(whatfile$, Slash$)
newdir$ = Left$(whatfile$, i)
If i > 0 Then
ChDir newdir$
whatfile$ = Mid$(whatfile$, i + 1)
End If
Open whatfile$ For Binary As #f
Do
Line Input #f, temp$
If Left$(UCase$(_Trim$(temp$)), 11) = "'$INCLUDE:'" Then
temp$ = _Trim$(temp$)
file$ = Mid$(temp$, 12)
file$ = Left$(file$, Len(file$) - 1)
MergeFile file$
Else
Print #1, temp$
End If
Loop Until EOF(f)
ChDir CurrentDir$
Close #f
End Sub
@grymmjack Was asking for a quick little program to merge $INCLUDE files into a single BAS file, so I sat down and wrote this one up in about 15 minutes. I haven't tested it extensively as I'm kinda distracted with my niece's kids visiting today, but it appeared to work without any issues with QB64PE.BAS and merged it all into one file easily enough.
Give it a try if you're interested in this type of thing, and if you manage to break it, post me a note on how you did so an I'll update it with a fix as soon as I get a little free time later.