11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

332 • Chapter 7: <strong>Advanced</strong> Connectivityimmediately. If no error occurs, the result of proc(data) is returned anderrorflag is FALSE.For example, the following code attempts to execute a Maple procedure.If an error occurs, a separate branch of code is taken.typedef struct {MKernelVector k;ALGEB fn, arg1, arg2;} CallbackArgs;void *tryCallback( void *data ){/* calls the maple procedure ’fn’ with arguments ’arg1’ *//* and ’arg2’ */return (void*)EvalMapleProc( ((CallbackArgs*)data)->k,((CallbackArgs*)data)->fn, 2,((CallbackArgs*)data)->arg1,((CallbackArgs*)data)->arg2);}void MainProc( MKernelVector k, ALGEB fn ){M_BOOL errorflag;ALGEB result;CallbackArgs a;a.k = k;a.fn = fn;a.arg1 = ToMapleFloat(k,3.14);a.arg2 = ToMapleInteger(k,44);result = (ALGEB)MapleTrapError(k,tryCallback,&a,&errorflag);if( errorflag ) {/* do something */}else {/* do something else */}}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!