guides:programming:programmers_reference_manual:synchronizing_the_volume_and_table_information

Synchronizing the Volume and Table Information

Code similar to the following is used in OpenInsight to ensure that volume and table information is synchronized. You should never need to use this code, but it explains why a synchronization problem could cause a table to become unavailable:

* first verify volume structures

cVols = count(Volumes(0), @fm) + (Volumes(0) # "")

for iVol = 1 to cVols

  Vol = Volumes(0)<iVol>

  cFiles = count(Volumes(3)<iVol>, @vm) + (Volumes(3)<iVol> # "")

  for iFile = 1 to cFiles

    File = Volumes(3)<iVol,iFile>

    locate File in Tables(0) using @fm setting Pos then

      * check volume reference

      if Tables(1)<Pos> # Vol then

         Volumes(3) = delete(Volumes(3), iVol, iFile, 0)

      end

     end else

  * file does not exist but is referenced by volume

  Volumes(3) = delete(Volumes(3), iVol, iFile, 0)

  end

  next iFiles

next iVol

 

cFiles = count(Tables(0), @fm) + (Tables(0) # "")

for iFile = cFiles to 1 step -1

  File = Tables(0)<iFile>

  Vol = Tables(1)<iFile>

  * check volume reference

  locate Vol in Volumes(0) using @fm setting Pos then

    locate File in Volumes(3)<Pos> using @vm setting Pos else

      * file not referenced by a volume

      for i = 0 to 5

        Tables(i) = delete(Tables(i), iFile, 0, 0)

      next i

    end

   end else

    * file references unattached volume

    for i = 0 to 5

       Tables(i) = delete(Tables(i), iFile, 0, 0)

    next i

   end

next iFile
  • guides/programming/programmers_reference_manual/synchronizing_the_volume_and_table_information.txt
  • Last modified: 2024/06/19 20:20
  • by 127.0.0.1