Page 1 of 1
[Implemented] Some commands to handle the debug output
Posted: Mon Feb 26, 2007 5:53 pm
by Hurga
Think it would be useful to have (at least) two commands to works with the debugger output. (The same like the buttons)
First one to Clear the window
Second one to save the contant in a text file
Expl:
ClearDebugger()
SaveDebugger(path + File)
Would be helpful... (at least for me

)
Posted: Mon Feb 26, 2007 7:01 pm
by Kale
These have been asked for from the year dot. Don't hold your breath.

Posted: Tue Feb 27, 2007 1:06 pm
by PB
Here's my versions of Danilo's examples (well, only one was his example,
because I didn't use his "clear" example because mine was shorter).

Also, his versions don't work with v4.xx so they needed freshening up.
[Edit] Now works with the Integrated and Standalone debugger.
Code: Select all
Procedure GetDebugOutputWindow()
Sleep_(10) ; Short delay seems necessary.
r=GetWindow_(GetDesktopWindow_(),#GW_CHILD)
Repeat
t$=Space(999) : GetWindowText_(r,t$,999)
If Left(t$,15)="Debug Output - "
w=r
Else
r=GetWindow_(r,#GW_HWNDNEXT)
EndIf
Until r=0 Or w<>0
ProcedureReturn w
EndProcedure
Procedure ClearDebugOutput() ; Returns 0 on failure.
d=GetDebugOutputWindow()
If d : s=SendMessage_(FindWindowEx_(d,0,"ListBox",0),#LB_RESETCONTENT,0,0) : EndIf
ProcedureReturn s
EndProcedure
Procedure SaveDebugOutput(file$) ; Returns 0 on failure.
d=GetDebugOutputWindow()
If d And CreateFile(0,file$)
s=1 : l=FindWindowEx_(d,0,"ListBox",0) : n=SendMessage_(l,#LB_GETCOUNT,0,0)
For a=0 To n-1
b=SendMessage_(l,#LB_GETTEXTLEN,a,0) : t$=Space(b)
SendMessage_(l,#LB_GETTEXT,a,@t$) : WriteStringN(0,t$)
Next
CloseFile(0)
EndIf
ProcedureReturn s
EndProcedure
For a=1 To 5 : Debug a : Next
Debug "Clearing in 2 seconds..."
Delay(2000)
ClearDebugOutput()
For a=6 To 10 : Debug a : Next
SaveDebugOutput("c:\debug.txt")
Debug "Saved lines 6 to 10 to c:\debug.txt"
Posted: Tue Feb 27, 2007 1:17 pm
by ts-soft
>> Note #2: I'm not 100% sure if the window class
doesn't work, WindowClass_13709520 for external Debugger, and another for Internal
Posted: Tue Feb 27, 2007 1:22 pm
by PB
I expected a problem like that.

Edited my post with a fix.
Posted: Wed Feb 28, 2007 9:45 am
by Hurga
Thx a lot.
That really helpful for me
Re: Some commands to handle the debug output
Posted: Thu Feb 04, 2010 12:59 pm
by Kwai chang caine
Yes i'm of the same advice that HURGA
Perhaps the 4.50 add this function ?? :roll:
I have found also a great code of NETMAESTRO for do this
http://www.purebasic.fr/english/viewtop ... 78#p225778
Thanks to PB for his code
But in the code of PB..the function SaveDebugOutput don't works

I have always a zero return by the API
Code: Select all
n=SendMessage_(l,#LB_GETCOUNT,0,0)
And i don't know why ?? :roll:
It's a pity, because the code of NETMAESTRO don't save the file

Re: Some commands to handle the debug output
Posted: Thu Feb 04, 2010 2:02 pm
by UserOfPure
Kwaï chang caïne wrote:the function SaveDebugOutput don't works
It looks like it was written in 2007, using an older version of PureBasic. Someone needs to update it for 2010.
Re: Some commands to handle the debug output
Posted: Thu Feb 04, 2010 3:20 pm
by Kwai chang caine
Ok thanks
