Page 1 of 1

DebugOutput window / Script line

Posted: Wed Mar 27, 2024 11:06 am
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.

Re: DebugOutput window / Script line

Posted: Wed Mar 27, 2024 11:51 am
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"

Re: DebugOutput window / Script line

Posted: Wed Mar 27, 2024 12:10 pm
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

Re: DebugOutput window / Script line

Posted: Wed Mar 27, 2024 12:15 pm
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

Re: DebugOutput window / Script line

Posted: Wed Mar 27, 2024 1:23 pm
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.

Re: DebugOutput window / Script line

Posted: Thu Mar 28, 2024 12:13 am
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