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 for output; If the file exists, its contents are cleared; if it does not exist, it is created empty. Use the command print on for appending output to S; you must also close the file after printing has finished.

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");  -- re-open "my-test" and clear it
/**/  print "goodbye" on file;       -- "mytest" now contains only the string "goodbye"
/**/  close(file);
/**/  file := OpenIFile("my-test");  -- open "my-test" for input
/**/  GetLine(file);
goodbye

See Also