home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a013 / 1.ddi / SOURCE.EXE / F_ISMEMO.PRG < prev    next >
Encoding:
Text File  |  1991-01-25  |  1.3 KB  |  52 lines

  1. *****************************************************************
  2. FUNCTION ISMEMO (filename)
  3. *****************************************************************
  4.  
  5. * Description
  6.  
  7. * Copyright(c) 1991 -- James Occhiogrosso
  8.  
  9.  
  10. LOCAL buffer := ' ', handle := 0, ret_value := -1, memofile := ''
  11.  
  12. * Add DBT extension for memofile.
  13.  
  14. IF AT(".", filename) > 0
  15.     memofile = SUBSTR(filename,1,AT('.',filename) - 1) + '.DBT'
  16. ELSE
  17.     * If no extension passed, default to DBF and DBT
  18.     memofile = TRIM(filename) + ".DBT"
  19.     filename = TRIM(filename) + ".DBF"
  20. ENDIF
  21.  
  22. * Open database file as read only
  23. handle = FOPEN(filename , 0)
  24.  
  25. * If no open error, read the first byte
  26. IF FERROR() = 0 .AND. FREAD(handle, @buffer, 1) = 1
  27.  
  28.     * The first byte of a dBASE III file is 131 if memo fields 
  29.     * are defined, or 03 if no memo fields defined. If neither
  30.     * is true the file is not a dBASE III database and the
  31.     * default return value of -1 is returned.
  32.  
  33.     * Check for memo code in buffer.
  34.     IF buffer = CHR(131)
  35.         * File is dBASE III file with memo fields
  36.        ret_value = 1
  37.  
  38.     ELSEIF buffer = CHR(03)
  39.         * File is dBASE III file without memo fields
  40.        ret_value = 0
  41.  
  42.     ENDIF
  43. ENDIF
  44.  
  45. * Clean up and return
  46. FCLOSE(handle)
  47. RETURN(ret_value)
  48.  
  49.  
  50.  
  51.  
  52.