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.




INCLUDE "D2:IO.ACT" ;from the Action! Tool Kit
 
PROC Dir(CHAR ARRAY filter)
  BYTE dev=[1]
  CHAR ARRAY line(255)
 
  Close(dev)
  Open(dev,filter,6)
  DO
    InputSD(dev,line)
    PrintE(line)
    IF line(0)=0 THEN
      EXIT
    FI
  OD
  Close(dev)
RETURN
 
PROC CopyFile(CHAR ARRAY src,dst)
  DEFINE BUF_LEN="1000"
  BYTE in=[1], out=[2]
  BYTE ARRAY buff(BUF_LEN)
  CARD len
 
  Close(in)
  Close(out)
  Open(in,src,4)
  Open(out,dst,8)
 
  DO
    len=Bget(in,buff,BUF_LEN)
    IF len>0 THEN
      Bput(out,buff,len)
    FI
  UNTIL len#BUF_LEN
  OD
 
  Close(in)
  Close(out)
RETURN
 
PROC Main()
  CHAR ARRAY filter="D:*.*",
    src="D:INPUT.TXT", dst="D:OUTPUT.TXT"
 
  Put(125) PutE() ;clear screen
 
  PrintF("Dir ""%S""%E",filter)
  Dir(filter)
 
  PrintF("Copy ""%S"" to ""%S""%E%E",src,dst)
  CopyFile(src,dst)
 
  PrintF("Dir ""%S""%E",filter)
  Dir(filter)
RETURN