Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Remove Remarks for Programs
#13
Basically that replace Rem with ' is what mine is essentially doing.

Now back in the day, we were a pretty tough bunch. Find one little oopsie in a routine and 10 members were eating your lunch! Ah, the good ol' days. No participation trophies. Big Grin 

Okay, I'll comprise, for our kids sake: @Dimster, here is a combo of Pete and Steve's remark remover. It uses Steve's new age QB64  cool way to look up your file, with my remove remarks code. It's EXCELLENT!

Code: (Select All)
_Title "Pete and Steve's Excellent Adventure"
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) + "_nc" + Mid$(BasIn$, period)
Open BasIn$ For Binary As #1
a$ = Space$(LOF(1))
Get #1, , a$
Close #1
Open BasOut$ For Output As #2
Do
i = i + 1
x$ = Mid$(a$, i, 1)
If Asc(x$) > 32 Then col = col + 1
x2$ = LCase$(Mid$(a$, i, 4))
If Mid$(x2$, 1, 1) = "'" Then
If LTrim$(Mid$(a$, i + 2, 1)) = "$" Then x2$ = ""
ElseIf x2$ = "rem " Then
If Mid$(a$, i + 4, 1) <> "$" Then x2$ = "'" Else x2$ = ""
End If
If LCase$(Mid$(a$, i, 5)) = "data " Then dta = -1
Select Case Mid$(x2$, 1, 1)
Case "'"
If quote = 0 And dta = 0 Then
q = InStr(i, a$ + Chr$(13), Chr$(13))
If col = 1 Then lineout% = 2 Else lineout% = 0
i = q + lineout% - 1
new$ = RTrim$(new$)
If Right$(new$, 1) = ":" Then
new$ = Mid$(new$, 1, Len(new$) - 1) ' Remove trailing colon.
End If
col = 0
_Continue
End If
Case Chr$(34)
If dta = 0 Then quote = 1 - quote
Case ":"
If dta Then dta = 0
Case Chr$(13), Chr$(10)
quote = 0: col = 0: dta = 0
End Select
new$ = new$ + x$
Loop Until i >= Len(a$)
Print #2, new$
Shell _DontWait _Hide "QB64pe.exe " + BasOut$
Rem Shell _DontWait _Hide "notepad " + BasOut$
Rem _OpenFileDialog$("Here's your RemLess file!", BasOut$)
Close #2: Exit Do
Else
Exit Do
End If
Loop
System

Well, it beats the hell out of anything Bill (Sheldon) and Ted (Clippy) could ever put together. Big Grin

Pete


For Phil. Rem/Unrem any of the last few lines for how you would like to gain access to the new file.
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: 3 Guest(s)