Error messages can be useful for debugging, but a pain to try to avoid at times. I would like to request a function that can attempt to execute code, and returns a logical to indicate whether the code generated any error messages. This would be similar to evalMacro, except that error messages would be suppressed (or returned as a string instead of being output to chat?).
e.g.
Code: Select all
[H: string = "-" ]
[H: fail = try( "[ value = eval( string ) ]" )]
Alternatively, something similar that returns an empty string instead of generating an error message, otherwise the result of the code as evalMacro (or execMacro). Or, an optional argument could change different behaviours (new variable scope, what is returned, etc.)
Reason: Some functions are quite finnicky about the arguments passed to it, and there are times when I don't really care what the error is, I just want to know if the code can execute without errors e.g. comparison of values (of different types), and the
Wiki: eval() function in particular.