I'm running a small routine to check out the i/o capabilities of Scilab as
follows:
ns=200; for it = 1:10:ns; print('a.txt',it); end;
Ofcourse the routine is meant to print the results to a file 'a.txt' in the
working directory. While there is a file created, there is one entry where
there should be 11 and the following error message is given in Scilab
(3.1.1(0))
File a.txt already exists or directory write access denied
In the bug report below, there is a comment by Allen Cornet, but no apparent
fix (1)? Also there is another reference to this problem that suggests
having to open and close the file(2). However, I am reading for the
'Modelling and Simulation in Scilab/Scicos' by Campbell et all that the
exable is stand alone
Any suggestions appreciated ,
Merry Christmas and regards
David
(1) Bad error message
http://bugzilla.scilab.org/show_bug.cgi?id=3478
(2) Probleme loading data stored in an ASCII file
http://www.mathkb.com/Uwe/Forum.aspx/scilab/1478/Probleme-loading-data-stored-in-an-ASCII-file
I'm currently on machine that Scilab 5.x doesn't support.
I think you are assuming the print('a.txt',it) will append it
to the current file a.txt, but in fact it is creating a new file
whose contents is just "it". It seems to be protecting you from overwriting
an existing file.
Instead try
unix_g("cat a.txt") // show current contents
fd = mopen('a.txt','a'); ns= 50;
for it = 1:10:ns,
fprintf(fd,"%d\n",it);
end;
unix_g("cat a.txt") // show ending contents
which on my machines outlines (blank lines deleted)
-->unix_g("cat a.txt") // show current contents
ans =
Existing line in a.txt
-->fd = mopen('a.txt','a'); ns= 50;
-->for it = 1:10:ns,
--> fprintf(fd,"%d\n",it);
-->end;
-->unix_g("cat a.txt") // show ending contents
ans =
!Existing line in a.txt !
! !
!1 !
! !
!11 !
! !
!21 !
! !
!31 !
! !
!41 !
--
Steven Bellenot http://www.math.fsu.edu/~bellenot
Professor and Associate Chair phone: (850) 644-7405
Department of Mathematics office: 223 Love
Florida State University email: bellenot at math.fsu.edu