CoCoA:OpenOFile
From ApCoCoAWiki
OpenOFile
open output file
Description
This function opens the file with name S---creating it if it
does not already exist---for output. If used with second argument
w or W then it immediately erases the file S. The function <ttref>Print On</ttref> is then used for appending output to S.
Example
D := OpenOFile(<quotes>my-test</quotes>); -- open <quotes>my-test</quotes> for output from CoCoA Print <quotes>hello world</quotes> On D; -- print string into <quotes>mytest</quotes> Print <quotes> test</quotes> On D; -- append to the file <quotes>mytest</quotes> Close(D); -- close the file D := OpenOFile(<quotes>my-test</quotes>,<quotes>w</quotes>); -- clear <quotes>my-test</quotes> Print <quotes>goodbye</quotes> On D; -- <quotes>mytest</quotes> now consists only of the string <quotes>goodbye</quotes> Close(D);
Syntax
OpenOFile(S:STRING):DEVICE OpenOFile(S:STRING,<quotes>w</quotes> or <quotes>W</quotes>):DEVICE
<type>io</type> <type>printing</type>