Dear co-Scilabers,

In the help page of the write() function @,
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";
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);

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?


users mailing list

Reply via email to