From time to time I'll have to write an SCL macro that executes some BCL statements. It's usually pretty straightforward, just issue the command using the BCL() function in an SCL macro, and it'll return a numeric error code, including 0 for a normal return.
Sometimes though, especially when working with user-provided data, these commands can fail (often due to invalid characters or some such thing). When a BCL command fails, the BCL() function returns a non-zero number and an error message gets printed to the screen for the user to see.
However, a lot of the SCL macros I write are run pretty much autonomously, so anything printed to the screen gets lost to me. That's why I usually have a function for logging messages to a text file, for analysis after the fact, to see why some macro failed.
So, getting to my point, finally, when I am using the BCL statement, I like to have my own routine (named exec_bcl_cmd or something) that wraps all this stuff together: executing the BCL statement, evaluating any error code return, and logging that to a text file. I've created an example SCL file that shows most of this, just a procedure named exec_bcl_cmd, that executes a bcl statement string, then converts the bcl return code integer into a more descriptive error message (pulled from the bclerr.inc file).
You can download it here.