An easy way to debug and ascertain values in progress

I’m betting that there is a smarter way to do what I’m doing.
When I am debugging a long procedure, I used to include a lot of Messges. When I was wanting to not display them, I commented them out. Then I could later turn them on again as necessary.

I then later created a Debug mode and checked to see if I was in Debug mode and only displayed the messages when needed.

Then I later recognized that I really needed to sometimes Stop the procedure when I saw that it had gone off the rails and needed to alter the code. What I have at the moment is a lot of code that really should not be necessary to have the opportunity to be in debug mode and see certain values or stop a procedure. This is what I have lots and lots of time in a procedure.

Local LDebugMode AlertYesNo "Are you in debug mode?" If Info("DialogTrigger")="Yes" LDebugMode="Yes" Else LDebugMode="No" EndIf

If LDebugMode="Yes" 
Alert "Continue,Exit Debug Mode,Stop Procedure" FGBoatVSailsCriteria + ": Boat V Sails= " + Info("Selected")
If Info("DialogTrigger")="Stop Procedure"
    Stop
ElseIf Info("DialogTrigger") = "Exit Debug Mode"
    LDebugMode = "No"
EndIf 
EndIf    

Is there an easier way to accomplish what I think every programmer needs or would like to do?

Robert, have you taken a good look at the new Debug Instrumentation feature in Panorama X 10.2? (For those of you not signed up for the 10.2 preview, you’ll have to wait a bit longer for this.)

If you want to have code that only runs when instrumentation is enabled, use the zlogging( function.

ZLogging will only eliminate the LDebugMode portion of my code.

What I’m looking for is an easy way to report the value of a variable, then be able to easily Continue, Stop the Procedure, or Exit debug mode. I can not see how ZLogging does any of this.

The procedure at hand calculates lots of different values and many later values are based on previous calculated values so there is much need to have dynamic reporting of the situation as the procedure moves through the process. Stopping it when necessary, which is no longer supported with the Command-Period has only made the situation worse. Then too, if I am early in the procedure and want to then ‘let it run’, I can not turn off debug without my code.

Tell me what I am missing with ZLogging

The new debug instrumentation is all about reporting values. You view these values in the console or terminal, there’s no need to stop. I do a LOT of debugging of Panorama code problems, and in my opinion this is the best thing sinced sliced bread. I just used instrumentation to quickly track down multiple issues today.

You also have access to a 90 minute video on this topic.


P.S. I would replace all of the code in your original post with this:

zlog labelize(FGBoatVSailsCriteria)+" "+labelizeinfo("selected")

You can leave this line in permanently, and enable/disable it as needed using the Instrumentation menu.

1 Like