var TAble :ttable;

    Changed :integer;
    lastid :integer;
begin
   table := ttable.create(selfscript);
   with TMyWait.create1('Èäåò ïðîâåðêà äàííûõ',selfscript) do
   try
     table.databasename := 'dbkassa';
     table.tablename := 'tovar.db';
     table.open;
     progressbarmax := table.recordcount;
     table.indexfieldnames := 'ID';
     table.last;
     lastid := table.fieldbyname('id').asinteger;
     changed := 0;

     table.indexfieldnames := '';
     table.first;
     while not table.eof do
     begin
       if table.fieldbyname('id').asstring = ''
       then begin
         table.edit;
         inc(lastid);
         table.fieldbyname('id').asinteger := lastid;
         table.post;
         inc(changed);
         advancedtext := 'Èçìåíåíî : '+inttostr(Changed)+' ïîçèöèé';
       end;
       incprogress;
       table.next;
     end;

     createhinti('Îïåðàöèÿ çàêîí÷åíà'+#13+'Çàìåíåíî '+inttostr(Changed)+' ïîçèöèé');

   finally
     free ;
     table.free;
   end;;
end.
