return the number of arguments in an EXPSEQ object - Maple Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Programming : OpenMaple : C Application Programming Interface : Data Queries : OpenMaple/C/ArgumentChecking

MapleNumArgs - return the number of arguments in an EXPSEQ object

IsMapleAssignedName - test if an object is an assigned name

IsMapleComplexNumeric - test if an object is complex numeric

IsMapleNumeric - test if an object is numeric

IsMapleInteger - test if an object is an integer

IsMapleInteger8 - test if an object is an 8-bit integer

IsMapleInteger16 - test if an object is a 16-bit integer

IsMapleInteger32 - test if an object is a 32-bit integer

IsMapleInteger64 - test if an object is a 64-bit integer

IsMapleList - test if an object is a list

IsMapleName - test if an object is a name

IsMapleNULL - test if an object NULL

IsMaplePointer - test if an object is a generated pointer

IsMaplePointerNULL - test if an object is the string "NULL"

IsMapleProcedure - test if an object is a Maple procedure

IsMapleRTable - test if an object is an rtable

IsMapleSet - test if an object is a set

IsMapleStop - test for an "end of session" object

IsMapleString - test if an object is a string

IsMapleTable - test if an object is a table

IsMapleUnassignedName - test if an object is an unassigned name

IsMapleUnnamedZero - test if an object is 0

Calling Sequence

MapleNumArgs(kv, s)

IsMapleAssignedName(kv, s)

IsMapleComplexNumeric(kv, s)

IsMapleNumeric(kv, s)

IsMapleInteger(kv, s)

IsMapleInteger8(kv, s)

IsMapleInteger16(kv, s)

IsMapleInteger32(kv, s)

IsMapleInteger64(kv, s)

IsMapleList(kv, s)

IsMapleName(kv, s)

IsMapleNULL(kv, s)

IsMaplePointer(kv, s)

IsMaplePointerNULL(kv, s)

IsMapleProcedure(kv, s)

IsMapleRTable(kv, s)

IsMapleSet(kv, s)

IsMapleStop(kv, s)

IsMapleString(kv, s)

IsMapleTable(kv, s)

IsMapleUnassignedName(kv, s)

IsMapleUnnamedZero(kv, s)




kernel handle of type MKernelVector



Maple object of type ALGEB



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


The IsMaple* functions test the specified type of the given Maple object. These functions all return TRUE (1) when the Maple dag, s fits the description given by the function name. If s is not of the correct type, FALSE (0) is returned.


MapleNumArgs returns the length of any Maple object.  It is most useful for computing the length of the argument expression sequence passed out to the call_external dll entry point.  An expression sequence object can be treated as a simple array with indexing starting at 1 (not 0).  For example, if args is an expression sequence and MapleNumArgs(kv,args) returns 3, then args[1], args[2], and args[3] are all Maple objects.  In the case of an external entry point, these are the arguments given during the function call.


There are several functions for determining what kind of NULL an object is. These are primarily used by automatic wrapper generation, and are not commonly be seen in hand-written code.   IsMapleUnnamedZero looks for a Maple zero object, but not a name assigned the value zero. IsMapleNULL tests for the empty expression sequence denoted by NULL in the Maple language.   IsPointerNULL tests for the C version of NULL (hardware zero), or the Maple string, "NULL".


IsMapleStop can be used with OpenMaple to detect the evaluation of the quit command.


The IsMaple...Numeric routines use the Maple type numeric definition. All other tests use the object type definition as defined by the type command. The only significant exception is IsMapleName, which returns TRUE only for NAME objects, while type(t[1], name) returns true even if it is testing a TABLEREF object.


Integer query routines, with the bit size specified in the name, test to ensure that the given Maple object, s, is a Maple integer and also that it can fit into the specified number of bits if converted to a hardware integer.


    #include <stdlib.h>

    #include "maplec.h"

    ALGEB M_DECL MyRand( MKernelVector kv, ALGEB *args )


    M_INT argc, val;

    argc = MapleNumArgs(kv,(ALGEB)args);

    if( argc != 1 ) {

        MapleRaiseError(kv,"one argument expected");

            return( NULL );


    if( !IsMapleInteger32(kv,args[1]) ) {


                "integer expected for %-1 argument, instead got %2",


            return( NULL );


    val = MapleToInteger32(kv,args[1]);

    return( ToMapleInteger(kv,(rand() % val)) );


Execute the external function from Maple.








Error, (in myrand) integer expected for 1st argument, instead got xx

See Also

CustomWrapper, define_external, OpenMaple, OpenMaple/C/API

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