Jump to content

Recommended Posts

Posted (edited)

I'm an old, long-time programmer and have learned dozens of languages over the years (anyone remember Univac Macro, or MAD?), but I adore AutoIt like crazy!  But although I'm not a noob any more, there's no denying there's a lot left to learn.

In some languages, there's one or more techniques for conditional compilation; for example, if some kind of compiler level variable/value is set to True or False (for example), the compiler can exclude some debug-only code, instead of forcing the programmer to simply comment out all the debug code (which is a real pain!)

Now, I found a request to add a new capability for something the author referred to as "conditional compliation" (see: Conditional Compilation (#if, #ifdef, #ifndef, #else, #elif, #endif, and defined) - REJECTED). But what that poster was asking for is vastly more difficult and extensive than what I'm thinking of, that's for sure!  All I want is something like this:

If %Debug ON
    Here's some special debugging code that I want to exclude from compilation...
EndIf

One of the main reasons I'd like something like this simple feature is for using the graphical debugger. It's very annoying to have to step or run though all the sub-sections of my code that are only useful before the code is already working reasonably well. In my case, I'm using a UDF written by Kobashi called "StatusMsgs" to display status messages very, very frequently during the earllier stages of debugging a GUI. I spent a lot of time adding all those status messages, and if I run across a problem in the future (say if a third-party user runs across some strange behavior or a bug), and I need additional info in order to debug the problem, it would be great to be able to enable compiling the debug code again.

Is there any relatively easy way to do that with AutoIt as it exists now, or do I have no choice but to comment/de-comment the debug code?

Thanks!

Edited by Mbee
Posted

Let's assume you call the status message with this line

StatusMsg(...)

you could simply use the SciTE editor (Ctrl+h) to change all those lines to comments:

; StatusMsg(...)

 

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

@Mbee,

make a smart use of the @Compiled built-in macro.

for example, in the UDF, go inside the assumed function StatusMsg(), that @water mentioned above. add a line just at the beginning of the function, such as:

If @Compiled Then Return

so if the code is compiled, the function returns without doing anything.

note that you need to see what return values are expected under normal operation, and mimic them.

Signature - my forum contributions:

  Reveal hidden contents

 

Posted

:)

My UDFs and Tutorials:

  Reveal hidden contents

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...