Delete/Remove All Comments - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11) +--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2) +---- Forum: Site Suggestions (https://qb64phoenix.com/forum/forumdisplay.php?fid=12) +---- Thread: Delete/Remove All Comments (/showthread.php?tid=3168) |
Delete/Remove All Comments - Dimster - 10-25-2024 I tend to have a number of smaller well commented codes which eventually I roll together into a finished larger program. These smaller code sections can have quite a few lines of code and comments which get copied and pasted into the larger program. To remove the comments from the finished larger program I have been hunting and highlighting the comments and deleting them as I find them. I was thinking the IDE may be more helpful in this regard if there was an option under the EDIT to Remove ALL COMMENTS. RE: Delete/Remove All Comments - SpriggsySpriggs - 10-25-2024 You can probably use some sort of regex script to do this. RE: Delete/Remove All Comments - Dimster - 10-25-2024 I know what they are but that's the sum total of my regex script knowledge. I would assume it could be very complicated to find every incident of a Rem or comment line and to distinguish the " ' " at the beginning of the line as opposed to a " ' " as part of the comment itself (ie REM: It's a key Do Loop v's the previous Do Loops) ( ' : It's a key Do Loop v's the previous Do Loops) Looking at that example I suppose I could change my coding habit with comments to be sure I used REM instead of " ' " to simplify the regex script. Boy always something new to learn, never a dull moment when you're into coding. Thanks Spriggsy RE: Delete/Remove All Comments - SMcNeill - 10-25-2024 Wouldn't this be as simple as writing a program that 1) read each line one line at a time 2) parse that line from left to right... 2a) Look for quote symbol so you can skip until next quote symbol in case something is like PRINT "Don't each cheese!" 2b) If you're not inside a quite, find the first comment symbol. At that point, you can elimiate it and everything to the right. 3) Write the edited line to a new file called "No Comment " + name$ 4) Loop until done RE: Delete/Remove All Comments - Pete - 10-25-2024 @Dimster In it's simplest form... Code: (Select All)
Applied to remove lines that are completely remarked and to get rid of trailing colons... Code: (Select All)
I don't know if QB64 still uses that _ symbol to wrap a code line. If it does, that would have to be included in an analysis. Play around with it, and let me know if there are any chinks in the armor. Pete RE: Delete/Remove All Comments - PhilOfPerth - 10-25-2024 Couldn't the Find/Replace All function be adapted to include Replace After (or something similar) so a search for ' or Rem woudl remove all code after them in the line? RE: Delete/Remove All Comments - Pete - 10-25-2024 Back in the day it was called Remline, but it was always an independent app and never added to QBasic. Pete |