[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
looping over file objects
From: |
Martijn Brouwer |
Subject: |
looping over file objects |
Date: |
Thu, 13 Nov 2003 14:43:34 +0100 |
Hi,
I would like to print data to both stdout and a file. The way I thought to do
this was:
1) file=fopen()
2) files=[stdout,file]
and subsequently:
for f=files
fprintf(f,....)
end
But it seems that file objects cannot be inserted in an array. This was no
problem when file objects were just integers. How can I do what I want in an
elegant way?
I do it now in this way, but it is an ugly hack:
files_to_process=1; %for stdout
file=fopen(...);
files_open=fopen("all");
filenum=files_open(length(file_open));
files_to_process=[files_to_process,filenum];
for f=files_to_process
...
end
-------------------------------------------------------------
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
-------------------------------------------------------------
- looping over file objects,
Martijn Brouwer <=