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

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

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

Scilab help >> Scilab > Scilab keywords > global


Define global variable

Calling Sequence

global nam1 ... namn


nam1,..., namn

valid variable names


Ordinarily, each Scilab function, has its own local variables and can "read" all variables created in the base workspace or by the calling functions. The global keyword allow to make variables read/write across functions. Any assignment to that variable, in any function, is available to all the other functions declaring it global.

If the global variable does not exist the first time you issue the global statement, it will be initialized to the empty matrix.


//first: calling environnment and a function share a variable
global a
deff('y=f1(x)','global a,a=x^2,y=a^2')
//second: three functions share variables
deff('initdata()','global A C ;A=10,C=30')
deff('letsgo()','global A C ;disp(A) ;C=70')
deff('letsgo1()','global C ;disp(C)')

See Also

  • who — listing of variables
  • isglobal — check if a variable is global
  • clearglobal — kills global variables
  • gstacksize — set/get scilab global stack size
  • resume — return or resume execution and copy some local variables
<< for Scilab keywords hat >>

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:
Wed Oct 05 12:09:24 CEST 2011