[Implemented] Some commands to handle the debug output

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Hurga
Enthusiast
Enthusiast
Posts: 148
Joined: Thu Jul 17, 2003 2:53 pm
Contact:

[Implemented] Some commands to handle the debug output

Post 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 :D )
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

These have been asked for from the year dot. Don't hold your breath. :?
--Kale

Image
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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"
Last edited by PB on Tue Feb 27, 2007 1:29 pm, edited 1 time in total.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post 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
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

I expected a problem like that. :) Edited my post with a fix.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Hurga
Enthusiast
Enthusiast
Posts: 148
Joined: Thu Jul 17, 2003 2:53 pm
Contact:

Post by Hurga »

Thx a lot.
That really helpful for me
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Some commands to handle the debug output

Post 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 8)
But in the code of PB..the function SaveDebugOutput don't works :(
I have always a zero return by the API :shock:

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 :(
ImageThe happiness is a road...
Not a destination
UserOfPure
Enthusiast
Enthusiast
Posts: 469
Joined: Sun Mar 16, 2008 9:18 am

Re: Some commands to handle the debug output

Post 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.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Some commands to handle the debug output

Post by Kwai chang caine »

Ok thanks :wink:
ImageThe happiness is a road...
Not a destination
Post Reply