Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Knox on Mon 28/09/2009 15:05:12

Title: Suggestion: Comment Add and Comment Remove + Bookmark
Post by: Knox on Mon 28/09/2009 15:05:12
Hi,

Im not entirely sure if this is the right place to post this, but I think it would be great to have a feature in the scripting part of AGS to right-click on a line and "add comment" or "remove comment"...so you can highlight a whole block of script, and add a comment...kind of like in UltraEdit...and also to have a feature of adding bookmarks so you can press a key and scroll though your bookmarks...

Does anyone think this would be useful?
Title: Re: Suggestion: Comment Add and Comment Remove + Bookmark
Post by: monkey0506 on Mon 28/09/2009 15:19:21
One thing that I do for commenting out large blocks of code at once is using specially formatted block-comments:

/**/
cEgo.Walk(120, 80); // this line is NOT commented
/**/

/*/
cEgo.Walk(120, 80); // this line IS commented
/**/


As you can see by only removing one asterisk I changed the line from not being commented to being commented. This is because the /**/ is a block comment with nothing in it. It just opens and immediately closes the comment. /*/ opens a block comment, the very first character of which is the forward-slash ('/'). Inside an open comment /* is ignored (that is, you cannot nest block comments). And finally the */ close of the block comment we opened with /*/.

And if that wasn't enough for you, you can even use this technology to set up a comment block switch to using only a single character switch between two different blocks of code!

/**/ // start comment switch, currently not commented
cEgo.Walk(120, 80); // NOT commented
/*/ // switch block, now inside of a block comment
cEgo.Walk(200, 40); // IS commented
/**/ // end comment switch and block comment started by switch block


Now by removing only one asterisk:

/*/ // start comment switch, currently is commented
cEgo.Walk(120, 80); // IS commented
/*/ // switch block, ends block comment started by start of comment switch
cEgo.Walk(200, 40); // NOT commented
/**/ // end comment switch, already outside of comment so opens and closes new block comment


So as you can see here we're using the /*/ as both the start and end of comment blocks. If we're not currently inside a block comment then it will open one, commenting out the second block of code. However if we are currently inside a block comment it will exit that comment, uncommenting the second code block.

Might be a bit confusing to look at but AGS's syntax highlighting will let you know what's going on. Also as I said this way you only have to change one character in the script to select between two completely different blocks of code. 8)
Title: Re: Suggestion: Comment Add and Comment Remove + Bookmark
Post by: Intense Degree on Mon 28/09/2009 15:55:53
Quote from: general_knox on Mon 28/09/2009 15:05:12
...and also to have a feature of adding bookmarks so you can press a key and scroll though your bookmarks...

I'll second that. Very handy for a "less experienced" coder such as me!
Title: Re: Suggestion: Comment Add and Comment Remove + Bookmark
Post by: Knox on Mon 28/09/2009 18:42:35
Wow Monkey,

Didn't know you could do that...I'll surely use that trick in the meantime!

:)
Title: Re: Suggestion: Comment Add and Comment Remove + Bookmark
Post by: Dualnames on Tue 29/09/2009 07:31:20
Quote from: Intense Degree on Mon 28/09/2009 15:55:53
Quote from: general_knox on Mon 28/09/2009 15:05:12
...and also to have a feature of adding bookmarks so you can press a key and scroll though your bookmarks...

I'll second that. Very handy for a "less experienced" coder such as me!

Comments is ok, and there's no need for me. Bookmarks however in a 25000 script game, could really work.
Title: Re: Suggestion: Comment Add and Comment Remove + Bookmark
Post by: SSH on Tue 29/09/2009 11:13:06
Split your code into functions, then you can use the automatic function bookmarks
Title: Re: Suggestion: Comment Add and Comment Remove + Bookmark
Post by: Khris on Tue 29/09/2009 12:08:49
Also, create multiple scripts and group stuff together.
Even for smaller projects, I usually have at least three or four scripts beside the global one.
Title: Re: Suggestion: Comment Add and Comment Remove + Bookmark
Post by: Dualnames on Wed 30/09/2009 14:38:18
Quote from: SSH on Tue 29/09/2009 11:13:06
Split your code into functions, then you can use the automatic function bookmarks
Split 25000 lines of code plus 10 modules.