Suggestion: Comment Add and Comment Remove + Bookmark

Started by Knox, Mon 28/09/2009 15:05:12

Previous topic - Next topic

Knox

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?
--All that is necessary for evil to triumph is for good men to do nothing.

monkey0506

One thing that I do for commenting out large blocks of code at once is using specially formatted block-comments:

Code: ags
/**/
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!

Code: ags
/**/ // 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:

Code: ags
/*/ // 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)

Intense Degree

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!

Knox

Wow Monkey,

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

:)
--All that is necessary for evil to triumph is for good men to do nothing.

Dualnames

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.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SSH

Split your code into functions, then you can use the automatic function bookmarks
12

Khris

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.

Dualnames

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.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk