Quantcast
Channel: Jason Andrews Blog
Viewing all articles
Browse latest Browse all 33813

RE: Reading Warning Messages from CIW using SKILL

$
0
0
Hi Karam, One way is to write a macro which redirects the woport temporarily to a string port: defmacro (CCFcaptureWarnings ( @rest body) ` let (((tempPort outstring())) unwindProtect( ;------------------------------------------------------------------ ; main clause - using dynamic scoping, redirect woport to tempPort ; and then invoke the forms passed in as the argument to the ; macro ;------------------------------------------------------------------ { let (((woport tempPort)) ,@body ; next two lines are to force final warning to be flushed warn ( "" ) getWarn () ) ;---------------------------------------------------------------- ; return value is the data written to the string port ;---------------------------------------------------------------- getOutstring(tempPort) } ;------------------------------------------------------------------ ; always execute the close even if there was an error in ; the code above ;------------------------------------------------------------------ close (tempPort) ) ) ) This uses dynamic scoping to ensure that woport is returned to its original value. Then you can wrap the code which is generating the warnings as follows, and the return value is the captured warnings: a=CCFcaptureWarnings( warn ( "hello\n" ) warn ( "world\n" ) warn ( "testing 123\n" ) ) The variable a contains the text of the warnings. Regards, Andrew.

Viewing all articles
Browse latest Browse all 33813

Trending Articles