program trasferimento;
uses
crt;
type
mm=file of char;//dichiarazione tipo file
var
si,no:mm; {Dichiarazioni variabile globali}
x:char;
f_si,f_no:string;
i1:integer;
i:real;
procedure stringa(var ss:string);
var
i,n:integer;
x:boolean;
begin
repeat
x:=false;
readln(ss);
n:=length(ss);
if(n>1)then
begin
for i:=1 to n-1 do
begin
if(ss[i]='.') and ((ss[i+1]>=#65) and (ss[i+1]<=#90) or (ss[i+1]>=#97) and (ss[i+1]<=#122))then
begin
x:=true;
break;
end
else
if(ss[i]='.') and ((ss[i+1]<#65) and (ss[i+1]>#90) or (ss[i+1]<#97) and (ss[i+1]>#122))then
writeln('Scrivere il nome del file compreso l''estenzione es. prova.pas')
else
if(ss[i]<>'.') and (i=n-1)then
writeln('Scrivere il nome del file compreso l''estenzione es. prova.pas')
end;
end
else if(n<=1)then
writeln('Nome non valido')
else
writeln('Scrivere il nome del file compreso l''estenzione es. prova.pas');
until
(x=true);
end;
begin{main}
writeln('Inserire il file(esistente) da mostare nella directoty corrente');
stringa(f_si);
writeln('Premere INVIO per continuare');
readln;
clrscr;
writeln('Inserire il nome del file(esistente/non esistente) dove saranno copiati i char');
stringa(f_no);
writeln('Premere INVIO per continuare');
readln;
clrscr;
repeat
writeln('Inserire il ritardo per mostrare ogni carattere(in milli secondi >=0 && <=2000)');
readln(i1);
if(i1<0) or (i1>2000)then
writeln('Tempo non valido');
until
(i1>=0) and (i1<=2000);
clrscr;
assign(no,f_no);
assign(si,f_si);
rewrite(no);
reset(si);
seek(si,0);
i:=0;
while not eof(si) do
begin
read(si,x);//legge un carattere dal file f_si
write(no,x);//scrive un carattere nel file f_no
i:=i+1; //conta i byte del file s1
write(x);//mostra all'utente il carattere letto dal file s1
delay(i1); //ritardo
end;
i:=i/1000;
writeln;
writeln(i:4:2,'KByte nel file ',f_no);
readln;
close(si);
close(no);
end.