Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Remove Remarks for Programs
#7
(10-26-2024, 08:16 AM)SMcNeill Wrote: That seems like an awful lot of code to do something really simple @Pete 

How's this work for you?

Code: (Select All)
Do
    BasIn$ = _OpenFileDialog$("File to Remove Comments From", "", "*.bas|*.bi|*.bm", "QB64PE files", 0)
    If BasIn$ <> "" Then
        period = _InStrRev(BasIn$, ".")
        BasOut$ = Left$(BasIn$, period - 1) + " (No Rem)" + Mid$(BasIn$, period)
        Open BasIn$ For Binary As #1
        Open BasOut$ For Output As #2
        Do Until EOF(1)
            Line Input #1, temp$
            in_quote = 0
            For p = 1 To Len(temp$)
                m$ = Mid$(temp$, p, 1)
                Select Case m$
                    Case Chr$(34) 'quote
                        in_quote = Not in_quote
                    Case "'" 'Remark character
                        If Not in_quote Then 'remark found
                            If p = 1 _Andalso Mid$(temp$, 2, 1) = "$" Then p = Len(temp$) + 1 'it's a metacommand
                            Exit For
                        End If
                    Case "$"
                        If p = 1 Then p = Len(temp$) + 1 'it's a metacommand
                End Select
            Next
            o$ = Left$(temp$, p - 1)
            Print #2, o$
        Loop
    Else System
    End If
Loop

Well, that worked (surprise, surprise)! at least, on a 1-liner with code plus '
Edit: and on a 400+ line prog with copious rems
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply


Messages In This Thread
Remove Remarks for Programs - by Pete - 10-26-2024, 02:01 AM
RE: Remline clone for QB64. - by ahenry3068 - 10-26-2024, 03:33 AM
RE: Remline clone for QB64. - by ahenry3068 - 10-26-2024, 03:51 AM
RE: Remline clone for QB64. - by Pete - 10-26-2024, 04:02 AM
RE: Remline clone for QB64. - by ahenry3068 - 10-26-2024, 07:25 AM
RE: Remove Remarks for Programs - by SMcNeill - 10-26-2024, 08:16 AM
RE: Remove Remarks for Programs - by PhilOfPerth - 10-26-2024, 09:50 AM
RE: Remove Remarks for Programs - by Dimster - 10-26-2024, 01:14 PM
RE: Remove Remarks for Programs - by Dimster - 10-26-2024, 02:01 PM
RE: Remove Remarks for Programs - by SMcNeill - 10-26-2024, 09:42 PM
RE: Remove Remarks for Programs - by Pete - 10-26-2024, 10:31 PM
RE: Remove Remarks for Programs - by SMcNeill - 10-26-2024, 10:47 PM
RE: Remove Remarks for Programs - by Pete - 10-26-2024, 11:03 PM
RE: Remove Remarks for Programs - by PhilOfPerth - 10-26-2024, 11:26 PM
RE: Remove Remarks for Programs - by Pete - 10-26-2024, 11:29 PM
RE: Remove Remarks for Programs - by Dimster - 10-27-2024, 12:49 PM
RE: Remove Remarks for Programs - by SMcNeill - 10-27-2024, 01:04 PM
RE: Remove Remarks for Programs - by Dimster - 10-27-2024, 02:22 PM



Users browsing this thread: 2 Guest(s)