write formatted output to the Maple user interface from external code - Maple Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Programming : OpenMaple : C Application Programming Interface : Output : OpenMaple/C/MaplePrintf

MaplePrintf - write formatted output to the Maple user interface from external code

MapleALGEB_Printf - write formatted output to the Maple user interface from external code

MapleALGEB_SPrintf - write formatted output to a string in external code

Calling Sequence

MaplePrintf(kv, format, hw_arg1, hw_arg2, ..., hw_argN)

MapleALGEB_Printf(kv, format, mpl_arg1, mpl_arg2, ..., mpl_argN)

MapleALGEB_SPrintf(kv, format, mpl_arg1, mpl_arg2, ..., mpl_argN)




kernel handle of type MKernelVector



output format specification

hw_arg1, ..., hw_argN


hardware data

mpl_arg1, ..., mpl_argN


type ALGEB objects



These functions can be used in external code with OpenMaple or define_external.


MaplePrintf is the same as the printf function in the C standard library, except that it directs output to the Maple user interface instead of stdout.  The extra arguments must all be hardware types (for example, int, float, and char*).


MapleALGEB_Printf is the same as the Maple printf function.  The extra arguments must all be Maple objects (of type ALGEB). Of note in the format specification, %a, formats an object of any Maple type, whereas, for example, %d formats only Maple integers.


MapleALGEB_SPrintf is the same as the Maple sprintf function.  It returns a Maple String object containing the formatted output.


When an argument to MapleALGEB_Printf or MapleALGEB_SPrintf is an expression sequence, it is formatted as if it were a list.


    #include "maplec.h"

    ALGEB M_DECL MyArgs( MKernelVector kv, ALGEB *args )


    M_INT i, n;

    MaplePrintf(kv,"External routine called with %ld argumentsn",


    for( i=1; i<=n; ++i ) {

        MapleALGEB_Printf(kv,"arg[%d] = %an",ToMapleInteger(kv,i),args[i]);


    if( n == 0 )

        return( ToMapleString(kv,"") );


        return( MapleALGEB_SPrintf(kv,"%a",args[1]) );


Execute the external function from Maple.





External routine called with 2 arguments
arg[1] = 1
arg[2] = 2




External routine called with 3 arguments
arg[1] = x^2+1
arg[2] = [1, 2]
arg[3] = 2^(1/2)



See Also

CustomWrapper, define_external, OpenMaple, OpenMaple/C/API, OpenMaple/C/Examples, printf, sprintf

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