Verify the size of a file called     input.txt     for a file in the current working directory, and another one in the file system root.




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
 
CARD FUNC FileSize(CHAR ARRAY src,dst)
  DEFINE BUF_LEN="100"
  BYTE dev=[1]
  BYTE ARRAY buff(BUF_LEN)
  CARD len,size
 
  size=0
  Close(dev)
  Open(dev,src,4)
  DO
    len=Bget(dev,buff,BUF_LEN)
    size==+len
  UNTIL len#BUF_LEN
  OD
  Close(dev)
RETURN (size)
 
PROC Main()
  CHAR ARRAY filter="D:*.*", fname="D:INPUT.TXT"
  CARD size
 
  Put(125) PutE() ;clear screen
 
  PrintF("Dir ""%S""%E",filter)
  Dir(filter)
 
  size=FileSize(fname)
  PrintF("Size of ""%S"" is %U bytes%E",fname,size)
RETURN