home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 April B / Pcwk4b98.iso / Borland / Dbase50w / EXTERN.PAK / DBSYSDRV.PRG < prev    next >
Text File  |  1994-08-02  |  2KB  |  81 lines

  1. *******************************************************************************
  2. *  PROGRAM:      dbsysdrv.prg
  3. *
  4. *  WRITTEN BY:   Borland Samples Group.
  5. *
  6. *  DATE:         1/94
  7. *
  8. *  UPDATED:      3/94
  9. *
  10. *  VERSION:      Field Test  March 1994
  11. *
  12. *  DESCRIPTION:  Small example that uses the dbfile.dll.
  13. *                It searches system.ini for .drv drivers loaded.
  14. *
  15. *  PARAMETERS:   None
  16. *
  17. *  CALLS:        To dbfile.dll
  18. *
  19. *  USAGE:        do dbsysdrv
  20. *
  21. *******************************************************************************
  22.  
  23.  * Be quiet
  24. set talk off
  25.  
  26.  * Check that the windows\system.ini file can be found
  27. filename = "c:\windows\system.ini"
  28. if .not. file( filename )
  29.    filename = space( 145 )
  30.    EXTERN CWORD GetWindowsDirectory( CSTRING, CINT ) krnl386.exe
  31.    namelength = GetWindowsDirectory( filename, 144 )
  32.    if namelength == 0 
  33.        ? "Can't find the Windows root directory."
  34.        return
  35.    endif
  36.    filename = substr( filename, 1, namelength ) + "\system.ini"
  37.    if .not. file( filename )
  38.        ? "Can't find the windows\system.ini file."
  39.        return
  40.    endif
  41. endif
  42.  
  43.  * Initialize dbfile.dll
  44. set procedure to dbfile additive
  45. do dbfile
  46.  
  47.  * Open up and set the filter to the string wanted.
  48. f = new textfile()
  49. if .not. f.open( filename )
  50.    ? "Can't open " + filename
  51.    return
  52. endif
  53. f.fieldseparator( "." )
  54. f.filter( "drv" )
  55.  
  56.  * Find the lines with .drv at the end.
  57. do while .not. (f.eof() .or. f.error())
  58.     * Get the field count. Then get the last field.
  59.    fields = f.getrec()
  60.    str = lower( f.getfield( fields ) )
  61.     
  62.     * Is it drv? If so concatenate the rec into a line and print it.
  63.    if str = "drv" .and. "drv" = str
  64.        count = 1
  65.        line = ""
  66.        do while count <= fields
  67.            line = line + f.getfield( count )
  68.            if count < fields
  69.                line = line + "."
  70.            endif
  71.            count = count + 1
  72.        enddo
  73.        ? line
  74.    endif
  75. enddo
  76.  
  77.  * Close up.
  78. f.close()
  79. f.release()
  80.  
  81.