From bug-octave-request at bevo dot che dot wisc dot edu Wed Nov 20 10:20:37 2002 Subject: Re: "global" bug 2.1.39? From: Paul Kienzle To: "John W. Eaton" Cc: Randy Gober , bug-octave@bevo.che.wisc.edu Date: Wed, 20 Nov 2002 11:20:35 -0500 On Wed, Nov 20, 2002 at 10:06:07AM -0600, John W. Eaton wrote: > On 20-Nov-2002, Randy Gober wrote: > > | If I enter at the command line: > | > | >>global c = 3, d, e = 5 > | > | I get the error==> > | error: `d' undefined near line 4 column 15 > | > | > | But I can enter: > | global c = 3 > | global d > | global e = 5 > | > | With no problem. > | > | The same goes when I use global inside a function. Looking at the Octave > | online help, "global c = 3, d, e = 5" is legal command (it is in fact an > | example :-) > > The docs are wrong now. For compatibility with Matlab the comma is > now a command separator. > > If you want to declare multiple global variables on one line, omit the > commas. > > If you want your code to be Matlab compatible, don't use initializers > in the global statement. Write > > global c d e > c = 3; > e = 5; > > instead. Shouldn't that be: global c d e if ~exist('c','var'), c=3; end if ~exist('e','var'), e=5; end otherwise it will overwrite the previously initialized values if there are any. Paul Kienzle pkienzle at users dot sf dot net ------------------------------------------------------------- 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 -------------------------------------------------------------