Is there a quick way to identify commented lines?
This is a pretty good example of when it's good to know a couple of basic command line tools. The solution below uses the command
grep, which is used to find lines in textfiles. I've installed
UnxUtils on my Windows machine (to save my sanity, some things are just to painful to do other ways), which contains grep and lots of other quality tools. UnxUtils can be found at
http://unxutils.sourceforge.net/.
Assuming you only have comments on their own line, this might be the simplest way:
grep -v "^[[:space:]]*'" code_with_comments.bas > code_without_comments.bas
Explanation:
- grep - the program we're using
- -v - only show lines NOT matching what we're asking for below
- "^[[:space:]]*'" - this is a language in itself, but the short explanation for what we're searching for is "find me all lines that start with ', and it's ok if we have whitespace first"
- code_with_comments.bas - your code with comments
- > - don't bother showing us the result, just pour it into the file we're about to tell you about
- code_without_comments.bas - the resulting file
So this is a perfectly safe command to run, as long as you make sure you're using a new filename as the last thing on the line. (If you're using a previously used filename, that file will be overwritten.) Then you can compare that to your original file. If you like the result, just delete the original file and rename the new file to take the old ones place.
Repeat if you want to do this with more than one file. (If you're feeling more adventurous, have lots of files to do this for and feel ok to automatically do the replacement in the existing files -
do a backup of your project first! - you should google the command
sed.)