[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem with exist()
From: |
Hamish Allan |
Subject: |
Re: Problem with exist() |
Date: |
Thu, 6 May 2004 21:20:44 +0100 |
Hi John,
Thank you for your reply, and thank you in a wider sense for Octave!
I should have realised what the problem was, I think I must have
previously used some language where variables in the interpreter's
namespace are available globally.
Basically I was trying to make my code keep track of dependencies for
me. The loading of the PCM data is just the first step; then I'm
creating a spectogram, doing some post-processing on that, then two
branches of further processing from that, each processed further
themselves and then combined, etc... all for various different audio
data. I'd like (during development) just to be able to alter some code,
type "clear thirdresult; go" rather than "thirdresult =
process2(secondresult); fourthresult = process3(thirdresult);
fifthresult = process4a(fourthresult); " etc.
But, doubtless there are simpler ways (I don't want to get into
eval(["global ", varname]); !!!)
Thanks again,
Hamish
Why not just use something like
function ret = auinf (name)
ret = auload (file_in_loadpath (sprintf ("%s.wav", name)));
...
endfunction
and then call it like this to get the audio_stuff in the top-level
workspace:
xyz_pcm = auinf ("xyz");
? Then just don't call it again for the same argument name unless you
want to reload the file.
| BUT, when I call it again, it loads the data again:
That's because you are evaluating the command that makes the variable
name xyz_pcm in the workspace of the caller. The variable xyz_pcm
never exists in the workspace of your auinf function.
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
-------------------------------------------------------------