a C enumeration which defines the types available for a variable
A C enumeration which defines the types available for a variable. You must include stack-c.h to benefit from this type definition.
The list of available types is the following:
Integers or enumeration types can be used to check the type of the variables. Using the enumeration type is recommended because of the explicit meaning of the value of the enumeration type.
In this example, the C gateway function takes one argument. Through a switch case structure, we display the type of the variable sent as a parameter.
#include "api_scilab.h"
#include "sciprint.h"
int sci_mysci_typesrhs(char * fname, unsigned long fname_len)
{
int iType = 0;
int* piAddr = NULL;
SciErr sciErr;
sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
if(sciErr.iErr)
{
printError(&sciErr, 0);
return 1;
}
sciErr = getVarType(pvApiCtx, piAddr, &iType);
if(sciErr.iErr)
{
printError(&sciErr, 0);
return 1;
}
switch(iType)
{
case sci_matrix:
sciprint("A matrix of doubles\n");
break;
case sci_poly:
sciprint("A matrix of polynomials\n");
break;
case sci_boolean:
sciprint("A matrix of booleans\n");
break;
case sci_sparse:
sciprint("A sparse matrix of doubles\n");
break;
case sci_boolean_sparse:
sciprint("A sparse matrix of booleans\n");
break;
case sci_matlab_sparse:
sciprint("A sparse matlab matrix\n");
break;
case sci_ints:
sciprint("A matrix of integers\n");
break;
case sci_handles:
sciprint("A graphic handle\n");
break;
case sci_strings:
sciprint("A matrix of strings\n");
break;
case sci_u_function:
sciprint("An uncompiled Scilab function\n");
break;
case sci_c_function:
sciprint("A compiled Scilab function\n");
break;
case sci_lib:
sciprint("A library of Scilab functions\n");
break;
case sci_list:
sciprint("A Scilab list\n");
break;
case sci_tlist:
sciprint("A Scilab tlist\n");
break;
case sci_mlist:
sciprint("A Scilab mlist\n");
break;
case sci_pointer:
sciprint("A pointer\n");
break;
default:
sciprint("Unknown type !\n"); // Should never happen
}
return 0;
}