MapleALGEB_Printf - Maple Help

Online Help

All Products    Maple    MapleSim


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

Parameters

Description

Examples

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)

Parameters

kv

-

kernel handle of type MKernelVector

format

-

output format specification

hw_arg1, ..., hw_argN

-

hardware data

mpl_arg1, ..., mpl_argN

-

type ALGEB objects

Description

• 

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.

Examples

    #include "maplec.h"

    ALGEB M_DECL MyArgs( MKernelVector kv, ALGEB *args )

    {

    M_INT i, n;

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

        (long)(n=MapleNumArgs(kv,(ALGEB)args)));

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

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

    }

    if( n == 0 )

        return( ToMapleString(kv,"") );

    else

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

    }

Execute the external function from Maple.

withExternalCalling&colon;

dllExternalLibraryNameHelpExamples&colon;

showDefineExternalMyArgs&comma;dll&colon;

show1&comma;2

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

1

(1)

showx2+1&comma;1&comma;2&comma;sqrt2

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

x^2+1

(2)

See Also

CustomWrapper

define_external

OpenMaple

OpenMaple/C/API

OpenMaple/C/Examples

printf

sprintf