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

  1. /*
  2.  * File......: LUPDATE.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_LUPDATE()
  26.  *  $CATEGORY$
  27.  *      File I/O
  28.  *  $ONELINER$
  29.  *      Get the date of a DBF last change.
  30.  *  $SYNTAX$
  31.  *      GT_LUpDate(<cFileName>) --> dModification
  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 date that the DBF file was last changed.
  37.  *  $DESCRIPTION$
  38.  *      GT_LUpDate() is designed to be the same as the Clipper function
  39.  *      LUpDate(). The main change is that it works on un-opened database
  40.  *      files.
  41.  *  $EXAMPLES$
  42.  *      // Print the date that a DBF file was changed.
  43.  *
  44.  *      ? GT_LUpDate("Life")
  45.  *  $END$
  46.  */
  47.  
  48. function GT_LUpdate(cFileName)
  49. local nFile   := 0    ,;
  50.       cDate   := "   ",;
  51.       dUpdate := ctod("")
  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,1,FS_SET)
  57.          if fread(nFile,@cDate,3) == 3
  58.             dUpdate := GT_SToD(alltrim(str(1900+asc(substr(cDate,1,1))))+;
  59.                                padl(asc(substr(cDate,2,1)),2,"0")+;
  60.                                padl(asc(substr(cDate,3)),2,"0"))
  61.          endif
  62.          fclose(nFile)
  63.       endif
  64.    endif
  65. endif
  66. return(dUpdate)
  67.