home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format 126
/
af126a.adf
/
Football.lzx
/
football
/
exec
/
UpdateSettings.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-05-22
|
5KB
|
221 lines
/* ***********************************************************************
UPDATE SETTINGS PROGRAM FOR FOOTBALL REXX SUITE
------------------------------------------------
Copyright Mark Naughton 1999
Version Date History
--------------------------------------------------------------------------
1.0 250499 Created as a partner to Football to update the
settings and league name in all files.
**************************************************************************
Procedure
---------
1. Check files exist. Get league name from '.df' file.
2. Read '.sf' file into an array. Search array for indicator for league
name. When found, check to see if the names are different - if no, then
don't update, else write the new name into the array. When finished and
updates have been made, write the new data into the old file.
3. Repeat step 2 for '.sflearn' file.
4. Repeat step 2 for '.stats' file.
5. Exit.
************************************************************************** */
PARSE ARG league_file
version = 1
league_file = "Data/"strip(league_file)
input_file = '.df'
input2_file = '.sf'
input3_file = '.sflearn'
input4_file = '.stats'
title = '*LEAGUE_NAME='
sdlines. = '???'
separator = '*'
if exists(league_file || input_file) = 0 then exit
if exists(league_file || input2_file) = 0 then exit
if exists(league_file || input3_file) = 0 then exit
if exists(league_file || input4_file) = 0 then exit
if open(datafile,league_file || input_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
line = strip(line)
if pos(separator,line) > 0 then do
if pos(title,line) > 0 then do
parse var line "*LEAGUE_NAME=" league_title
league_title = strip(league_title)
end
end
end
close(datafile)
end
else do
say
say "ERROR : (UpdateSettings)"
say
say "Cannot open '"league_file || input_file"' for reading."
exit
end
sdcount = 0
if open(datafile,league_file||input2_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
line = strip(line)
sdcount = sdcount + 1
sdlines.sdcount = line
end
close(datafile)
end
else do
say
say "ERROR : (UpdateSettings)"
say
say "Cannot open '"league_file||input2_file"' for reading."
exit
end
mkt = 0
do i=1 to sdcount
if pos("**",sdlines.i) > 0 then do
parse var sdlines.i "**" ltitle
if pos(ltitle,league_title) = 0 then do
sdlines.i = "** "league_title
mkt = 1
leave
end
else do
mkt = 0
leave
end
end
end
if mkt = 1 then do
if open(datafile3,league_file || input2_file,'w') then do
do j=1 to sdcount
writeln(datafile3,sdlines.j)
end
close(datafile3)
end
else do
say
say "ERROR : (UpdateSettings)"
say
say "Cannot open '"league_file || input2_file"' for writing."
exit
end
end
sdcount = 0
if open(datafile,league_file||input3_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
line = strip(line)
sdcount = sdcount + 1
sdlines.sdcount = line
end
close(datafile)
end
else do
say
say "ERROR : (UpdateSettings)"
say
say "Cannot open '"league_file||input3_file"' for reading."
exit
end
mkt = 0
do i=1 to sdcount
if pos("**",sdlines.i) > 0 then do
parse var sdlines.i "**" ltitle
if pos(ltitle,league_title) = 0 then do
sdlines.i = "** "league_title
mkt = 1
leave
end
else do
mkt = 0
leave
end
end
end
if mkt = 1 then do
if open(datafile3,league_file || input3_file,'w') then do
do j=1 to sdcount
writeln(datafile3,sdlines.j)
end
close(datafile3)
end
else do
say
say "ERROR : (UpdateSettings)"
say
say "Cannot open '"league_file || input3_file"' for writing."
exit
end
end
sdcount = 0
if open(datafile,league_file||input4_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
line = strip(line)
sdcount = sdcount + 1
sdlines.sdcount = line
end
close(datafile)
end
else do
say
say "ERROR : (UpdateSettings)"
say
say "Cannot open '"league_file||input4_file"' for re-reading."
exit
end
mkt = 0
do i=1 to sdcount
if pos(title,sdlines.i) > 0 then do
parse var sdlines.i "*LEAGUE_NAME=" ltitle
if pos(ltitle,league_title) = 0 then do
sdlines.i = "*LEAGUE_NAME="league_title
mkt = 1
leave
end
else do
mkt = 0
leave
end
end
end
if mkt = 1 then do
if open(datafile3,league_file || input4_file,'w') then do
do j=1 to sdcount
writeln(datafile3,sdlines.j)
end
close(datafile3)
end
else do
say
say "ERROR : (UpdateSettings)"
say
say "Cannot open '"league_file || input4_file"' for writing."
exit
end
end
exit