- Aide Scilab
- API Scilab
- Scilab Gateway API
- How to
- CheckColumn
- CheckDimProp
- CheckDims
- CheckLength
- CheckLhs
- CheckRhs
- CheckRow
- CheckSameDims
- CheckScalar
- CheckSquare
- CheckVector
- CreateListVarFrom
- CreateListVarFromPtr
- CreateVar
- FindOpt
- FirstOpt
- GetListRhsVar
- GetRhsVar
- GetType
- IsOpt
- Lhs
- LhsVar
- NumOpt
- OverLoad
- Rhs
- Scierror
- Scilab C Types
- get_optionals
- istk
- sci_types
- sciprint
- stk
Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
However, this page did not exist in the previous stable version.
FindOpt
C gateway function find the position of an optional argument given its name
Calling Sequence
Pos FindOpt(varname, opts)
Arguments
- varname
the name of the optional parameter
- opts
a C list of optional parameters
typedef struct rhs_opts__ { int position ; // stack position : -1 if not present char *name; // the name of the variable char *type; // a Scilab type (like "d") representing the type of the variable int m,n; // the size of the variable unsigned long int l; // a pointer to the Scilab stack } rhs_opts;
- Pos
the rank of the optional parameter if it has been found in the parameters sent to the C function, 0 otherwise.
Description
A C gateway function which find the position of an optional argument given its name. You must include stack-c.h to benefit from this function.
WARNING: This API is deprecated from Scilab 5.2.0 and is going to be removed with Scilab 6.0. Please use API Scilab (the new Scilab API).
Examples
A more complete example is available in the directory SCI/modules/core/example/optional_parameters.
#include <stack-c.h> int sci_optional_parameters(char * fname) { int m1,n1,l1; // optional names must be stored in alphabetical order in opts static rhs_opts opts[]= {{-1,"v1","d",0,0,0}, {-1,"v2","d",0,0,0}, {-1,NULL,NULL,0,0}}; int minrhs = 1, maxrhs = 1; int minlhs = 1, maxlhs = 3; int nopt, iopos, res; char buffer_name[csiz]; // csiz used for character coding nopt = NumOpt(); CheckRhs(minrhs,maxrhs+nopt); CheckLhs(minlhs,maxlhs); // first non optional argument GetRhsVar( 1, "c", &m1, &n1, &l1); if (get_optionals(fname,opts)==0) return 0; sciprint("number of optional parameters = %d\n", NumOpt()); sciprint("first optional parameters = %d\n", FirstOpt()); sciprint("FindOpt(v1) = %d\n", FindOpt("v1", opts)); sciprint("FindOpt(v2) = %d\n", FindOpt("v2", opts)); if (IsOpt(1,buffer_name)) sciprint("parameter 1 is optional: %s\n", buffer_name); if (IsOpt(2,buffer_name)) sciprint("parameter 2 is optional: %s\n", buffer_name); if (IsOpt(3,buffer_name)) sciprint("parameter 3 is optional: %s\n", buffer_name); return 0; }
See Also
- CheckDims — C interface function which checks if a parameter send to the C function has the required dimensions
- CheckRow — C interface function which checks if a parameter send to the C function is a row vector or not
- CheckScalar — C interface function which checks if a parameter send to the C function is a scalar or not
- CheckVector — C interface function which checks if a parameter send to the C function is a vector (column or row) or not
- CheckOverLoad — C gateway function which tells Scilab to look for another overloaded function
- CheckDimProp — C interface function which checks the comatibility between 2 arguments send to the C function
- CheckLength — C interface function which checks the length of a vector send as a parameter to the C function
- CheckSameDims — C interface function which checks if two parameters send to the C function have the same size
- CheckSquare — C interface function which checks if a parameter send to the C function is a square matrix or not
- How to check parameters — how to check parameter send to an interface using the C gateway functions
<< CreateVar | Scilab Gateway API | FirstOpt >> |