I’m trying to write a matrix like this
1111b
1010b
1100b
1000b
to a text file (actually to a .ppm or .pgm file) using the function below. No matter how many variations on the file I/O syntax shown in Q4M I try, I keep getting syntax errors. I must be doing something obviously wrong, but I can’t see it. What am I doing wrong?
wrtimg:{
r:count x;
h:hopen: `:c:/Documents and Settings/Stu/Desktop/fig.txt;
(neg h) [“P2”];
(neg h) [“#fig.txt”];
(neg h) (string r)," ",string r;
(neg h) [“255”];
x:255*raze abs x;
n:count x;
i: 0;
do [
n ;
(neg h) string x[i];
i:i+1];
hclose h}
With this function and the 4x4 matrix above I want to get
P2
#fig.txt
4 4
255
followed by 16 integer values, one per line.