[Scilab-users] Direct file access with write(fid,a,k,fm) ?
Samuel Gougeon
sgougeon at free.fr
Sat Jan 15 23:17:51 CET 2022
Dear co-Scilabers,
In the help page of the write() function @
https://help.scilab.org/docs/6.1.1/en_US/write.html,
an enigmatic sentence somewhat describes a interesting writing mode:
"
/Direct access files : x = write(file_desc, a, k, format). Here k is the
vector of records (one record//
// by row, i.e. m = prod(size(k))//
/
"/Direct access/ can be very useful, in order to write only targeted
records, instead of the whole file.
But here this description looks completely obscure to me, and there is
no related example.
I have tried many things using such a syntax with a text file, for
instance with the following example, and all of them fail:
a = rand(5,3)*100;
File = "write_test.txt";
mdelete(File);
fm = "(3(2x,f4.0))"; // 3*(2+4) = 18 bytes / row
write(File, a, fm);
fid = file("open",File,"unknown","direct",18);
k = [3 4];
b = -a(k,:);
write(fid, b, k, fm);
file('close',fid)
This yields an error:
--> write(fid, b, k, fm)
Incorrect file or format.
Would anyone have any hints about this syntax, noticeably about the /k/
and /m/ meanings?
Regards
Samuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20220115/27d30923/attachment.htm>
More information about the users
mailing list