Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.3.0 - 日本語

Change language to:
English - 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 manual >> Scilab > Scilab keywords > global

global

グローバル変数を定義する

呼出し手順

global('nam1',...,'namn')
global nam1 ... namn

パラメータ

nam1,..., namn

有効な変数名

説明

もともと, 各 Scilab 関数は固有のローカルな変数を有し, 基本ワークスペースで作成された全ての変数を"読む"または   関数コールにより読むことができます. global キーワードにより,複数の関数をまたがって 変数を読み/書きすることができます. 関数の内部で変数に代入すると,この変数をglobalとして 宣言した他の関数でも利用可能となります.

global命令を初めて実行した時点で そのグローバス変数が存在しない場合, 空行列に初期化されます.

//first: calling environnment and a function share a variable
global a
a=1
deff('y=f1(x)','global a,a=x^2,y=a^2')
f1(2)
a
//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)')
initdata()
letsgo()
letsgo1()
<< for Scilab keywords hat >>

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:25:00 CET 2011