2010/6/5 Ben Abbott
<address@hidden>
On Jun 5, 2010, at 10:52 AM, Stefan Neumann wrote:
I did a quick test of the developers sources and octave-3.2.3. For each, the global attribute was preserved. Perhaps an upgrade to a newer version will resolve the problem for you?
the problem happens only when octave is restarted.
If you just save/clear all/load then it works as you describe.
It seems that some infos on variables, like "global", survive even a
clear all.
The global attribute is preserved by save(). It appears in the save-file like this:
# ------------------------------------------------- #
# Created by Octave 3.2.4, Sun Jun 06 00:41:11 2010 CEST <address@hidden>
# name: a
# type: global scalar
1
# ------------------------------------------------- #
But after restarting octave and load() it does not get restored, even though it definitely has been saved. Just to make sure I retried just now:
# ------------------------------------------------- #
octave:1> load a.dat
octave:2> who
Variables in the current scope:
ans
octave:3> a
error: `a' undefined near line 3 column 1
# ------------------------------------------------- #
See: no 'a'
I use octave 3.2.4. Upgrading to 3.3.51 might be premature.
Stefan
-----------------------------------
octave:2> clear all
octave:3> global a
octave:4> a = 1;
octave:5> b = 2;
octave:6> save test.mat
octave:7> clear all
octave:8> load test.mat
octave:9> whos
Variables in the current scope:
Attr Name Size Bytes Class
==== ==== ==== ===== =====
g a 1x1 8 double
b 1x1 8 double
Total is 2 elements using 16 bytes
-----------------------------------
Ben