MergeFile
#1
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.  Wink
Reply


Messages In This Thread
MergeFile - by SMcNeill - 12-27-2022, 05:26 PM
RE: MergeFile - by grymmjack - 12-27-2022, 06:37 PM
RE: MergeFile - by SpriggsySpriggs - 12-28-2022, 03:00 PM
RE: MergeFile - by grymmjack - 01-10-2023, 02:53 AM
RE: MergeFile - by SpriggsySpriggs - 01-10-2023, 03:38 PM
RE: MergeFile - by a740g - 01-10-2023, 05:16 PM
RE: MergeFile - by SpriggsySpriggs - 01-10-2023, 05:18 PM
RE: MergeFile - by SpriggsySpriggs - 01-10-2023, 05:20 PM
RE: MergeFile - by grymmjack - 04-18-2023, 09:58 PM



Users browsing this thread: 4 Guest(s)