//->AutoSpool
// David Pilling May 1992
//
// This file should be copied into your Hearsay.Library folder
// Once installed, it will create a directory, !Hearsay.Spool
// Each terminal session will then create a spool file automatically.
// A maximum of 20 spool files will be created, after that old ones will
// be automatically deleted.
// The idea is of course to give you a record of your sessions.
//


void sys_term_create(int term)
{
 int n;
 string s;
 string first;

 osclis("cdir <Hearsay$Path>.Spool");

 startscan();
 n=0;
 while(nextobject("<Hearsay$Path>.Spool","sp*",s))
 {
  if(!n) first=s;
  n++;
 }

 if(n>20) osclis("delete <Hearsay$Path>.Spool."+first);
             
 if(n)  n=stoi(s<<2)+1;
 s="00000000"+itos(n);
 n=slen(s)-8;
 s=s<<n;

 s="<Hearsay$Path>.Spool.sp"+s;

 spoolclose();

 if(term==VIEWDATA) spoolopen(s,CEPT3);
 else
 if(term==MINITEL)  spoolopen(s,CEPT2);
 else               spoolopen(s,RAWDATA);

 tprints("<sys$date> ");
 tprints("<sys$time>\r\n");
}