[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: global variables
From: |
Mike Miller |
Subject: |
Re: global variables |
Date: |
Tue, 21 Jan 2014 11:50:54 -0500 |
On Tue, Jan 21, 2014 at 17:39:35 +0100, Michal Studniarek wrote:
>
> I think the question was if you can define a global variable then change
> its value inside function and to have a new value available outside.
>
> In example:
>
> global x=2;
>
> function x=test()
> global x;
> x=4;
> endfunction
>
> Value of global variable x will be still 2. Function operates on global var x
> locally but can not change its value globaly.
In fact your example is almost exactly out of the manual and shows
that a function can indeed modify the value of a global variable, both
inside and outside the scope of the function.
See https://www.gnu.org/software/octave/doc/interpreter/Global-Variables.html
--
mike
- global variables, Jabcok, 2014/01/21
- Re: global variables, st.michal88, 2014/01/21
- Re: global variables, louis scott, 2014/01/21
- Re: global variables, Doug Stewart, 2014/01/21
- Re: global variables, Michal Studniarek, 2014/01/21
- Re: global variables, Jose, 2014/01/21
- Re: global variables,
Mike Miller <=
- Re: global variables, Michal Studniarek, 2014/01/21
- Re: global variables, st.michal88, 2014/01/22
- Re: global variables, st.michal88, 2014/01/22
- Re: global variables, Doug Stewart, 2014/01/22
- Re: global variables, st.michal88, 2014/01/22
- Re: global variables, c., 2014/01/22