Jump to content

Comment out a debug line in a program


Go to solution Solved by MrBill,

Recommended Posts

Posted

I have been looking through the wiki, but can't seem to find a way to "comment out a line"

I am aware of the comment command, but it does not do what I need.

In particular, I have messages that I have inserted in programs when debugging. After everything is working, I would like to be able add a character such as a # before a command. This would stop the command from executing without having to delete the line. 

The idea being, I would not have to redo the line should the need to debug arise in the future.

Does anyone know a way to do this.

Thanks

Steve

  • Like 1
Posted

@MrBill

Do you think this might be something others might want, and a feature request to UDI would be in order?

Would it be difficult for them to implement?

Many years ago when I was a programmer we used these lines as documentation too.

 

  • Like 2
Posted
@MrBill
Do you think this might be something others might want, and a feature request to UDI would be in order?
Would it be difficult for them to implement?
Many years ago when I was a programmer we used these lines as documentation too.
 
Definitely. I have programs that are 40 to 60 lines long and when I debug I have to delete a line to test and then rebuild it before moving the new line back up 45 clicks to save.


Then there are the bad replacement errors that can creep in.

One way is to copy the program and disable the original program. Then delete bypass lines to test. Once done, delete the test program and re-enable the original program.

Sent from my SM-G781W using Tapatalk

Posted

@stevehoyt apparently I tend to over simplify things.  If it was easy to implement surly UDI would have done so.

I've participated in the threads begging for the magenta color in the admin consoles default theme (for insteon devices) to get changed to another color, instead I must change the font size to larger, it holds that size for a week or so before i must do it over.

  • 2 weeks later...
Posted
On 7/1/2023 at 11:44 AM, stevehoyt said:

@MrBill

Do you think this might be something others might want, and a feature request to UDI would be in order?

Would it be difficult for them to implement?

Many years ago when I was a programmer we used these lines as documentation too.

 

I have wished this myself many times. I'm obviously no UDI programmer, but I gotta think this can't be too hard, can it?

Of course, I'm sure this is lower on the priority list than getting Matter or Zigbee running. 

Posted (edited)
43 minutes ago, ShawnW said:

I have wished this myself many times. I'm obviously no UDI programmer, but I gotta think this can't be too hard, can it?

Of course, I'm sure this is lower on the priority list than getting Matter or Zigbee running. 

For now...and likely forever, ( Zwave,  Matter, Insteon collapsing, xxx,  YY, polyglot, polisy,  eISY, and IoX launcher, have always dominated the progress over new features and small operational bugs, for the last 4-5 years) change the line to a comment and enter the same line's text into it. When you restore it you already have the placeholder and don't have to click it up a dozen times to get it into the right place again.

Edited by larryllix
  • 4 weeks later...
Posted (edited)

You might try using a repeat command as a conditional block.

In this example
if A_Debug_Flag is 1, A_Debug_V0 winds up as 5
if A_Debug_Flag is not 1, A_Debug_V0 winds up as -5
In both cases A_Debug_V1 winds up as 100.

AW_Debug is treated as a local variable used to end the Repeat without having to change A_Debug_Flag so the program can be run the same way more than once.

image.png.b48733010fd62e48eca9d71f0ba25b3b.png

 

Edited by RDoc
Posted
9 hours ago, RDoc said:

You might try using a repeat command as a conditional block.

In this example
if A_Debug_Flag is 1, A_Debug_V0 winds up as 5
if A_Debug_Flag is not 1, A_Debug_V0 winds up as -5
In both cases A_Debug_V1 winds up as 100.

AW_Debug is treated as a local variable used to end the Repeat without having to change A_Debug_Flag so the program can be run the same way more than once.

image.png.b48733010fd62e48eca9d71f0ba25b3b.png

 

Wrong thread?

I don't see the purpose or a related message in this thread.

Did you know you can copy a program to the clipboard and paste it here in a more readable text format? Right click on any program title in the program tree, and select copy to clipboard.

Posted

@larryllixDid you read the OP?

The question was how to comment out debug code. There is no way to do that directly. However, by using a conditional block and flag variables as shown, the code can remain in place and be easily switched on and off.

A simpler but less flexible method is to use a Repeat for 0 block. Unfortunately, you can't use a variable for the repeat count.

If the Repeat count is 0 A_Debug_0 winds up -5
If the Repeat count is 1 A_Debug_0 winds up 5

I disagree that copy to clipboard produces a more readable code block and you can't paste code into programs anyway.

image.png.9dff6a4810b8aa64a27c2fcdba1d648b.png

Posted
8 minutes ago, RDoc said:

I disagree that copy to clipboard produces a more readable code block and you can't paste code into programs anyway.

When I'm helping someone debug their programs, its defiantly better if they are posted into the forum as TEXT.   Why because it's easier to copy and paste the program then make changes to it....   If I actually have to type what's in your screenshot to share a proposed change it may not happen.  If I can copy and paste it's much more efficient. 

  • Like 3
Posted (edited)

@MrBill: Good point.

ZW Test - [ID 002D][Parent 0001]

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')
 
Then
        $A_Debug_V0  = -5
        $A_Debug_V1  = -100
        $AW_Debug  = $A_Debug_Flag
        Repeat While $AW_Debug is 1
           $A_Debug_V0  = 5
           $AW_Debug  = 0
        Repeat 1 times
           $A_Debug_V1  = 100
 
Else
   - No Actions - (To add one, press 'Action')
 

Edited by RDoc
Posted
3 hours ago, RDoc said:

@MrBill: Good point.

ZW Test - [ID 002D][Parent 0001]

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')
 
Then
        $A_Debug_V0  = -5
        $A_Debug_V1  = -100
        $AW_Debug  = $A_Debug_Flag
        Repeat While $AW_Debug is 1
           $A_Debug_V0  = 5
           $AW_Debug  = 0
        Repeat 1 times
           $A_Debug_V1  = 100
 
Else
   - No Actions - (To add one, press 'Action')
 

That is not commenting out code lines for debug purposes. You are adding more complexity of conditional lines into code before any debugging is needed and not any solution for subject of this thread.

How would you debug those conditional lines if you suspected one wasn't working or doing something it shouldn't? Surely you wouldn't have added more conditions into those programs to disable the conditional lines. That would be getting more ridiculous.

The OP is wanting a way to debug existing programs not complicate them.

 

  • Like 1
Posted

This is getting silly and I'm not here to argue.

For anyone who actually wants to have a way to turn on and off a block of debugging lines, just enclose them in a Repeat block as shown. Personally, I use a debug flag variable as shown in the first example with Repeat While so you can turn on and off debugging code in a program just by changing the debug flag variable manually from 0 to 1.

However, if you just want a simpler and somewhat safer way to stop execution of a block of lines, the Repeat For 0 method will do it. To let the code lines run again, just remove the Repeat for 0 line(s).


Then
        $A_Debug_V0  = -5
        $A_Debug_V1  = -100
        Repeat 0 times            <== Don't let the code up to the next Repeat run. To let all the code execute, remove this line.
           $A_Debug_V0  = 5   <== This line (and any other lines in the Repeat block) won't run if it's Repeat 0.
        Repeat 1 times            <== When you are letting all the code execute you can remove this line too.

           $A_Debug_V1  = 100

Note for more advanced use where you want to have the same debug flag work in multiple programs:
(Ignore all this if you just are working in a single program)

I strongly suggest not using the same pseudo local variable (AW_Debug) in more than one program because it's still a global variable (there are no real local variables). You can use the same debug flag variable (A_Debug_Flag) in multiple programs as long as you only read the value, not change it programmatically.

Guest
This topic is now closed to further replies.

  • Recently Browsing

    • No registered users viewing this page.
  • Who's Online (See full list)

  • Forum Statistics

    • Total Topics
      37k
    • Total Posts
      371.3k
×
×
  • Create New...