help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Global variables in function


From: Corsair
Subject: Re: Global variables in function
Date: Wed, 12 Nov 2008 14:51:05 +0800
User-agent: Mutt/1.5.18 (2008-05-17)

On Wed, Nov 12, 2008 at 06:12:56AM +0000, Carlo de Falco wrote:
>
> (...)
> It is necessary declare a variable as global within a function body
> in order to access it.  For example,
>
>     global x
>     function f ()
>       x = 1;
>     endfunction
>     f ()
>
> does _not_ set the value of the global variable `x' to 1.  In order to
> change the value of the global variable `x', you must also declare it
> to be global within the function body, like this
>
>     function f ()
>       global x;
>       x = 1;
>     endfunction
> (...)
>
>
> The explanation above was obtained by typing "doc global" at the octave 
> prompt.

Sorry, my bad.  I just read the first several line of the document and
start writing.  Got to more carefully next time...

Thank you both! :-)

-- 
There is no emotion; there is peace.
There is no ignorance; there is knowledge.
There is no passion; there is serenity.
There is no death; there is the Force.

Attachment: pgprTdBAtsO29.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]