

                   T P R O    N U M B E R    2

   The following is a set of procedures that we have been used in
various commercial programs. Feel free to use them for commercial
and noncomercial uses. We claim no responsibility to the outcome of
the use of these procedures. You are using them at your own risk.
Enough of the legalities. If you find these routines useful, we
would greatly appreciate any small donation.




                                Soft-Touch Computers
                                James Billmeyer
                                7716 Balboa Blvd, Unit D
                                Van Nuys, Ca  91406





(****************************************************************)
(*  The GetValidRec procedure will only get the desired record  *)
(*  if it is not deleted. If the record is deleted then the ok  *)
(*  flag is set to false. The use of the GetValidRec procedure  *)
(*  is the same as the  GetRec  procedure except  the  ok flag  *)
(*  must be tested  before using  the  information returned in  *)
(*  the buffer.                                                 *)
(*                                                              *)
(*      EXAMPLE:                                                *)
(*                                                              *)
(*        GetValidRec(Datf,Record_Number,Information);          *)
(*        if  ok  then                                          *)
(*           begin                                              *)
(*               .                                              *)
(*               .                                              *)
(*               .                                              *)
(*                                                              *)
(*  The GetValidRec procedure is useful for rebuilding indexes  *)
(*  for data files that have deleted recordes.                  *)
(*                                                              *)
(*  Add the GetValidRec procedure to the Toolbox Access.box or  *)
(*  Access3.box files.                                          *)
(*                                                              *)
(****************************************************************)





procedure GetValidRec(var DatF   : DataFile;
                      var R      : Integer;
                      var Buffer           );
var
   temp_rec,
   firstfree    :  integer;

begin
  temp_rec := r;
  firstfree  := datf.firstfree;
  ok := true;
  while  (firstfree <> -1) and ok  do
     begin
        if  r = firstfree  then
           ok := false
        else
           begin
              temp_rec := FirstFree;
              GetRec(DatF,temp_rec,TaRecBuf);
              FirstFree := TaRecBuf.I;
           end;
     end;
  if  ok  then
     begin
        Seek(DatF.F,R);
        BlockRead(DatF.F,Buffer,1);
        IOstatus := IOresult;
        TaIOcheck(DatF,R);
     end;
end;

                                        