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

  1. /*
  2.  * File......: HEADER.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_HEADER()
  26.  *  $CATEGORY$
  27.  *      File I/O
  28.  *  $ONELINER$
  29.  *      Get the header size of a DBF file.
  30.  *  $SYNTAX$
  31.  *      GT_Header(<cFileName>) --> nHeaderSize
  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.  *      The size of the header in the DBF file.
  37.  *  $DESCRIPTION$
  38.  *      GT_Header() is designed to be the same as the Clipper function
  39.  *      Header(). The main change is that it works on un-opened database
  40.  *      files.
  41.  *  $EXAMPLES$
  42.  *      // Print the header size of an un-opened database file.
  43.  *
  44.  *      ? GT_Header("Life")
  45.  *  $END$
  46.  */
  47.  
  48. function GT_Header(cFileName)
  49. local nFile       := 0   ,;
  50.       cHeaderSize := "  ",;
  51.       nHeaderSize := 0
  52. if valtype(cFileName) == TYPE_CHAR
  53.    if GT_IsDbf(cFileName)
  54.       cFileName := GT_DefExt(cFileName,"Dbf")
  55.       if (nFile := fopen(cFileName,FO_READ)) != F_ERROR
  56.          fseek(nFile,8,FS_SET)
  57.          if fread(nFile,@cHeaderSize,2) == 2
  58.             nHeaderSize := bin2w(cHeaderSize)
  59.          endif
  60.          fclose(nFile)
  61.       endif
  62.    endif
  63. endif
  64. return(nHeaderSize)
  65.