jackrabbit Posted December 11, 2008 Share Posted December 11, 2008 Dear all, In C, we can use #IFDEF to control which portion of the code to run. It is very handy for debug the code. I am wondering if AutoIt has similar feature? I could not find it in the document. Thanks. Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 11, 2008 Share Posted December 11, 2008 Dear all,In C, we can use #IFDEF to control which portion of the code to run. It is very handy for debug the code. I am wondering if AutoIt has similar feature? I could not find it in the document.Thanks.If you mean to prevent multiple inclusion by #include, then the include file should have #include-once at the top. This is good general practice for all include files.I don't think there are any conditional compiler directives in the AutoIt3Wrapper, but that would be a Jos question... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Developers Jos Posted December 11, 2008 Developers Share Posted December 11, 2008 If you mean to prevent multiple inclusion by #include, then the include file should have #include-once at the top. This is good general practice for all include files.I don't think there are any conditional compiler directives in the AutoIt3Wrapper, but that would be a Jos question... Nope, No conditional compiler directives available.... but there are many other options to do optional debugging. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
jackrabbit Posted December 11, 2008 Author Share Posted December 11, 2008 Nope, No conditional compiler directives available.... but there are many other options to do optional debugging. Thank you guys. I want to use that feature for debugging.For example, when I debug, I want to print out some messages with MsgBox. When I run the code regularly, I want to turn off those MsgBox. Now I have to manually turn them on and off. It is really painful since these msgbox are at different locations in the code. I am wondering how can I turn them on and off in one shot in AU3? Link to comment Share on other sites More sharing options...
Developers Jos Posted December 11, 2008 Developers Share Posted December 11, 2008 (edited) Something like this could work too: $debug = Number(IniRead("pgm.ini", "main", "debug", "0")) $a = 1 $b = 1 ; some code Debug($a) ; some code Debug($b & " test2") ; Some code Func Debug($var) If not $debug Then Return MsgBox(0, "debug", $var) EndFunc ;==>Debug Edited December 11, 2008 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
weaponx Posted December 11, 2008 Share Posted December 11, 2008 You could be creative... Global Const $Debug = True _Debug("Title", "Message", 0) Func _Debug($sTitle,$vVar,$iMode=0) If $Debug Then $sOutput = "" ;If array is passed, flatten to string If IsArray($vVar) Then For $X = 0 to Ubound($vVar)-1 $sOutput &= "["&$X&"]: " & $vVar[$X] & @CRLF Next EndIf ;Debug to console or message box If $iMode = 0 Then MsgBox(48,$sTitle,$vVar) Else ConsoleWrite($sOutput) EndIf EndIf EndFunc Link to comment Share on other sites More sharing options...
ds34 Posted December 11, 2008 Share Posted December 11, 2008 Maybe also intersting for you, especially when you need to create a modular debug:http://www.autoitscript.com/forum/index.php?showtopic=83031 Link to comment Share on other sites More sharing options...
jackrabbit Posted December 11, 2008 Author Share Posted December 11, 2008 Thank you guys. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now