handle output redirection in OpenMaple - Maple Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Programming : OpenMaple : C Application Programming Interface : OpenMaple Functions : OpenMaple/C/redirectCallBack

redirectCallBack - handle output redirection in OpenMaple

Calling Sequence

redirectCallBack(data, name, mode)




user_data pointer passed to StartMaple (void*)



name of the file stream to redirect to (char*)



file mode to distinguish between writing and appending (char*)



This OpenMaple function is part of the MCallBackVector structure passed as an argument to StartMaple.


The redirectCallBack function is called when the kernel executes the Maple writeto or appendto function. The intent is to redirect subsequent output.


The prototype for the function you can assign to the entry in the MCallBackVector must look like the following.

M_BOOL M_DECL redirectCallBack( void *data, char *name, char *mode );


The name parameter specifies the name of the file to which output is appended.  The mode parameter specifies the file access mode to use. The mode is "wt" for write or "at" for append. The name and mode parameters are compatible with the C library function fopen.


If the name parameter is NULL (in which case the parameters are not compatible with fopen), Maple is signaling that redirection is terminated. Subsequent output is sent to, for example, the main output stream.


If no redirectCallBack function is provided, any attempt to execute the Maple writeto function or appendto function produces an error (reported using the errorCallBack function or textCallBack function).


The data parameter contains the same data as passed to StartMaple in the user_data parameter.


Source code for a redirectCallBack example is provided in the samples/OpenMaple/HelpExamples subdirectory of your Maple installation.

See Also

callBackCallBack, CustomWrapper, errorCallBack, OpenMaple, OpenMaple/C/API, OpenMaple/C/Examples, queryInterrupt, readLineCallBack, StartMaple, statusCallBack, streamCallBack, textCallBack

Download Help Document

Was this information helpful?

Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam