Program KasPus;
{-----------------------------------------------------------------
  Deletes fields which are empty or contain only spaces in records of
  actually opened CDS/ISIS database
-----------------------------------------------------------------}
Var

 fl,f,n,
 cmfn,
 max
:real;


Function Spac(txt:string):string;
{----------------------------------------------------
-----------------------------------------------------}
begin
 while (Substr(txt,1,1)=' ') do
  txt:=Substr(txt,2,Size(txt));
 Spac:=txt;
end;


Begin
 if Dbn<>'' then
 begin
  cmfn:=1;
  max:=Maxmfn;
  fl:=0;
  Clear;
  Cursor(10,10);
  Write('Processing record:');

  while (cmfn<max) and (fl=0) do
  begin
   f:=0;
   Cursor(10,30);
   Write(Encint(cmfn,5));

   if Record(cmfn)=0 then
   begin
    n:=1;
    while (n<=Nfields) and (fl=0) do
    begin
     if Spac(Field(n))='' then
     begin
      f:=1;
      fl:=Flddel(n);
     end else
      n:=n+1
    end;

    if (f=1) and (fl=0) then
     Update;
   end;

   cmfn:=cmfn+1
  end;

  Cursor(20,10);
  if fl=0 then
   Write(Chr(7)|Chr(7)|'*** THE END ***')
  else
   Write(Chr(7)|Chr(7)|Chr(7)|'ERROR!!! Processing interrupted ')
 end
End.

