home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
Dloads
/
PROGRAMM
/
BUILDER.ZIP
/
CHCON2.BLD
< prev
next >
Wrap
Text File
|
1992-11-17
|
4KB
|
120 lines
'==================================================================
' CHCON2.BLD
'
' What it does:
' Like CHCON1.BLD but shows everything and lets user decide.
' Demonstrates the ability of a Builder program to alter the
' contents of CONFIG.SYS (doesn't actually change CONFIG.SYS;
' it copies CONFIG.SYS to a file called TEST.TMP and makes the
' changes to that file). Cruises through CONFIG.SYS and looks
' for a "FILES=" line. Displays the contents of CONFIG.SYS in a
' box as it goes. When the "FILES=" line is found, the program
' creates a second box below the first, showing the new proposed
' line (which contains "FILES=50"), and asks if the new line
' should be written out. Writes that line to the new file if
' user inputs {Y}. Creates a new TEST.TMP file, which you
' would in practice copy to CONFIG.SYS.
'
' Tested using:
' Builder 1.21
'
' By:
' Tom Campbell
'
'==================================================================
' CHCONFIG.BLD
' Reads CONFIG.SYS and copies is output to TEST.TMP.
' When it finds a line with "FILES=", it changes the line to FILES=50.
' Descriptors for the input file (CONFIG.SYS)
' and the output file (TEST.TMP)
File InFile, OutFile
' Original holds each line as it's read from the file; Upper is
' its uppercase version.
' RevisedLine is the text the line will be changed to.
String Original, RevisedLine, Upper
' DoChange is set to 1 if user decided to change file, and cleared
' to 0 if not. Its value is relevant only if CONFIG.SYS was
' found.
' FoundIt is 0 until the "FILES=" line is found. When it is,
' FoundIt is set to 1.
Integer DoChange, FoundIt
cls
' Draw the top box, which shows the original file.
Single box 5, 10, 60, 5 white on black
' Assume the line with "FILES=" isn't in the file.
Put 0 into FoundIt
Put 0 into DoChange
Put "FILES=50" into RevisedLine
' Quit if CONFIG.SYS isn't available. Set ERRORLEVEL to 1, which
' traditionally means an error has occurred, on exit.
if not exist "C:\CONFIG.SYS" exit 1
' Make CONFIG.SYS available for file operations.
Open "C:\CONFIG.SYS" for reading as InFile
' It will be copied to TEST.TMP, except for the "FILES=" line, which
' will be replaced with RevisedLine.
Open "TEST.TMP" for writing as OutFile
' This loop continues as long as there are lines in CONFIG.SYS.
While not eof InFile
' Get the next line from "CONFIG.SYS".
ReadLine Original from InFile
' Clear a line in the box.
say @ 7, 11 " "
' Display the line to be changed.
say @ 7, 11 Original;
' Copy it to the string var Upper, forcing it to uppercase.
Put UpperCase Original into Upper
' See if it's the line in question.
If Upper contains "FILES="
' Note that the line was found.
Put 1 into FoundIt
' Title over the box.
say @ 4, 11 "Line to be changed:";
' Draw the bottom box, which shows the new line.
Double box 15, 10, 60, 5 white on black
' Display box title.
say @ 14, 11 "Proposed change:"
' Display text to replace the old text.
say @ 17, 11 RevisedLine
' Ask user if it should be changed.
Say @ 22, 10 "Would you like to change it? ";
GetYN
' ERRORLEVEL is set to 1 if user types {Y}, 0 if user types {N}.
if DOSErrorLevel is 1
' User typed {Y}.
DoChange := 1
' Write the new line to the file.
WriteLine RevisedLine to OutFile
end else
' User typed {N}. Don't continue.
DoChange := 0
end
end else
' Not the right line. Copy it to "TEST.TMP" unchanged.
' This occurs every time a line that does *not* contain "FILES=" is
' read from the original CONFIG.SYS.
WriteLine Original to OutFile
End ' If
End ' While
' Return file resources to DOS.
Close InFile
Close OutFile
' Explain whether the mission was successful.pressed
if DoChange is 1
say @ 22, 10 "Successful--was able to alter CONFIG.SYS.";
end else
say @ 22, 10 "CONFIG.SYS was not changed."
end