From bug-request at octave dot org Fri Dec 17 07:56:11 2004 Subject: bug in Global directive From: "John W. Eaton" To: Peter JENSEN Cc: bug at octave dot org Date: Fri, 17 Dec 2004 08:58:00 -0500 On 17-Dec-2004, Peter JENSEN wrote: | ## The global directive is described on | ## page 60 in JWE's book. From the example | ## it looks like the global directive can | ## take several arguments. The parser accepts | ## this however the second variable is not | ## accepted as global | | ## I am running 2.1.58 on RH linux. | | ## I see the following error message | | ## octave:1> bug | ## x = 1 | ## y = 2 | ## error: `y' undefined near line 22 column 12 | ## error: called from `print_xy_fail' | ## error: near line 38 of file `/home/ukpj/octave/saic/sim_levels/bug.m' | | 1 ; | | function print_xy_fail() | global x,y ; | x | y | endfunction | | function print_xy_ok() | global x ; | global y ; | x | y | endfunction | | global x = 1 ; | global y = 2 ; | | print_xy_ok() ; | print_xy_fail() ; This is not a bug in Octave. You must be looking at some old documentation that does not correspond to the current behavior of the code. In global a, b the comma is now a command separator. In earlier versions of Octave, the behavior was different and the comma was parsed as a separator for the elements of the list of global variables. This change was made for compatibility with Matlab. I think the current documentation describes the current behavior. jwe ------------------------------------------------------------- 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 -------------------------------------------------------------