File input/output is part of Short Circuit's Console Program Basics selection.
Task

Create a file called   "output.txt",   and place in it the contents of the file   "input.txt",   via an intermediate variable.

In other words, your program will demonstrate:

   how to read from a file into a variable
   how to write a variable's contents into a file


Oneliners that skip the intermediate variable are of secondary interest — operating systems have copy commands for that.




Section Header
 
+ name := FILE_IO;
 
Section Public
 
- main <- (
  + e : ENTRY;
  + f : STD_FILE;
  + s : STRING;
 
  e := FILE_SYSTEM.get "input.txt";
  (e != NULL).if {
    f ?= e.open_read_only;
    (f != NULL).if {
      s := STRING.create(f.size);
      f.read s size (f.size);
      f.close;
    };
  };
 
  (s != NULL).if {
    e := FILE_SYSTEM.make_file "output.txt";
    (e != NULL).if {
      f ?= e.open;
      (f != NULL).if {
        f.write s from (s.lower) size (s.count);
        f.close;
      };
    };
  };
);