Jump to content

to call a function or not


step887
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

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