I remember using #IF in C++ to exclude large sections of optional code at compile time. Usually something like #IF DEBUGGING followed by code that you only wanted to compile when actively testing & developing, but exclude in the final build.
I know AHK isn't compiled, but is there something I can do to achieve a similar outcome? My current project is getting pretty large, so I'm starting to think about performance optimizations. I have a lot of script sections that end up looking like this when I'm writing and testing out new script:
Code: Select all
reactToChange:
debugAppend( "Waiting to React" )
;- Disable to timer so we can set a new interval later.
SetTimer, reactToChange, Off
watchColor := getPixelColor( watchX, watchY )
if ( watchColor = reactColor ) ;- Pixel is trigger color
{
debugAppend( "Saw Reaction Color" )
reactColor := getPixelColor( reactX, reactY ) ;- Check reaction
if( reactions.HasKey( reactColor ) ) ;- Reaction is valid
{
debugAppend( "Valid Reaction" )
reaction := reactions[reactColor]
if( rangeCheck( reaction, target ) ) {
executeReaction( reaction )
}
if( !verifyReaction() )
{
debugAppend( "Reaction Failed" )
missedReactions += 1
}
}
}
nextTimer := baseWatchFrequencyMS + ( missedReactions * frequencyScaleMS )
SetTimer, reactToChange, %nextTimer%
Return
Is there any way to do this without manually editing the script to comment these lines out, or doing some kind of global search-and-replace?
[Mod edit: Fixed code tags to include the last line of code in the code box.]