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


return

return or resume execution and copy some local variables

Syntax

return
[x1,..,xn] = return(a1,..,an)

Arguments

x1,..,xn

variables in calling environment

a1,..,an

local variables

Description

In a function return stops the execution of the function, [x1,..,xn]=return(a1,..,an) stops the execution of the function and put the local variables ai in calling environment under names xi.

In pause mode, it allows to return to lower level. [x1,..,xn]=return(a1,..,an) returns to lower level and put the local variables ai in calling environment under names xi.

In an execstr called by a function [x1,..,xn]=return(a1,..,an) stops the execution of the function and put the local variables ai in calling environment under names xi.

The statement resume is equivalent to return.

Note: the usage of this feature can complexify the code. Instead, the syntax function b=foo() is recommended.

Examples

function foo(a)
         a=a+1
         b=resume(a)
         c=52
endfunction

foo(42);
assert_checkequal(b,43)
// c does not exist

See also

  • abort — interrupt evaluation.
  • break — keyword to interrupt loops
  • execstr — execute Scilab code in strings
  • resume — return or resume execution and copy some local variables

History

VersionDescription
6.0.0 return is now protected: Assignments like return=1 are no longer possible.
Report an issue
<< resume Control flow select >>

Copyright (c) 2022-2024 (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:
Mon Jun 17 17:49:14 CEST 2024