I'm testing out some code I'm in the process of writing and basically I'd like to have a function that is similar to the built-in print() function, but is controlled by a variable that I can set or clear based on whether I was trying to debug or not. So basically something like the following pseudo code:
So note that I want debugPrint() to be able to take an arbitrary number of parameters, which is what I meant by the <parameters> part in there, just like the existing print() function does. Then I can just switch the
to
to toggle these print statements, without having to find all of them in my code and comment them all out. Is there already a function that does something like this? Or if not, what would be the syntax to write the function I want where it can take an arbitrary number of parameters and pass them along to print()?
Code:
var debug := 1; // 1 means we're in debug mode, 0 means we're in release mode func debugPrint(<parameters>) if(debug == 1) print(<parameters>); else // do nothing endif endfunc func main() debugPrint("test message"); debugPrint("the value of x is ", x); debugPrint([HEX2]myHexValue); endfunc
Code:
var debug := 1;
Code:
var debug := 0;
Comment