Jump to content
Sign in to follow this  
step887

to call a function or not

Recommended Posts

step887

I am building a debug function into my script, I only want this function to be called, if $debug = True..

So my question:

do I an If Then statement like:

If $debug = True Then debug('stuff')

func debug($para1)

msgbox(0,'',$para1)

Endfunc

or do I call the function everytime like and return if $debug is not True

debug('stuff')

func debug($para1)

If Not $debug Then Return

msgbox(0,'',$para1)

Endfunc

So my only concern would be performance.. if I am debugging, it could be called 1000s of times and it will not be calling a msgbox, it will logging to a file..

So which would better or does it not really matter?

Share this post


Link to post
Share on other sites
JohnOne

I think the first option would be better "If $debug = True Then debug('stuff')"

Only 1 boolean variable is always being checked, the second is always making a call to a function and checking the variable.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×