program StringheDaFile;
const
DIM = 30;
type
parola = packed array [1..DIM] of char;
var
p : parola;
f1, f2 : text;
procedure LeggiStringa (var filein: text; var par: parola);
var
ch: char;
i,
j : integer;
function Lettera (c: char): boolean;
begin
Lettera := ((c >= 'a') and (c <= 'z')) or ((c >= 'A') and (c <= 'Z'));
end;
begin
i := 0;
if not eof(filein) then
repeat
read(filein, ch);
until Lettera(ch) or eof(filein);
if Lettera(ch) then
begin
i := 1;
par[i] := ch;
end;
if not eof(filein) then
repeat
read(filein, ch);
i := i + 1;
par[i] := ch;
until (not Lettera(ch)) or eof(filein);
if i = 0 then
for j := i + 1 to DIM do par[j] := ' '
else
for j := i to DIM do par[j] := ' ';
end;
function LMaiuscola (l: char): char;
begin
if (l >= 'a') and (l <= 'z') then
LMaiuscola := chr(ord(l) + ord('A') - ord('a'))
else
LMaiuscola := l
end;
procedure SMaiuscola (var s: parola);
var
ch : char;
i : integer;
begin
for i := 1 to DIM do
begin
ch := s[i];
s[i] := LMaiuscola(ch)
end
end;
procedure StampaFile (var f: text);
var
ch : char;
begin
reset(f);
writeln('--- inizio file ---');
while not eof(f) do
begin
read(f, ch);
write(ch);
end;
writeln;
writeln('--- fine file ---')
end;
begin
assign(f1, 'parole.in');
reset(f1);
writeln('apertura parole.in fatta');
assign(f2, 'parole.out');
rewrite(f2);
writeln('apertura parole.out fatta');
while not eof(f1) do
begin
LeggiStringa(f1, p);
write(p, ' --- ');
SMaiuscola(p);
writeln(p);
writeln(f2, p)
end;
close(f1);
close(f2);
writeln('stampa file di input (<RET> per continuare): ');
readln;
assign(f1, 'parole.in');
reset(f1);
StampaFile(f1);
close(f1);
writeln('stampa file di output (<RET> per continuare):');
readln;
assign(f1, 'parole.out');
reset(f1);
StampaFile(f1);
writeln('<RET> per finire');
readln
end.