10-26-2024, 09:50 AM
(This post was last modified: 10-26-2024, 09:55 AM by PhilOfPerth.)
(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.)
Please visit my Website at: http://oldendayskids.blogspot.com/
Please visit my Website at: http://oldendayskids.blogspot.com/