SMOOTSARA Active Member Licensed User Longtime User Feb 10, 2018 #1 Hello friends I want to clean the application code. The number of lines of the B4A is more than 3000 lines, which is a lot of comments Is there a quick way to identify commented lines? Until I clear them quickly If this is not possible in the B4A , this could be a good suggestion for future releases. Good luck
Hello friends I want to clean the application code. The number of lines of the B4A is more than 3000 lines, which is a lot of comments Is there a quick way to identify commented lines? Until I clear them quickly If this is not possible in the B4A , this could be a good suggestion for future releases. Good luck
LucaMs Expert Licensed User Longtime User Feb 10, 2018 #2 Why do you want to remove them? Comments are very useful and they will not be compiled. Upvote 0
johndb Active Member Licensed User Longtime User Feb 10, 2018 #3 arastoo said: Hello friends I want to clean the application code. The number of lines of the B4A is more than 3000 lines, which is a lot of comments Is there a quick way to identify commented lines? Until I clear them quickly If this is not possible in the B4A , this could be a good suggestion for future releases. Good luck Click to expand... I agree with @LucaMs, why delete your comments? If you insist on deleting your comments then I would recommend that you write a small B4J program to open the .bas file and remove all lines starting with "'". Upvote 0
arastoo said: Hello friends I want to clean the application code. The number of lines of the B4A is more than 3000 lines, which is a lot of comments Is there a quick way to identify commented lines? Until I clear them quickly If this is not possible in the B4A , this could be a good suggestion for future releases. Good luck Click to expand... I agree with @LucaMs, why delete your comments? If you insist on deleting your comments then I would recommend that you write a small B4J program to open the .bas file and remove all lines starting with "'".
SMOOTSARA Active Member Licensed User Longtime User Feb 10, 2018 #4 johndb said: I agree with @LucaMs, why delete your comments? If you insist on deleting your comments then I would recommend that you write a small B4J program to open the .bas file and remove all lines starting with "'". Click to expand... Hi dear friend Is it possible to write this program? I need to clear comments to provide the product to the customer Upvote 0
johndb said: I agree with @LucaMs, why delete your comments? If you insist on deleting your comments then I would recommend that you write a small B4J program to open the .bas file and remove all lines starting with "'". Click to expand... Hi dear friend Is it possible to write this program? I need to clear comments to provide the product to the customer
LucaMs Expert Licensed User Longtime User Feb 10, 2018 #5 arastoo said: I need to clear comments to provide the product to the customer Click to expand... The source code? Upvote 0
arastoo said: I need to clear comments to provide the product to the customer Click to expand... The source code?
SMOOTSARA Active Member Licensed User Longtime User Feb 10, 2018 #6 LucaMs said: The source code? Click to expand... Dear friend. Sending your application's source is impossible. Upvote 0
LucaMs said: The source code? Click to expand... Dear friend. Sending your application's source is impossible.
johndb Active Member Licensed User Longtime User Feb 10, 2018 #7 arastoo said: Hi dear friend Is it possible to write this program? I need to clear comments to provide the product to the customer Click to expand... It is possible to write the program. It uses the same Basic syntax as B4A or any of the other B4X products. That's the wonderful thing about this RAD system. If you are asking us to write the code for you then unfortunately my time is limited at the present time. Sorry. Upvote 0
arastoo said: Hi dear friend Is it possible to write this program? I need to clear comments to provide the product to the customer Click to expand... It is possible to write the program. It uses the same Basic syntax as B4A or any of the other B4X products. That's the wonderful thing about this RAD system. If you are asking us to write the code for you then unfortunately my time is limited at the present time. Sorry.
LucaMs Expert Licensed User Longtime User Feb 10, 2018 #8 arastoo said: I need to clear comments to provide the product to the customer Click to expand... LucaMs said: The source code? Click to expand... Intendevo chiederti se devi cedere al tuo cliente il codice sorgente, non di inviarlo a me If you sell your source code, I think that your customer will need the comments. If you sell only the apk, you don't need to remove them. Anyway, as @johndb wrote, it is simple to develop a small tool to remove COMMENT LINES (lines with commands and comments are more difficult to handle, of course). Just a multi file selector, a button, CREATE BACKUPS, read all lines in a List, remove those that start with "'" from the list, save the list. Last edited: Feb 10, 2018 Upvote 0
arastoo said: I need to clear comments to provide the product to the customer Click to expand... LucaMs said: The source code? Click to expand... Intendevo chiederti se devi cedere al tuo cliente il codice sorgente, non di inviarlo a me If you sell your source code, I think that your customer will need the comments. If you sell only the apk, you don't need to remove them. Anyway, as @johndb wrote, it is simple to develop a small tool to remove COMMENT LINES (lines with commands and comments are more difficult to handle, of course). Just a multi file selector, a button, CREATE BACKUPS, read all lines in a List, remove those that start with "'" from the list, save the list.
Widget Well-Known Member Licensed User Longtime User Feb 10, 2018 #9 arastoo said: Hello friends I want to clean the application code. The number of lines of the B4A is more than 3000 lines, which is a lot of comments Is there a quick way to identify commented lines? Until I clear them quickly If this is not possible in the B4A , this could be a good suggestion for future releases. Good luck Click to expand... Use a grep tool like grepWin to remove the comments. Upvote 0
arastoo said: Hello friends I want to clean the application code. The number of lines of the B4A is more than 3000 lines, which is a lot of comments Is there a quick way to identify commented lines? Until I clear them quickly If this is not possible in the B4A , this could be a good suggestion for future releases. Good luck Click to expand... Use a grep tool like grepWin to remove the comments.
Erel B4X founder Staff member Licensed User Longtime User Feb 11, 2018 #10 It should be quite simple to create a B4J file that reads the source code and removes the comment lines. Upvote 0
It should be quite simple to create a B4J file that reads the source code and removes the comment lines.
Sandman Expert Licensed User Longtime User Feb 11, 2018 #11 arastoo said: Is there a quick way to identify commented lines? Click to expand... 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: Code: Copy 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.) Upvote 0
arastoo said: Is there a quick way to identify commented lines? Click to expand... 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: Code: Copy 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.)
Widget Well-Known Member Licensed User Longtime User Feb 11, 2018 #12 Sandman: This should work. I'd suggest outputting the uncommented files with the same file name but in a different directory so it will compile with no changes to the project. Upvote 0
Sandman: This should work. I'd suggest outputting the uncommented files with the same file name but in a different directory so it will compile with no changes to the project.
Sandman Expert Licensed User Longtime User Feb 11, 2018 #13 Widget said: I'd suggest outputting the uncommented files with the same file name but in a different directory Click to expand... Yep, sure, that would also work fine. Better double check the output name though so you're actually writing the output to the new dir - don't wanna overwrite the commented file... Upvote 0
Widget said: I'd suggest outputting the uncommented files with the same file name but in a different directory Click to expand... Yep, sure, that would also work fine. Better double check the output name though so you're actually writing the output to the new dir - don't wanna overwrite the commented file...
Erel B4X founder Staff member Licensed User Longtime User Feb 12, 2018 #14 B4J code to remove comments from project files: https://www.b4x.com/android/forum/threads/make-clear-all-comments-codes.89430/#post-565604 Upvote 0
B4J code to remove comments from project files: https://www.b4x.com/android/forum/threads/make-clear-all-comments-codes.89430/#post-565604