home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / PROGRAMM / BUILDER.ZIP / CHCON1.BLD < prev    next >
Text File  |  1992-11-17  |  3KB  |  83 lines

  1. '==================================================================
  2. ' CHCON1.BLD
  3. '
  4. ' What it does:
  5. '   Searches CONFIG.SYS for the line containing "FILES=" and
  6. '   replaces it with the line "FILES=50".  Doesn't let the
  7. '   user in on this decision; for a version that lets the
  8. '   user see what's going on and choose not to make the
  9. '   change, see CHCON2.BLD.
  10. '
  11. ' Tested using:
  12. '   Builder 1.21c
  13. '
  14. ' By:
  15. '   Tom Campbell
  16. '
  17. '==================================================================
  18.  
  19.  
  20. ' CHCONFIG.BLD
  21. ' Reads CONFIG.SYS and copies is output to TEST.TMP.
  22. ' When it finds a line with "FILES=", it changes the line to FILES=50.
  23.  
  24.  
  25. ' Descriptors for the input file (CONFIG.SYS)
  26. ' and the output file (TEST.TMP)
  27. File InFile, OutFile
  28.  
  29. ' Original holds each line as it's read from the file; Upper is
  30. ' its uppercase version.
  31. ' RevisedLine is the text the line will be changed to.
  32. String Original, RevisedLine, Upper
  33.  
  34. ' FoundIt is 0 until the "FILES=" line is found. When it is,
  35. ' FoundIt is set to 1.
  36. Integer FoundIt
  37.  
  38. cls
  39.  
  40. ' Assume the line with "FILES=" isn't in the file.
  41. Put 0 into FoundIt
  42. Put "FILES=50" into RevisedLine
  43.  
  44. ' Quit if CONFIG.SYS isn't available.  Set ERRORLEVEL to 1, which
  45. ' traditionally means an error has occurred, on exit.
  46. if not exist "C:\CONFIG.SYS" exit 1
  47.  
  48. ' Make CONFIG.SYS available for file operations.
  49. Open "C:\CONFIG.SYS" for reading as InFile
  50. ' It will be copied to TEST.TMP, except for the "FILES=" line, which
  51. ' will be replaced with RevisedLine.
  52. Open "TEST.TMP" for writing as OutFile
  53.  
  54. ' This loop continues as long as there are lines in CONFIG.SYS.
  55. While not eof InFile
  56.   ' Get the next line from "CONFIG.SYS".
  57.   ReadLine Original from InFile
  58.   ' Copy it to the string var Upper, forcing it to uppercase.
  59.   Put UpperCase Original into Upper
  60.   ' See if it's the line in question.
  61.   If Upper contains "FILES="
  62.     ' Note that the line was found.
  63.     Put 1 into FoundIt
  64.     ' Write the new line to the file.
  65.     WriteLine RevisedLine to OutFile
  66.   end else
  67.     ' Not the right line.  Copy it to "TEST.TMP" unchanged.
  68.     ' This occurs every time a line that does *not* contain "FILES=" is
  69.     ' read from the original CONFIG.SYS.
  70.     WriteLine Original to OutFile
  71.   End ' If
  72. End ' While
  73. ' Return file resources to DOS.
  74. Close InFile
  75. Close OutFile
  76.   ' Explain whether the mission was successful.pressed
  77.   if FoundIt is 1
  78.     say @ 22, 10 "Successful--was able to alter CONFIG.SYS.";
  79.   end else
  80.     say @ 22, 10 "CONFIG.SYS was not changed."
  81.   end
  82.  
  83.