home *** CD-ROM | disk | FTP | other *** search
- /*
- Listing 18.2 Protect()
- Author: Joe Booth
- Excerpted from "Clipper 5: A Developer's Guide"
- Copyright (c) 1991 M&T Books
- 501 Galveston Drive
- Redwood City, CA 94063-4728
- (415) 366-3600
- */
-
-
- #include "FILEIO.CH"
-
- function protect(file_name)
- LOCAL handle,first_byte,buffer:=" "
- LOCAL fn:=trim(file_name)
- if (handle := Fopen(fn+".DBF",FO_READWRITE)) > -1
- fread(handle,@buffer,1) // Read first byte
- first_byte := asc(buffer)
- fseek(handle,0,0) // Go to top of file
- if first_byte = 131 // If memo file field
- fwrite(handle,chr(27),1) // write 27 as the first
- else // byte, otherwise write
- fwrite(handle,chr(26),1) // a 26.
- endif
- fclose(handle) // Close the file
- endif
- return NIL
-
- // end of file CHP1802.PRG
-