| View previous topic :: View next topic |
| Author |
Message |
Stanley Krute
Joined: 30 Jul 2005 Posts: 38
|
Posted: Sat Nov 21, 2009 6:10 pm Post subject: sweet&simple debugging message templates |
|
|
Here's one of my favorite sweet&simple debugging message templates:
| Code: | | ; MsgBox % "[debugging] [line " . A_LineNumber . "]`n`n" . "Put_Some_Var_Name_Here: " . Put_Some_Var_Name_Here |
I sprinkle it around my code when debugging some doh!-ness. Paste in a var name and remove the ; when I want to look at a var value. Produces stuff like this:
I imagine other folks may have similar tekn3x. Share away.
-- ahknoob stan |
|
| Back to top |
|
 |
Stanley Krute
Joined: 30 Jul 2005 Posts: 38
|
Posted: Sat Nov 21, 2009 8:02 pm Post subject: |
|
|
Here's a variant of the above, but this template's for multiple vars:
| Code: | if 0 ; set to 1 to debug
{
scratch := ""
scratch := scratch . "Put_Some_Var_Name_Here: " . Put_Some_Var_Name_Here . "`n"
scratch := scratch . "Put_Some_Var_Name_Here: " . Put_Some_Var_Name_Here . "`n"
scratch := scratch . "Put_Some_Var_Name_Here: " . Put_Some_Var_Name_Here . "`n"
MsgBox % "[debugging] [line " . A_LineNumber . "]`n`n" . scratch
} |
Replace the var name placeholders, then replace the 0 with a 1 in the if test at the top when you want to see those var values. |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 2427
|
Posted: Sun Nov 22, 2009 12:24 am Post subject: |
|
|
Nice concept, most users come here not knowing how to set their code up for debugging and this is a nice template.
Since you're well familiar with the concatenation operator you could use the continuation section style to concatenate multiple results rather than assigning the variable to itself plus concatenation each time:
| Code: | if 0 ; set to 1 to debug
{
scratch := ""
scratch := scratch . "Put_Some_Var_Name_Here: " . Put_Some_Var_Name_Here . "`n"
. "Put_Some_Var_Name_Here: " . Put_Some_Var_Name_Here . "`n"
. "Put_Some_Var_Name_Here: " . Put_Some_Var_Name_Here . "`n"
MsgBox % "[debugging] [line " . A_LineNumber . "]`n`n" . scratch
} |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
entropic
Joined: 21 Dec 2008 Posts: 161
|
Posted: Sun Nov 22, 2009 3:25 am Post subject: |
|
|
On a side-note I've always thought it would be nice if you could do this:
| Code: |
Lines := ListLines()
Vars := ListVars()
FileAppend, %Lines% `n`n %Vars%, DebugLog.txt
|
|
|
| Back to top |
|
 |
gwarble
Joined: 23 May 2009 Posts: 125 Location: north bay, california
|
Posted: Sun Nov 22, 2009 6:04 am Post subject: |
|
|
i made Notify() for this purpose without pausing the script... good for variables or labels/timers when a msgbox doesn't cut it, and multiple can be shown... although its evolved into more, i still use it a lot for this:
| Code: | Notify("Variable at line " A_LineNumber, Variable)
Notify(A_ThisLabel)
Notify("Var1 = " Var1 "`nVar2 = " Var2 "`nVar3 = " Var3)
; or...
Notify("Var1 = " Var1)
Notify("Var2 = " Var2)
Notify("Var3 = " Var3) |
- gwarble |
|
| Back to top |
|
 |
aaffe
Joined: 17 May 2007 Posts: 941 Location: Germany - Deutschland
|
Posted: Mon Nov 23, 2009 10:41 am Post subject: |
|
|
I think it should be
scratch .= "Put Some Var_Name_Here: " . Put_Some_Var_Name_Here . "`n"
instead of
scratch := scratch . ....
Ok, this only is a little shorter, but shorter is better, I think.
| sinkfaze wrote: | Nice concept, most users come here not knowing how to set their code up for debugging and this is a nice template.
Since you're well familiar with the concatenation operator you could use the continuation section style to concatenate multiple results rather than assigning the variable to itself plus concatenation each time:
| Code: | if 0 ; set to 1 to debug
{
scratch := ""
scratch := scratch . "Put_Some_Var_Name_Here: " . Put_Some_Var_Name_Here . "`n"
. "Put_Some_Var_Name_Here: " . Put_Some_Var_Name_Here . "`n"
. "Put_Some_Var_Name_Here: " . Put_Some_Var_Name_Here . "`n"
MsgBox % "[debugging] [line " . A_LineNumber . "]`n`n" . scratch
} |
|
|
|
| Back to top |
|
 |
|