Page 1 of 2
Comment blocks like rem..endrem
Posted: Tue Jan 01, 2013 9:28 pm
by EdzUp
I would like comment blocks to be added to PB yeah you have the select and adjust system but it would be more elegant if you could just call something like
rem
this is a comment line
so is this
endrem
this line is code though
Its only a small example BUT imagine if you have a hundred line piece of code you wish to change just a quick rem..endrem would work wonders or some command similar

I do prefer C's /*...*/ but thats another story

Re: Comment blocks like rem..endrem
Posted: Tue Jan 01, 2013 10:07 pm
by davido
Hi Edzup,
You can comment a range already by simply highlighting it and pressing control-B.
To un-comment it just highlight it and use alt-B
The same commands are in the right-click menu.
Regards
Dave
Re: Comment blocks like rem..endrem
Posted: Tue Jan 01, 2013 10:22 pm
by glomph
Hi,
you could use Compiler If .... and Compilerendif with something you dont use.
glomph
Re: Comment blocks like rem..endrem
Posted: Tue Jan 01, 2013 10:33 pm
by skywalk
Code: Select all
CompilerIf 0
This is 1 line of a block comment...
And so is this but you have To deal With autoformatting. :(
CompilerEndIf
Re: Comment blocks like rem..endrem
Posted: Wed Jan 02, 2013 2:24 pm
by MachineCode
CompilerIf works, but the comments are formatted incorrectly (as skywalk said), and the commented block is not in the IDE's comment color. So, it's not really a good solution.
Re: Comment blocks like rem..endrem
Posted: Wed Jan 02, 2013 4:09 pm
by Tenaja
MachineCode wrote:CompilerIf works, but the comments are formatted incorrectly (as skywalk said), and the commented block is not in the IDE's comment color. So, it's not really a good solution.
+1
Re: Comment blocks like rem..endrem
Posted: Thu Jan 03, 2013 12:50 am
by LuCiFeR[SD]
+1 on the original request. I think Rem... EndRem blocks would be very useful
Re: Comment blocks like rem..endrem
Posted: Thu Jan 03, 2013 4:10 am
by Shield
Nothing against block comments, but please not with rem / endrem...
Then again they are not needed anyway. (At least myself, I never use them in any language to comment something).
Re: Comment blocks like rem..endrem
Posted: Thu Jan 03, 2013 6:22 pm
by Tenaja
Shield wrote:Nothing against block comments, but please not with rem / endrem...
Then again they are not needed anyway. (At least myself, I never use them in any language to comment something).
Block comments are perfect for commenting out an entire procedure or set of procedures, so you can try alternates without losing the original.
I agree; Rem EndRem are not good, but something more "pb-like" would be CommentStart/End. (Although I would much rather type /* */, because it is shorter and common vernacular.
Re: Comment blocks like rem..endrem
Posted: Thu Jan 03, 2013 10:44 pm
by jassing
Tenaja wrote:
I agree; Rem EndRem are not good, but something more "pb-like" would be CommentStart/End. (Although I would much rather type /* */, because it is shorter and common vernacular.
+1 on this -- but I'd make it more "purebasic-ish"
Code: Select all
; This is a single line comment
;{
this is a multiline
comment
;}
Re: Comment blocks like rem..endrem
Posted: Fri Jan 04, 2013 3:57 am
by Shield
Tenaja wrote:
Block comments are perfect for commenting out an entire procedure or set of procedures...
Yes, but only for that. If they are actively used to actually comment the source they are nothing
more than a huge pain in the rear if they are not nestable.
Re: Comment blocks like rem..endrem
Posted: Fri Jan 04, 2013 4:07 am
by MachineCode
Tenaja wrote:Block comments are perfect for commenting out an entire procedure or set of procedures, so you can try alternates without losing the original.
What? If you comment out a procedure, then you also need to comment out all calls to that procedure; otherwise you'll get an error when trying to compile.
Re: Comment blocks like rem..endrem
Posted: Fri Jan 04, 2013 4:15 am
by Shield
Not if he replaces the procedure by an
alternative, as he said (same name, probably directly below the old procedure).
The problem with block comments is, if they are implemented as in C#, C++, Java, ... that they are not nestable,
which means commenting out block comments, e.g.
is not possible without removing the previous */. So please...make them nestable.

Re: Comment blocks like rem..endrem
Posted: Fri Jan 04, 2013 4:18 am
by MachineCode
Shield wrote:Not if he replaces the procedure by an alternative, as he said (same name, probably directly below the old procedure).
Oh, I see. In that case, it's easier to just rename the old procedure instead, rather than commenting it all out. Just add an extra single char to the start of the procedure name, to make it redundant.
Re: Comment blocks like rem..endrem
Posted: Fri Jan 04, 2013 5:48 am
by Tenaja
Shield wrote:Not if he replaces the procedure by an
alternative, as he said (same name, probably directly below the old procedure).
The problem with block comments is, if they are implemented as in C#, C++, Java, ... that they are not nestable,
which means commenting out block comments, e.g.
is not possible without removing the previous */. So please...make them nestable.

Actually, using the characters of C and Java do NOT mean it is not nestable. The ability to nest block comments is entirely up to the compiler author. It is actually quite easy to "upgrade" block comments to allow nesting, no matter WHAT character set you use to start it. This text below shows how to do it very easily with one-character, but with two or more characters, it is trivially different:
There's one last item to deal with: nested comments. Some programmers like the idea of nesting comments, since it allows you to comment out code during debugging. The code I've given here won't allow that and, again, neither will Turbo Pascal.
But the fix is incredibly easy. All we need to do is to make SkipComment recursive:
Code: Select all
{ Skip a comment field }
procedure SkipComment;
begin
while Look <> '}' do
begin
GetChar;
if Look = '{' then
SkipComment;
end;
GetChar;
end;
That does it. As sophisticated a comment-handler as you'll ever need.