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

  1. /*
  2.  * File......: ISDBF.PRG
  3.  * Author....: Dave Pearson
  4.  * BBS.......: The Dark Knight Returns
  5.  * Net/Node..: 050/069
  6.  * User Name.: Dave Pearson
  7.  * Date......: $Date$
  8.  * Revision..: $Revision$
  9.  * Log file..: $Logfile$
  10.  *
  11.  * This is an original work by Dave Pearson and is placed in the public
  12.  * domain.
  13.  *
  14.  * Modification history:
  15.  * ---------------------
  16.  *
  17.  * $Log$
  18.  *
  19.  */
  20.  
  21. #include "gt_lib.ch"
  22.  
  23. /*  $DOC$
  24.  *  $FUNCNAME$
  25.  *      GT_ISDBF()
  26.  *  $CATEGORY$
  27.  *      File I/O
  28.  *  $ONELINER$
  29.  *      Check that a file is a DBF file.
  30.  *  $SYNTAX$
  31.  *      GT_IsDbf(<cFileName>) --> lIsDbf
  32.  *  $ARGUMENTS$
  33.  *      <cFileName> is the name of the DBF file. If the name has no
  34.  *      extension it defaults to DBF.
  35.  *  $RETURNS$
  36.  *      .T. if the file is a DBF file, .F. if not.
  37.  *  $DESCRIPTION$
  38.  *      GT_IsDbf() is designed to check that a file is a Clipper DBF file.
  39.  *  $EXAMPLES$
  40.  *      // Check if a file is a DBF file.
  41.  *
  42.  *      ? GT_IsDbf("Life")
  43.  *  $END$
  44.  */
  45.  
  46. function GT_IsDbf(cFileName)
  47. local nFile   := 0  ,;
  48.       cIdChar := " ",;
  49.       lIsDbf  := FALSE
  50. if valtype(cFileName) == TYPE_CHAR
  51.    cFileName := GT_DefExt(cFileName,"Dbf")
  52.    if (nFile := fopen(cFileName,FO_READ)) != F_ERROR
  53.       if fread(nFile,@cIdChar,1) == 1
  54.          if asc(cIdChar) == 3 .or. asc(cIdChar) == 131
  55.             lIsDbf := TRUE
  56.          endif
  57.       endif
  58.       fclose(nFile)
  59.    endif
  60. endif
  61. return(lIsDbf)
  62.