Can I get info about SUB inside SUB? - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://staging.qb64phoenix.com/forumdisplay.php?fid=10) +---- Thread: Can I get info about SUB inside SUB? (/showthread.php?tid=1666) Pages:
1
2
|
RE: Can I get info about SUB inside SUB? - bplus - 05-10-2023 Sorry for the wait, needed lunch. Hey this works just fine! Code: (Select All) f = f1 RE: Can I get info about SUB inside SUB? - bplus - 05-10-2023 So, Your template might look like this for any function start: Code: (Select All) Function f1 plug in with copy/paste and modify names, for example: Code: (Select All) Dim Shared As Long debug or use one of the other DIYD suggestions. RE: Can I get info about SUB inside SUB? - madscijr - 05-12-2023 (05-08-2023, 04:37 PM)thesolarcode Wrote: Hi, Here's link to a discussion on this same subject with a wild solution/hack by RhoSigma: is there a way to get the name of a function to call from a variable or data? (1/26/2022) RE: Can I get info about SUB inside SUB? - eoredson - 05-13-2023 Can't be done because: Code: (Select All) Sub MySub(V) RE: Can I get info about SUB inside SUB? - SMcNeill - 05-13-2023 Like I mentioned before, the simple way I'd do this is just like so: Code: (Select All) $Let DEBUG = TRUE 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? RE: Can I get info about SUB inside SUB? - TempodiBasic - 05-14-2023 Hi 1. I remember that someone uses to print on the console to have debug output on another window aside that of the running program. I sometimes used this way. 2. in More cases I used to print before and after the block of code that doesn't work as aspected, and this way fixes the 80-90% of bugs. After print the variables values, the program stops its flow for a SLEEP or a _DELAY. 3. I rarely print variables variations into a file for analizing it in a second time. and if I think that there is a logic bug, I allow the flow of code to drive me to the bug. PS: Option _Explicit & Option _ExplicitArray save so much time! I often mistype the name of variables! I more less declare a wrong data type among MAIN, SUB & FUNCTION parameters, in the SUB & FUNCTION with SHARED. (i.e. integer vs single vs long) My two cents PPS: Knowing in what SUB/FUNCTION we are give us poor informations...I suggest you to follow the flow on the paper or using the Debug F7/F8 to execute step by step the code. |