Methods of skipping huge sections of code while debugging

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Methods of skipping huge sections of code while debugging

Post by Helmet »

Like everybody, I use # to make areas of code stop working while debugging. But sometimes I want many, many lines to temporarily stop working, such as conversations between units, so adding and subtracting a zillion #s is time-consuming. As far as I know, there is no ignore tag, where if you put ignore on line 200 and /ignore on line 2000, the computer skips all the code in between.

So, what do you guys do to skip huge sections of code?

Sometimes I change an event to name=turn 99 to keep it from firing.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
gnombat
Posts: 706
Joined: June 10th, 2010, 8:49 pm

Re: Methods of skipping huge sections of code while debugging

Post by gnombat »

Helmet wrote: October 14th, 2020, 1:06 pm adding and subtracting a zillion #s is time-consuming
Some text editors have a way to do that automatically with a single command.

Alternatively, you could use #ifdef (example).
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: Methods of skipping huge sections of code while debugging

Post by Helmet »

Wow, #ifdef works great. Thanks.

I didn't know some text editors can easily add and subtract remarks/comments. Thanks for the tip. I use TextWrangler for Mac. I'll see if it has that feature...

It does, but it only places semi-colons, not #. Evidently there is no way to change it to # in the preferences. That would've been cool.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
Celtic_Minstrel
Developer
Posts: 2207
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Methods of skipping huge sections of code while debugging

Post by Celtic_Minstrel »

Helmet wrote: October 14th, 2020, 3:15 pm Wow, #ifdef works great. Thanks.

I didn't know some text editors can easily add and subtract remarks/comments. Thanks for the tip. I use TextWrangler for Mac. I'll see if it has that feature...

It does, but it only places semi-colons, not #. Evidently there is no way to change it to # in the preferences. That would've been cool.
I am 99% sure that you can make this feature work correctly in TextWrangler. The reason it places semicolons is because it has been set to map the *.cfg file extension to the INI file format, in which semicolons are the comment character. What you need to do is change the mappings in preferences (add a custom extension mapping in the Languages section) so that *.cfg instead maps to the WML file format… which also means you need to install a language definition for the WML file format.

You can find an old one that I made right here on the forum. It's out-of-date and won't correctly highlight some tags and stuff, but I believe it should still work for the basic WML syntax, and it's just a .plist file so if you're so inclined you could probably update it yourself.

I had a better one in progress that adds an actual DLL plugin for some richer features. Unfortunately, it's rather buggy in its current state and sometimes just refuses to highlight a file at all until you reopen it, so I haven't released it. I don't use TextWrangler for editing WML lately anyway, so I haven't had much motivation to finish it, but if anyone wants the source code I can send it to them.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: Methods of skipping huge sections of code while debugging

Post by Helmet »

Celtic_Minstrel wrote: October 15th, 2020, 1:00 am...What you need to do is change the mappings in preferences (add a custom extension mapping in the Languages section) so that *.cfg instead maps to the WML file format… which also means you need to install a language definition for the WML file format...
Thank you, Celtic_Minstrel. It worked!

I have always wanted my text editor to work with WML. Wow. I'm sure this will help me make fewer mistakes. Not only can I make remarks appear and disappear like magic, my tags are now BLUE.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Post Reply