up previous next
OpenOFile

open output file

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

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 print on is then used for appending output to S.

Example
  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);

See Also