[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Can't save structures?
From: |
jcardoso |
Subject: |
Re: Can't save structures? |
Date: |
Wed, 19 Feb 97 23:56:17 GMT |
John W. Eaton wrote:
| On 19-Feb-1997, address@hidden <address@hidden> wrote:
|
| | In octave-2.0.2 I can't save structures or structure elements. Is
| | this normal? Is there any work-around?
|
| For now, you have to do something like this, to save the elements
| individually:
...
| Fixing this is in the PROJECTS file. Any volunteers?
I'm sorry, as I don't know C++. Meanwhile, I wrote two m files that allow
one to read and save structures, as long as a member structure is not a
structure itself.
This showed a bug in 2.0.3 that did not appear in 2.0.2; it is
related, I supose, to the changes done in sighandlers.cc to block
signals.
a=system("ls")
don't block in 2.0.2 and block in 2.0.3. An assignment must be done,
system() itself don't block.
Thanks,
Joao
____________________________________________________________
function struct = load_struct(file)
# struct = load_struct(file)
#
# load a structure from a file; structure members can't be structures.
a=system(["awk '{ORS=\" \"};/name:/ {print $3}' " file]); # block in 2.0.3
eval(["load " file " " a]);
b = split(a," ");
for i=1:rows(b)-1
eval(["struct." b(i,:) "=" b(i,:) ";"]);
endfor
endfunction
____________________________________________________________
function save_struct(file, struct)
# save_struct(file, struct)
#
# save a structure to a file; structure members can't be structures.
cmd = sprintf("save %s ", file);
for [val, nam] = struct
eval(sprintf("%s=val;",nam));
cmd = sprintf("%s %s ",cmd, nam);
endfor
eval(cmd)
endfunction
____________________________________________________________
--
Joao Cardoso, INESC | e-mail: address@hidden
R. Jose Falcao 110 | tel: + 351 2 2094345
4050 Porto, Portugal | fax: + 351 2 2008487
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Can't save structures?,
jcardoso <=