up previous next
OpenOFile

open output file

Syntax
OpenOFile(S: STRING): OSTREAM
OpenOFile(S: STRING,"w" or "W"): OSTREAM

Description
This function opens the file with name S ---creating it if it does not already exist---for output. It immediately erases the file with name S . Then the function print on is then used for appending output to S until it is closed.

Example
/**/  file := OpenOFile("my-test");  -- open "my-test" for output from CoCoA
/**/  print "hello world! " on file; -- print string into "my-test"
/**/  print " test" on file;         -- append to the file "my-test"
/**/  close(file);  -- close the file
/**/  file := OpenOFile("my-test");  -- clear "my-test" and re-open it
/**/  print "goodbye" on file; -- "mytest" now consists only of the string "goodbye"
/**/  close(file);

See Also