home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / prgmming / clipper / chektabs.prg < prev    next >
Text File  |  1993-10-14  |  3KB  |  96 lines

  1. /*
  2.  * File......: CHECKTABS.PRG
  3.  * Author....: Martin Colloby
  4.  * BBS.......: The Dark Knight Returns
  5.  * Net/Node..: 050/069
  6.  * User Name.: Martin Colloby
  7.  * Date......: 18/4/93
  8.  * Revision..: 1.0
  9.  *
  10.  * This is an original work by Martin Colloby and is placed in the public
  11.  * domain.
  12.  *
  13.  * Modification history:
  14.  * ---------------------
  15.  *
  16.  * $Log$
  17.  *
  18.  */
  19.  
  20.  
  21. /*  $DOC$
  22.  *  $FUNCNAME$
  23.  *      GT_CHECKTABLES()
  24.  *  $CATEGORY$
  25.  *      General
  26.  *  $ONELINER$
  27.  *      Check that the given tables exist
  28.  *  $SYNTAX$
  29.  *      GT_CheckTables( aTables )
  30.  *  $ARGUMENTS$
  31.  *      aTables - Array of tables and indexes
  32.  *  $RETURNS$
  33.  *      NIL
  34.  *  $DESCRIPTION$
  35.  *      Checks that each of the given tables and indexes exists in the
  36.  *      cDefaultPath\TABLES directory.
  37.  *
  38.  *      Structure of aTables is { Element 1 , Element 2 , ... }
  39.  *
  40.  *      where each element is { Table name , Index 1 , Index 2 , ... }
  41.  *  $EXAMPLES$
  42.  *
  43.  *  $SEEALSO$
  44.  *
  45.  *  $INCLUDE$
  46.  *      GT_LIB.CH
  47.  *  $END$
  48.  */
  49.  
  50. *
  51. #include "GT_lib.ch"
  52.  
  53. FUNCTION GT_CheckTables( aTables )
  54. MEMVAR cDefaultPath
  55. /*****************************************************************************
  56.  Purpose - Check that the given tables and indexes exist
  57.  Returns - None
  58.  Author  - Martin Colloby
  59.  Created - 16/4/92
  60. ******************************************************************************
  61.  Parameters - aTables - Multidimensional array of tables and indexes
  62.  Privates   - none
  63.  Locals     - nCount  - Count of tables
  64.               nCount1 - Count of indexes for table
  65.  Externals  - None
  66. ******************************************************************************
  67.  Structure of aTables is { Element 1 , Element 2 , ... }
  68.  
  69.  where each element is { Table name , Index 1 , Index 2 , ... }
  70.  
  71.  Each table and index should be identified from the directory cDefaultPath
  72. *****************************************************************************/
  73.  
  74. LOCAL nCount     := 0
  75. LOCAL nCount1    := 0
  76.  
  77. FOR nCount := 1 TO LEN( aTables )
  78.  
  79.     IF !FILE( cDefaultPath + "\Tables\" + aTables[nCount,1] + ".dbf" )
  80.         GT_Warning( { "Cannot find table " + cDefaultPath + "\Tables\" + aTables[nCount,1] + ".dbf" } )
  81.         RETURN NIL
  82.     ENDIF
  83.  
  84.     FOR nCount1 := 2 TO LEN( aTables[nCount] )
  85.         IF LEN( aTables[ nCount , nCount1 ] ) > 0
  86.             IF !FILE( cDefaultPath + "\Tables\" + aTables[nCount,nCount1] + INDEXEXT() )
  87.                 GT_Warning( { "Cannot find index " + cDefaultPath + "\Tables\" + aTables[nCount,nCount1] + INDEXEXT() } )
  88.                 RETURN NIL
  89.             ENDIF
  90.         ENDIF
  91.     NEXT nCount1
  92. NEXT nCount
  93.  
  94. RETURN NIL
  95. *
  96.