CoCoA:OpenOFile

From ApCoCoAWiki
Revision as of 10:02, 24 October 2007 by XMLBot (talk | contribs) (pushing XML rev. 1.46, again)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

Close

Introduction to IO

OpenIFile

OpenIString

OpenOString

Source

   <type>io</type>
   <type>printing</type>