unit modello;
interface
uses crt, dos;
function getchar:char;
procedure pausa(fr:string; linee:word);
procedure linea(s:char);
function exit_not(fr:string; p:char):boolean;
function intDomanda(f:string; l1,l2:longint):longint;
function realDomanda(f:string; l1,l2:double):double;
procedure CentraFrase(f:string; lin:word);
function CentraFrase(f:string; r:char; fine:word):string;
function tempo:double;
function numero(n:double; cifre,dec:byte):string;
function destra(fr:string; t:char; fine:word):string;
implementation
function getchar:char;
begin
if keypressed then getchar:=readkey
else getchar:=chr(0);
end;
procedure pausa(fr:string; linee:word);
var i,fine:byte;
begin
while linee>0 do
begin
writeln;
linee:=linee-1;
end;
// fine:=ord(fr[0]);
fine:=length(fr);
for i:=1 to fine do write(fr[i]);
write(' '+readkey);
end;
procedure linea(s:char);
var i:byte;
begin
writeln;
for i:=0 to 79 do write(s);
end;
function exit_not(fr:string; p:char):boolean;
var r:char;
begin
write(fr);
r:=upcase(getchar);
p:=upcase(p);
writeln(r);
if r=p then exit_not:=true else exit_not:=false;
linea('-');
end;
function intDomanda(f:string; l1,l2:longint):longint;
begin
intDomanda:=trunc(realDomanda(f, l1, l2));
end;
function realDomanda(f:string; l1,l2:double):double;
var t:double;
num:string;
errore:integer;
ch:boolean;
begin
repeat
write(f+' ');
readln(num);
val(num, t, errore);
if errore=0 then
begin
ch:=((t>=l1) and (t<=l2));
if not ch then
begin
writeln('Limiti ammessi { ',l1:8:3,' -> ',l2:8:3,' }');
end;
end
else
begin
writeln('Sono ammessi solo numeri!');
ch:=false;
end;
until ch;
realDomanda:=t;
end;
procedure CentraFrase(f:string; lin:word);
var l,x0:word;
begin
l:=length(f);
x0:=(80-l) div 2;
gotoxy(x0,lin);
writeln(f);
end;
function CentraFrase(f:string; r:char; fine:word):string;
var stop,i:word;
begin
if length(f)<fine then
begin
stop:=(fine div 2) - (length(f) div 2);
for i:=1 to stop do f:=r+f;
while length(f)<fine do f:=f+r;
end;
CentraFrase:=f;
end;
function tempo:double;
var h,m,s,cs:word;
begin
GetTime(h, m, s, cs);
tempo:=3600.0 * (h+0.0) + 60.0*m + s + 0.01*cs;
end;
function numero(n:double; cifre,dec:byte):string;
var s:string;
begin
str(n:cifre:dec, s);
numero:=s;
end;
function destra(fr:string; t:char; fine:word):string;
begin
while length(fr)<=fine do
begin
fr:=fr+t;
end;
destra:=fr;
end;
begin
end.