Skip to content

Optional Arguments

Note: This draft page is under construction 🚧

Any IronCalc function may accept zero, one or more arguments, which are values passed to the function when it is called from a spreadsheet formula.

Many function arguments are required. For such arguments, always pass a suitable value in the function call.

Some function arguments are optional. Optional arguments need not be passed in the function call and, in such cases, the function instead uses a predefined default value.

Consider a notional function called FN_NAME, with the following syntax:

FN_NAME(arg1, arg2, arg3, arg4=def1, arg5=def2, arg6=def3) => fn_name

Notes about this syntax:

  • FN_NAME is a function that takes six arguments (arg1, arg2, arg3, arg4, arg5 and arg6) and returns a value referred to as fn_name.
  • For convenience in this case, all arguments and the returned value are colour-coded to indicate that they are numbers.
  • Arguments arg1, arg2 and arg3 are required arguments and this would normally be stated in the Argument descriptions section of the function's description page.
  • Arguments arg4, arg5 and arg6 are optional arguments and again this would normally be stated in the Argument descriptions section of the function's description page. In addition, optional arguments are usually indicated by the specification of a default value in the syntax.
    • If arg4 is omitted, then the value def1 is assumed.
    • If arg5 is omitted, then the value def2 is assumed.
    • If arg6 is omitted, then the value def3 is assumed.

With this syntax, the following would all be valid calls to the FN_NAME function:

=FN_NAME(1,2,3). All optional arguments omitted.

=FN_NAME(1,2,3,4). arg4 set to 4; optional arguments arg5 and arg6 assume default values.

=FN_NAME(1,2,3,,5). arg5 set to 5; optional arguments arg4 and arg6 assume default values.

=FN_NAME(1,2,3,,,6). arg6 set to 6; optional arguments arg4 and arg5 assume default values.

=FN_NAME(1,2,3,4,5). arg4 and arg5 set to 4 and 5 respectively; optional argument arg6 assumes default value.

=FN_NAME(1,2,3,4,,6). arg4 and arg6 set to 4 and 6 respectively; optional argument arg5 assumes default value.

=FN_NAME(1,2,3,,5,6). arg5 and arg6 set to 5 and 6 respectively; optional argument arg4 assumes default value.

=FN_NAME(1,2,3,4,5,6). Values passed for all optional arguments.