home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sunny 1,000 Collection
/
SUNNY1000.iso
/
Files
/
Dos
/
Sport
/
GOLF43.ZIP
/
G_FILE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1994-07-15
|
6KB
|
229 lines
Program g_file;
{This program is intended to read a "random" golf file, and write a text file
of the same name, with the .txt suffix, OR read the .txt file and write the
corresponding "random" file. This will allow me to use text editors on the
converted file, thus effectively edit the "random" file}
uses dos,crt;
{$I convspec}
var
game : game_type;
P1,P2 : Pathstr;
D : Dirstr;
N : Namestr;
E : Extstr;
Tfile : text;
ans : char;
Golfr_id : char;
space : char;
count : byte;
tname : string;
index : shortint;
filsiz : shortint;
courses : course_file_type;
club : course_type;
golfers : golfer_file_type;
golfer : golfer_type;
game_file : game_file_type;
hole : byte;
const
string20 : string[20] = ' ';
string32 : string[32] = ' ';
begin
clrscr;
writeln('1 - courses to courses.txt');
writeln('2 - courses.txt to courses');
writeln('3 - Golfers to Golfers.txt');
writeln('4 - Golfers.txt to Golfers');
writeln('5 - game to game.txt');
writeln('6 - game.txt to game');
writeln('0 or escape - quit');
readln(ans);
Repeat
case ans of
'0',#27,'n','N' : exit;
'1':
begin
assign (courses, 'courses');
assign (Tfile, 'courses.txt');
{$I-}
reset (courses);
If IOResult <> 0 then
begin
writeln('No Courses file exists');
exit;
end;
{$I-}
rewrite(Tfile);
filsiz := filesize(courses);
with club do
begin
repeat
read(courses,club);
write(Tfile, id:3,' ',rated_par:4:1,slope:4);
for hole := 1 to 18 do
write(Tfile,card_par[hole]:2);
writeln(Tfile,' ',name);
until eof(courses);
end;
close(Tfile);
close(courses);
end; {end 1:}
'2':
begin
assign (courses, 'courses');
assign (Tfile, 'courses.txt');
{$I-}
reset (Tfile);
If IOResult <> 0 then
begin
writeln('No Courses.txt file exists');
exit;
end;
{$I-}
rewrite(courses);
with club do
repeat
name := string32;
read(Tfile,id,rated_par,slope);
for hole := 1 to 18 do
read(Tfile,card_par[hole]);
readln(Tfile,space,name);
write(courses,club);
until eof(Tfile);
close(Tfile);
close(courses);
end; {end 2:}
'3':
begin
assign (Golfers,'Golfers');
assign (Tfile,'Golfers' + '.txt');
{$I-}
reset (Golfers);
If IOResult <> 0 then
begin
writeln('No Golfers file exists');
exit;
end;
{$I-}
rewrite(Tfile);
with Golfer do
repeat
read(Golfers,Golfer);
write(Tfile,id:3,no_of_games:5,hcp:6:2);
for count := 1 to 20 do
write(Tfile,last_20[count]:5:1);
writeln(Tfile,' ',name);
until eof(Golfers);
close (Tfile);
close (Golfers);
end; {end 3:}
'4':
begin
assign (Golfers,'Golfers');
assign (Tfile,'Golfers' + '.txt');
{$I-}
reset (Tfile);
If IOResult <> 0 then
begin
writeln('No Golfers.txt file exists');
exit;
end;
{$I-}
rewrite(Golfers);
with Golfer do
repeat
name := string20;
read(Tfile,id,no_of_games,hcp);
for count := 0 to 19 do
read(Tfile,last_20[count]);
readln(Tfile,space,name);
write(Golfers,Golfer);
until eof(Tfile);
close (Tfile);
close (Golfers);
end; {end 4:}
'5':
repeat
writeln('Golfer # ');
readln(Golfr_id);
assign(Tfile,'Golfr' + Golfr_id + '.txt');
assign(game_file,'Golfr' + Golfr_id);
{$I-}
reset(game_file);
if ioresult <> 0 then
begin
writeln('No Golfr' + Golfr_id,' game file exists.');
Golfr_id := #27;
end
else
{$I+}
begin
rewrite(TFile);
repeat
read(game_file,game);
with game do
write(Tfile,game_no:3,hcp:3,course_id:4,month:3,day:3,year:3);
for count := 1 to 18 do
write(Tfile,' ',game.score[count]:3);
writeln(Tfile);
until eof(game_file);
close(Tfile);
close(game_file);
writeln('Another Golfer''s game file?');
readln(Golfr_id);
end;
until Golfr_id in [#27,'N','n']; {5:}
'6':
repeat
writeln('Golfer # ');
readln(Golfr_id);
assign(game_file,'Golfr' + Golfr_id);
assign(Tfile,'Golfr' + Golfr_id + '.txt');
{$I-}
reset(TFile);
if ioresult <> 0 then
begin
Writeln('No Golfr' + Golfr_id +'.txt file exists');
Golfr_id := #27;
end
else
{$I+}
begin
rewrite(game_file);
with game do
repeat
read(Tfile,game_no,hcp,course_id,month,day,year);
for count := 1 to 18 do
read(Tfile,score[count]);
readln(Tfile);
write(game_file,game);
until eof(Tfile);
close(game_file);
close(Tfile);
writeln('Another Golfer''s game.txt file?');
readln(Golfr_id);
end;
until Golfr_id in [#27,'N','n']; {6:}
end; {end case}
writeln('Next conversion?');
readln(ans);
until ans in ['0','N','n',#27];
end.