Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes

Change language to:
Français - 日本語 - Português

Please note that the recommended version of Scilab is 6.1.1. This page might be outdated.
However, this page did not exist in the previous stable version.

Scilab manual >> API Scilab > Scilab Gateway API > IsOpt


C gateway function which checks if a parameter is optional and returns the name of the parameter

Calling Sequence

Res IsOpt(Pos,buffer_name)



the position in the Scilab memory of the parameter to be checked (input parameter)


an array of char (of size csiz which correspond to the maximum length of a Scilab variable) in which the name of the parameter will be copied if the position Pos is optional (output parameter)


1 if Pos has an optional parameter, 0 otherwise


C gateway function which checks if a parameter is optional and returns the name of the parameter. 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).


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},

  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();


  // 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;
<< GetType Scilab Gateway API Lhs >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Wed Jan 26 16:23:48 CET 2011