Thanks, that's exactly the behaviour I wanted! For example, I had a global
variable for the default sample rate (44100 samples/sec.), but I wanted the
user to be able to override it if desired.

By the way, I'm using the pre-compiled binary version for Windows from
Sourceforge (v3.0.3) under Windows XP sp 2, and when I type in 'clear all',
Octave crashes with a message about an invalid memory reference or something
(the dialogue box disappears before I can copy down the message). Has anyone
else noticed this?

David.

On Wed, Jan 7, 2009 at 2:19 PM, Jonathan Kotta <jpko...@gmail.com> wrote:

> On Tue, Jan 6, 2009 at 11:12 PM, Bill Denney <wslo...@gmail.com> wrote:
> >
> > Global and persistent variables are cleared with clear all.
> >
>
> You can write an accessor function and mlock it to preserve global
> variables.
>
> function old = my_variable_accessor(new)
>    mlock();
>
>    try
>        val;
>    catch
>        persistent val;
>        val = DEFAULT;
>    end
>
>    old = val;
>
>    if nargin == 1
>        val = new;
>    end
>
> --
> Thanks,
>
> Jonathan Kotta
>
> Hofstadter's Law:
>    It always takes longer than you expect, even
>    when you take into account Hofstadter's Law.
>
------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to