home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
GCINI.ZIP
/
GCINI.CMD
next >
Wrap
OS/2 REXX Batch file
|
1992-11-30
|
4KB
|
101 lines
/*** gcIni.Cmd: garbage collection on an .INI file ***/
/*** Written by John S. Givler, givler@watson.ibm.com ***/
/*** Version 1.0a ***/
if arg(1) = '?' | arg(1) = '/?' | arg(1) = '-?' then
do
/* NB. [] are square brackets, denoting optional parameters */
say " Syntax: gcIni [InputFileName [OutputFileName]]"
say " "
say "The active Group/Name/Value triples in the input file will be copied"
say "to the output file. The input file is NOT modified by this program."
say " "
say "The optional InputFileName must be fully qualified, e.g. 'C:\OS2\EPM.INI'."
say "The optional OutputFileName need not be fully qualified."
say "Wildcards are NOT supported in the FileNames."
say " "
say "With no parameters, we default to doing a matched pair of copies:"
say "'Os2Sys.Ini' to 'gcOs2Sys.Ini' and 'Os2.Ini' to 'gcOs2.Ini'."
say " "
say "Note 1: This procedure will hog your CPU for a while."
say "Note 2: It is HIGHLY RECOMMENDED that the output file be on a RAM disk!"
say " (We do a vast amount of extremely inefficient file I/O.)"
exit
end
call RxFuncAdd SysLoadFuncs, RexxUtil, SysLoadFuncs
if RxFuncQuery('SysLoadFuncs') then
do
say "Error: RexxUtil's SysLoadFuncs procedure could not be loaded."
say "Perhaps RexxUtil.DLL is not on your LibPath?"
say "gcIni gives up."
exit
end
call SysLoadFuncs
if RxFuncQuery('SysIni') then
do
/*
** I have no idea how a system could have passed the previous test
** and yet fail this one!
*/
say "Error: RexxUtil's SysIni procedure could not be loaded,"
say "and gcIni cannot run without it."
exit
end
parse arg OldIni NewIni /* Note: OldIni name must not contain spaces! */
if OldIni == '' then
do
call gc "USER", 'gcOs2.Ini'
call gc "SYSTEM", 'gcOs2Sys.Ini'
exit
end
if NewIni == '' then NewIni = "gc.Ini"
call gc OldIni, NewIni
exit
gc: procedure
parse arg OldIni, NewIni
OldIni = strip(OldIni)
NewIni = strip(NewIni)
say "Reading '"OldIni"', writing '"NewIni"'."
call SysFileDelete NewIni /* zap any old copies of output file */
/* This next part is based on a 'SysIni' RexxUtil code sample in REXX.INF */
call SysIni OldIni, 'All:', 'Apps.'
if Result == 'ERROR:'
then do
say "Error: '"OldIni"' does not seem to be a valid .Ini file."
if substr(OldIni,2,1) <> ':' then
do
say " Apparently you did not give me a fully-qualified input filename."
say " (This requirement is mentioned in the help text, 'gcini /?')."
say " I will prepend the current drive & directory, and try that..."
if left(OldIni,1) == '\'
then OldIni = left(directory(),2) || OldIni /* prepend device */
else OldIni = directory() || '\' || OldIni /* prepend path */
end
call gc OldIni, NewIni
exit
end
else do i = 1 to Apps.0
call SysIni OldIni, Apps.i, 'All:', 'Keys.'
if Result == 'ERROR:'
then do
say "Error querying group '"Apps.i"';"
exit
end
else do j=1 to Keys.0
Val = SysIni(OldIni, Apps.i, Keys.j)
call SysIni NewIni, Apps.i, Keys.j, Val
if Result == "ERROR:" then
do
say 'Failure setting 'Apps.i":"Keys.j
say "Possibly your disk is full?"
exit
end
end
end
return