Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.5.2 - English

Change language to:
Français - 日本語 - Português - Русский

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function

Scilab Help >> Advanced functions > argn

argn

Returns the number of input/output arguments in a function call

Calling Sequence

[lhs [,rhs] ]=argn()
lhs=argn(1)
rhs=argn(2)

Description

This function is used inside a function definition. It gives the number of actual inputs arguments (rhs) and output arguments (lhs) passed to the function when the function is called. It is usually used in function definitions to deal with optional arguments.

Note that lhs is always greater than or equal to 1. That is to say, even if a function is called without having mentioned an output argument, lhs will be equal to 1.

Examples

function concat=myOwnFunction(name, optional)
  [lhs,rhs]=argn(0);
  disp(lhs);
  if rhs <= 1 then
       optional="my Optional value";
  end
  if rhs == 0 then
       error("Expect at least one argument");
  end
  concat=name+" "+optional;
endfunction

See Also

  • function — opens a function definition
  • varargin — variable number of arguments in an input argument list
Report an issue
<< profiling Advanced functions bytecode >>

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 Apr 01 10:14:07 CEST 2015