DebugOutput window / Script line

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
tatanas
Enthusiast
Enthusiast
Posts: 260
Joined: Wed Nov 06, 2019 10:28 am
Location: France

DebugOutput window / Script line

Post by tatanas »

Hi,

Is there a way to show in the DebugOutput window the script line number from where the Debug command was executed ?
If not, It could be added as a checkbox option in the Preferences > Debugger.

Thanks.
Windows 10 Pro x64
PureBasic 6.20 x64
User_Russian
Addict
Addict
Posts: 1520
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: DebugOutput window / Script line

Post by User_Russian »

Code: Select all

Macro Line
  Str(#PB_Compiler_Line)+" "
EndMacro

Debug Line+"Text"
Debug Line+"Text"
Debug Line+"Text"
Debug Line+"Text"
Bitblazer
Enthusiast
Enthusiast
Posts: 761
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: DebugOutput window / Script line

Post by Bitblazer »

Code: Select all

Macro Line
 #PB_Compiler_File + " line " + Str(#PB_Compiler_Line) + " "
EndMacro
But it would be really helpful to be able to define some kind of prefix for debug output or optionally add sourcefile / linenumber
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: DebugOutput window / Script line

Post by Demivec »

Another macro variation:

Code: Select all

;Use macro DebugL when you want the line number included before the debug output
Macro DebugL
  Debug "" + #PB_Compiler_Line + ": " +
        
EndMacro
    
DebugL "Before Loop"
For i = 1 To 10
  DebugL i
Next

DebugL "Loop complete"
outputs:

Code: Select all

9: Before Loop
11: 1
11: 2
11: 3
11: 4
11: 5
11: 6
11: 7
11: 8
11: 9
11: 10
14: Loop complete
tatanas
Enthusiast
Enthusiast
Posts: 260
Joined: Wed Nov 06, 2019 10:28 am
Location: France

Re: DebugOutput window / Script line

Post by tatanas »

I know about macro and #PB_Compiler_File constant but I suppose it's pretty easy to add it in DebugOuput through a parameter.
Windows 10 Pro x64
PureBasic 6.20 x64
BarryG
Addict
Addict
Posts: 4136
Joined: Thu Apr 18, 2019 8:17 am

Re: DebugOutput window / Script line

Post by BarryG »

@Demivec: When I run your code, my line numbers are offset by -2 compared to yours (below is the output).

I copied your code exactly and the first line in the IDE is the ";Use macro DebugL..." comment.

Did you have 2 empty lines in your IDE before your code?

Code: Select all

7: Before Loop
9: 1
9: 2
9: 3
9: 4
9: 5
9: 6
9: 7
9: 8
9: 9
9: 10
12: Loop complete
Post Reply