CoCoA:OpenIFile

From ApCoCoAWiki

OpenIFile

open input file

Description

This function opens the file with name S for input.

Input from that file can then be read with <ttref>Get</ttref>.

(Note: one would normally use <ttref>Source</ttref> to read CoCoA commands from a file.)

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>
  Close(D);
  D := OpenIFile(<quotes>my-test</quotes>);  -- open <quotes>my-test</quotes> for input to CoCoA
  Get(D,3);  -- get the first three characters (in Ascii code)
[104, 101, 108]
-------------------------------
  Ascii(It);  -- convert the ascii code into characters
hel
-------------------------------
  Close(D);

Syntax

OpenIFile(S:STRING):DEVICE

Close

Introduction to IO

OpenOFile

OpenIString

OpenOString

OpenSocket

Source

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