up
previous
next
open output file
OpenOFile(S:STRING):DEVICE
OpenOFile(S:STRING,"w" or "W"):DEVICE
|
This function opens the file with name S---creating it if it
does not already exist---for output. The function
Print On
is then
used for writing output to the file. If OpenOFile is used without a
second argument or if the second argument is not
w
or
W
then
Print On
will append output to the file. Otherwise, any existing
file with the name S will be erased before the output is written.
D := OpenOFile("my-test"); -- open "my-test" for output from CoCoA
Print "hello world" On D; -- print string into "mytest"
Print " test" On D; -- append to the file "mytest"
Close(D); -- close the file
D := OpenOFile("my-test","w"); -- clear "my-test"
Print "goodbye" On D; -- "mytest" now consists only of the string "goodbye"
Close(D);
|