Ver Mensaje Individual
  #1  
Antiguo 14-06-2008
Avatar de salvica
salvica salvica is offline
Miembro
 
Registrado: mar 2004
Ubicación: Albacete (España) ... En un lugar de la Mancha ...
Posts: 304
Reputación: 21
salvica Va por buen camino
Question Pregunta sobre índices en tablas DBF

Es solo una pregunta antes de estropear algo

Si en una tabla inserto un registro en blanco, pero no hago post, afectará al fichero de índices?

Ejemplo: (el objeto TDbf pertenece al Form)
Código Delphi [-]
procedure TForm1.PasarGridViewToTablas( strTabla:string );
var
  ColorCelda : TColor;
  DatosCelda : string;
  ACol, ARow : integer;
  strClave   : string;
  intUnix    : integer;
  strFecha   : string;
  Y, M, D    : word;
begin
  with Dbf do begin
       Active        := false;
       IndexName     := strTabla;
       TableName     := strTabla + '.dbf';
     { abrir la tabla activa }
       Open;
     { recorrer el GridView }
       for ARow:=0 to GridView1.RowCount-1 do begin
         { evitar el "cualgue" del sistema }
           Application.ProcessMessages;
           strClave := GridView1.Cell[0, ARow].AsString;
           intUnix  := StrToInt( GridView1.Cell[1, ARow].AsString );
           strFecha := GridView1.Cell[2, ARow].AsString;
           Y        := StrToIntDef( Copy(strFecha, 7, 4), 1970 );
           M        := StrToIntDef( Copy(strFecha, 4, 2),   12 );
           D        := StrToIntDef( Copy(strFecha, 1, 2),    1 );
         { localizar el registro por si se hubiera efectuado anteriormente }
           if not SearchKey(strClave, stEqual) then begin
            { añadimos un registro en blanco }
              Append;
            { añadimos la clave del registro y los campos comunes }
              FieldByName('ESTACION').AsString      := strClave;
              FieldByName('FECHA_UNIX').AsInteger   := 0;
           end else Edit;
         { solo modificamos campos si FECHA_UNIX es menor que la actual, saltar el post }
           if( intUnix>=FieldByName('FECHA_UNIX').AsInteger ) then Continue;
             { modificar los datos recibidos }
               ...
             { salvar los datos modificados }
               Post;
       end; { del for }
     { cerrar la tabla activa }
       Close;
  end; { del with Dbf do }
end;
con Delphi-7 y TDbf
Responder Con Cita