Can I get info about SUB inside SUB?
#15
Like I mentioned before, the simple way I'd do this is just like so:

Code: (Select All)
$Let DEBUG = TRUE

a = 1
foo a, b, c
Print a, b, c




Sub foo (x, y, z)
    $If DEBUG Then
        Print "========================"
        Print "Init Sub Foo..."
        Print "Init value x = "; x
        Print "Init value y = "; y
        Print "Init Value z = "; z
        Print "========================"
    $End If
    x = x + 1
    y = x * 2
    z = y - x
    $If DEBUG Then
        Print "========================"
        Print "Exit Sub Foo..."
        Print "Exit value x = "; x
        Print "Exit value y = "; y
        Print "Exit Value z = "; z
        Print "========================"
    $End If
End Sub


Now you can use the precompiler to set if you want to see debug/trace info or not, and you can specify exactly what pieces of information is relevant for you to track and report on with your program as it's running.  If you want to get fancy, add some COLOR statements to the $IF block so the debug info stands out a little more relevant for you, if you want.  

If you're wanting custom debugging or logging, then it's generally best to just write the simple debug and log code yourself.  Otherwise, exactly what the heck do you expect the program to automatically log for you?  Passed variables?  Internal variables?  Variable values at multiple positions inside the routine?  How about array?  Do you just need a single value or should it update the whole array when logging?  Or mem blocks?  image handles?   Font handles?  How the heck do you expect the program to log *EVERYTHING* inside a complex sub/function?   Isn't it just much better to write the code yourself for the specific pieces of information you need, rather than expecting everything to automatically be there at your fingertips to spew out every possible value just when you type "Debug = True" somewhere?
Reply


Messages In This Thread
RE: Can I get info about SUB inside SUB? - by SMcNeill - 05-13-2023, 05:33 AM



Users browsing this thread: 8 Guest(s)