help-octave
[Top][All Lists]
Advanced

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

Re: global variable question


From: Geraint Paul Bevan
Subject: Re: global variable question
Date: Mon, 08 Dec 2003 15:27:53 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031105 Thunderbird/0.3

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John W. Eaton wrote these words on 12/08/03 15:17:
| On  8-Dec-2003, Christoph Dalitz <address@hidden>
wrote:
|
| | I am having trouble with the use of global variables in Octave 2.1.35.
|
| 2.1.35 is old.  Why not use hte latest recommended version, 2.1.50?
|
| |  (a) Subsequent initializations of global variables are ignored, eg.
| |
| |     global n = 10;
| |     global n = 100;  # has no effect
| |


Upgrading to 2.1.50 doesn't fix the problem with subsequent global
declarations

GNU Octave, version 2.1.50 (i386-pc-linux-gnu).

octave:1> global n = 10
octave:2> n
n = 10
octave:3> global n = 100
octave:4> n
n = 10

Christoph, you can use isglobal to fix this in your script:

if (! isglobal ( 'n' ))
        global n;
endif

n = 10;
n = 100; # etc.

- --
Geraint Bevan
http://www.mech.gla.ac.uk/~gbevan

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iEYEARECAAYFAj/UmHkACgkQcXV3N50QmNODmgCeNhlTkGfKmEEqLXbw8GUqG+lH
tcIAnjk9y9x91QD2IlRtcKFX3erMchsb
=sgx4
-----END PGP SIGNATURE-----



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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