[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: saving Octave state?
From: |
Mike Miller |
Subject: |
Re: saving Octave state? |
Date: |
Thu, 2 Dec 2010 14:04:47 -0600 (CST) |
User-agent: |
Alpine 2.00 (DEB 1167 2008-08-23) |
On Tue, 30 Nov 2010, John W. Eaton wrote:
On 30-Nov-2010, Mike Miller wrote:
| I decided to mimic the R filenames and call the data and history files
| .OData and .Ohistory (instead of .RData and .Rhistory). This is in my
| ~/.octaverc file:
|
|
| history_file (".Ohistory");
| if ( exist(".OData", "file") == 2 )
| load(".OData") ;
| endif
|
|
| So it automatically loads history and data, if they are present. I'm not
| sure if any aspect of the state of the previous instance of Octave would
| be missed when I launch Octave in the same directory if I had done this
| just before quitting the previous time:
|
| save .OData
|
| What do you think?
Use a function to do this with atexit if you want to ensure that this
happens every time Octave quits.
Thanks for the tip. I can see how that would work beautifully for me, but
it seems a little trickier than I expected. I added this to my
~/.octaverc, but it doesn't do what I want:
function save_odata ()
save("-binary", ".OData")
endfunction
atexit ("save_odata");
The one problem is that the save command seems to decide what it will be
saving at the time when I start Octave, so I seem to end up with nothing
but __nargin__ and __nargout__. No arrays that I create during the Octave
session are stored if run this at any point in the session...
save_odata
...but they are stored if I do this:
save("-binary", ".OData")
If I write the function like this...
function save_odata (v)
save("-binary", ".OData", "v")
endfunction
...I can store an individual variable (called "z") like this...
store_odata(z)
...but I can't figure out how to store all variables.
The only thing I can think of that you are not saving is the internal
state managed by functions like more, octave_core_file_name,
output_precision, etc. If you have changed any of these from their
defaults, that info will not be saved and restored automatically.
Is there any way to save/restore that information, even if not
automatically?
Mike
- Re: saving Octave state?,
Mike Miller <=