home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / okconfig.zip / CFGCHECK.PRG < prev   
Text File  |  1988-05-27  |  6KB  |  189 lines

  1. *:*********************************************************************
  2. *:
  3. *:      Program: CFGCHECK.PRG
  4. *:
  5. *:       System: Function for checking and updating config.sys file.
  6. *:       Author: John F. Rogers
  7. *:       Copyright (c) 1988, RJM Software, Inc.
  8. *:
  9. *:      Purpose: This function will check the config.sys file for
  10. *:               properly set files and buffers.  It will make necessary
  11. *:               changes, if required or create a config.sys file.
  12. *:
  13. *:
  14. *:   Parameters: files_req,buffs_req
  15. *:
  16. *:      Returns: .T.        Config.sys is O.K.     (no changes required)
  17. *:               .F.        Config.sys is not O.K. (changes made)
  18. *:
  19. *:
  20. *:         Uses: TEMPONE.DBF
  21. *:             : TEMPTWO.DBF
  22. *:             : C:\CONFIG.OLD
  23. *:
  24. *: Documented: 5/16/88       20:05                   SNAP! version 2.02a
  25. *:*********************************************************************
  26. FUNCTION configok
  27.  
  28. PARAMETERS files_req,buffs_req
  29. PRIVATE m_files,m_buff,m_okay
  30.  
  31. *** initialize private variables
  32. m_okay     = .F.
  33. m_files    = 0
  34. m_buff     = 0
  35.  
  36. ***********************************************************************
  37. *: m_file < 0   - Config.sys file does not exist
  38. *: m_file = 0   - No FILES statement is found
  39. *: m_file > 0   - Number of files currently set
  40. *: m_buff < 0   - Config.sys file does not exist
  41. *: m_buff = 0   - No BUFFERS statement is found
  42. *: m_buff > 0   - Number of buffers currently set
  43. ***********************************************************************
  44.  
  45.  
  46. *** if config.sys file exists perform following
  47. IF FILE("c:\config.sys")
  48.  
  49.     CREATE tempone
  50.     *** open temporary work file and append blank
  51.     USE tempone
  52.     APPEND BLANK
  53.     REPLACE field_name WITH 'tempfield',field_type WITH 'C',field_len WITH 254
  54.  
  55.     *** create second work file from first work file
  56.     CREATE temptwo FROM tempone
  57.     ERASE tempone.dbf
  58.     USE temptwo
  59.     *** append existing config.sys data to temptwo work file
  60.     APPEND FROM c:\config.sys SDF
  61.  
  62.     *** locate record containing 'files' data
  63.     LOCATE ALL FOR AT( 'FILES=',UPPER(tempfield) ) > 0
  64.  
  65.     IF FOUND()
  66.         m_len   = LEN(TRIM(tempfield))
  67.         m_files = SUBSTR(tempfield,7,m_len)
  68.         m_files = VAL(m_files)
  69.     ELSE
  70.         *** return following value if 'files=' statement not found
  71.         m_files = 0
  72.     ENDIF
  73.  
  74. ELSE
  75.     *** return following values if a config.sys file does not exist
  76.     m_files = -1
  77.     m_buff  = -1
  78. ENDIF
  79.  
  80. *** locate record containing 'buffers' data
  81. LOCATE ALL FOR AT( 'BUFFERS=',UPPER(tempfield) ) > 0
  82.  
  83. IF FOUND()
  84.     m_len   = LEN(TRIM(tempfield))
  85.     m_buff  = SUBSTR(tempfield,9,m_len)
  86.     m_buff = VAL(m_buff)
  87. ELSE
  88.     *** return following value if 'buffers=' statement not found
  89.     m_buff = 0
  90. ENDIF
  91.  
  92.  
  93. *** check if files and buffers are correct
  94. IF m_files < files_req .OR. m_buff < buffs_req
  95.  
  96.     DO CASE
  97.  
  98.         *** CONFIG.SYS does not exist
  99.         CASE m_files < 0
  100.  
  101.             *** create a new CONFIG.SYS file
  102.             SET CONSOLE OFF
  103.             SET ALTERNATE TO C:\config.sys
  104.             SET ALTERNATE ON
  105.             ? 'files='   + LTRIM(STR(files_req))
  106.             ? 'buffers=' + LTRIM(STR(buffs_req))
  107.             SET ALTERNATE OFF
  108.             SET CONSOLE ON
  109.  
  110.         OTHERWISE
  111.  
  112.             *** Backup up existing config.sys, and modify
  113.             SET CONSOLE OFF
  114.  
  115.             *** Backup CONFIG.SYS
  116.             COPY FILE C:\config.sys TO C:\config.old
  117.  
  118.             *** open temporary workfile
  119.             USE temptwo
  120.  
  121.             *** A "files=" statement wasn't found in the existing config.sys
  122.             IF m_files = 0
  123.                 APPEND BLANK
  124.                 REPLACE tempfield WITH 'files=' + LTRIM(STR(files_req))
  125.             ENDIF
  126.  
  127.             *** A "buffers=" statement wasn't found in the existing config.sys
  128.             IF m_buff  = 0
  129.                 APPEND BLANK
  130.                 REPLACE tempfield WITH 'buffers=' + LTRIM(STR(buffs_req))
  131.             ENDIF
  132.  
  133.             *** "files=" statement found, with wrong value
  134.             IF m_files > 0 .AND. m_files < files_req
  135.                 LOCATE ALL FOR AT( 'FILES=' , UPPER(tempfield) ) > 0
  136.  
  137.                 IF FOUND()
  138.                     REPLACE tempfield WITH 'files=' + LTRIM(STR(files_req))
  139.                 ENDIF
  140.  
  141.             ENDIF
  142.  
  143.             *** "buffers=" statement found, with wrong value
  144.             IF m_buff > 0 .AND. m_buff < buffs_req
  145.                 LOCATE ALL FOR AT( 'BUFFERS=',UPPER(tempfield) ) > 0
  146.  
  147.                 IF FOUND()
  148.                     REPLACE tempfield WITH 'buffers=' + LTRIM(STR(buffs_req))
  149.                 ENDIF
  150.  
  151.             ENDIF
  152.  
  153.             *** the CONFIG.SYS file has been corrected. Copy to c:\ and re-boot
  154.             GOTO TOP
  155.             SET ALTERNATE TO C:\config.sys
  156.             SET ALTERNATE ON
  157.             DO WHILE !EOF()
  158.  
  159.                 IF LEN(TRIM(tempfield)) > 0
  160.                     ? TRIM(tempfield)
  161.                 ENDIF
  162.  
  163.                 SKIP
  164.             ENDDO
  165.  
  166.             SET ALTERNATE OFF
  167.             SET CONSOLE ON
  168.             ERASE temptwo.dbf
  169.  
  170.     ENDCASE
  171.     CLEAR
  172.     *** set up own message here...
  173.     SET COLOR TO N/W
  174.     @ 10,11 CLEAR TO 16,70
  175.     @ 10,11 TO 16,70
  176.     @ 12,13 SAY " Your configuration file (config.sys) has been modified! "
  177.     @ 13,13 SAY "To use new config.sys file your system must be re-booted,"
  178.     @ 14,13 SAY "    by pressing the CTRL-ALT-DEL keys simultaneously.    "
  179.  
  180.     m_okay = .F.
  181. ELSE
  182.     m_okay = .T.
  183. ENDIF
  184.  
  185. CLOSE ALTERNATE
  186. RETURN(m_okay)
  187.  
  188. *: EOF: CFGCHECK.PRG
  189.