home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / CHAP18.EXE / CHP1803.PRG < prev    next >
Encoding:
Text File  |  1991-04-30  |  840 b   |  30 lines

  1. /*
  2.    Listing 18.3  Unprotect()
  3.    Author: Joe Booth
  4.    Excerpted from "Clipper 5: A Developer's Guide"
  5.    Copyright (c) 1991 M&T Books
  6.                       501 Galveston Drive
  7.                       Redwood City, CA 94063-4728
  8.                       (415) 366-3600
  9. */
  10.  
  11. #include "FILEIO.CH"
  12.  
  13. function unprotect(file_name)
  14. LOCAL handle,first_byte,buffer:=" "
  15. LOCAL fn:=trim(file_name)
  16. if (handle := Fopen(fn+".DBF",FO_READWRITE)) > -1
  17.    fread(handle,@buffer,1)         // Read first byte
  18.    first_byte := asc(buffer)
  19.    fseek(handle,0,0)               // Go to top of file
  20.    if first_byte = 27              // Is a memo file needed?
  21.       fwrite(handle,chr(131),1)
  22.    else
  23.       fwrite(handle,chr(03),1)
  24.    endif
  25.    fclose(handle)                  // Close the file
  26. endif
  27. return NIL
  28.  
  29. // end of file CHP1803.PRG
  30.