AutoHotkey Community

It is currently May 27th, 2012, 1:35 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: November 21st, 2009, 7:10 pm 
Offline

Joined: July 30th, 2005, 3:49 pm
Posts: 42
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:

Image

I imagine other folks may have similar tekn3x. Share away.

-- ahknoob stan


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 21st, 2009, 9:02 pm 
Offline

Joined: July 30th, 2005, 3:49 pm
Posts: 42
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 1:24 am 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
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
   }

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 4:25 am 
Offline

Joined: December 21st, 2008, 7:29 pm
Posts: 181
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



Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 7:04 am 
Offline

Joined: May 23rd, 2009, 4:48 am
Posts: 363
Location: north bay, california
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 23rd, 2009, 11:41 am 
Offline

Joined: May 17th, 2007, 12:07 pm
Posts: 1004
Location: Germany - Deutschland
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
   }


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group