esercizi di chimica con turbo pascal 1.1 su mac

Program titola3;
(* grafico per simulazione TITOLAZIONE INTERATTIVO *)
   USES Memtypes,QuickDraw,OSIntf,ToolIntf;
   
   VAR
      gPort:   GrafPort;           
      gra1,gra2,gomma,cancella:rect;
      a,x,y,b,valore,x1,y1,tempo,esatte,errate:integer;
      nx:real;
      frase1,frase2:string;
      
procedure pausa; (* attesa che si prema enter *)
begin
moveto(10,10);drawstring('premi enter ');readln;
end;
  
  procedure grafica;  (* attivazione comandi grafici *)
BEGIN
   InitGraf(@thePort);      
   initfonts;
   InitCursor;
   HideCursor;
   OpenPort(@gPort); 
   textfont(9);
   textface([outline]);  
   PenPat(white);
   BackPat(Black);
   EraseRect(gPort.portRect);
   FrameRect(gPort.portRect);
end;
procedure testo(x,y:integer;frase:string);
begin 
penpat(white);
moveto(x,y);drawstring(frase);
end;
procedure cancellatesto;
begin
setrect(cancella,10,10,500,100);
penpat(black);
paintrect(cancella);
end;
procedure cancellagrafo;
begin
setrect(gomma,1,1,500,370);
penpat(black);
paintrect(gomma);
end;
procedure sosta1;
begin
for a:=1 to valore do write('');
end;
procedure sosta2(tempo:integer);
begin
for a:=1 to tempo do write('');
end;
procedure titolando;  (* bicchiere con soluzione da titolare *)
begin
moveto(100,200);
setrect(gra1,100,200,200,370);framerect(gra1);
moveto(100,200);penpat(black);lineto(200,200);penpat(white);
setrect(gra1,105,290,195,365);paintrect(gra1);
testo(220,350,'bicchiere graduato con 40 cc. = V2 noto');
testo(220,360,'di soluzione da titolare o nota N2');
testo(220,370,'e un indicatore di pH ');
sosta2(tempo);
end;
procedure buretta;
begin
moveto(140,200);lineto(140,170);lineto(120,170);lineto(120,10);
lineto(180,10);lineto(180,170);lineto(160,170);lineto(160,200); 
testo(220,20,'buretta graduata con 40 cc.');
testo(220,30,'di soluzione TITOLANTE nota o ignota N1');sosta2(tempo);
end;
procedure buretta2;
begin
setrect(gra1,125,12,178,168);paintrect(gra1);pausa;
end;
procedure base2(riga,y,y1:integer);
begin
x:=125;x1:=105;
for a:=1 to riga do
begin
moveto(x,y);penpat(black);lineto(178,y);
moveto(x1,y1);penpat(white);lineto(195,y1);
sosta1;
y:=y+1;y1:=y1+1;
end;
end;
procedure pro1;
begin
testo(20,20,'aggiungendo volume noto di sostanza titolante di normalita nota');
testo(20,40,'a volume noto di soluzione titolanda di normalita ignota');
testo(20,60,'si calcola la grandezza ignota con la formula generale ');
testo(20,80,' N1 * V1 = N2 * V2 ------->  N2 = N1 * V1 / V2  ');
testo(20,90,' V1 = N2 * V2 / N1 <------>  N1 = N2 * V2 / V1  ');
pausa;
testo(20,140,'vengono proposti alcuni esempi con richiesta di indicare');
testo(20,150,'volume titolante necessario-V1  es.2 ---> 6 ');
testo(20,160,'la normalita ignota---------N2  es.7 ---> 22');
testo(20,170,'normalita titolante---------N1  es.23---> 25 ');pausa;
end;
procedure graduaa;
begin
y:=210;
for a:=1 to 8 do
begin
moveto(95,y);lineto(205,y);
y:=y+20;
end;
end;
procedure graduab;
begin
y:=10;;
for a:=1 to 5 do
begin
moveto(115,y);lineto(185,y);
y:=y+40;
end;
end;
procedure aggiunge;
begin
testo(220,60,'aggiungere 10 cc.di titolante');
testo(220,70,'premendo ENTER ');
end;
procedure aggiunge2;
begin
testo(220,60,'aggiungere cc.di titolante');
testo(220,70,'premendo ENTER ');
testo(220,80,'fino a viraggio indicatore');
end;
procedure indicatore3(y1:integer);
begin
setrect(gra1,105,y1,195,365);penpat(gray);paintrect(gra1);
testo(220,260,'viraggio indicatore');
testo(220,270,'neutralizzazione completata');
end;
procedure analisi1(frase1:string);
begin
testo(220,120,frase1);
end;
procedure analisi2(frase2:string);
begin
testo(220,140,frase2);
end;
procedure ana7a(frase1:string);
begin
analisi1(frase1);
end;
procedure ana7b(frase2:string);
begin
analisi2(frase2);pausa;
end;
procedure attiva1(riga,y,y1:integer;frase1,frase2:string;cx:real);
begin
titolando;buretta;graduaa;graduab;aggiunge2;buretta2;
base2(riga,y,y1);
pausa;indicatore3(y1);
ana7a(frase1);
testo(230,200,'scrivi valore N2 con 3 decimali ?');
testo(230,210,'scrivi 0 se non sai ');
readln(cx);
if cx=nx then begin
testo(230,220,'esatto');esatte:=esatte+1;end
 else begin testo(230,220,'errato');errate:=errate+1;end;
ana7b(frase2);;
end;
procedure attiva2(riga,y,y1:integer;frase1,frase2:string;cx:real);
begin
titolando;buretta;graduaa;graduab;aggiunge2;buretta2;
base2(riga,y,y1);
pausa;indicatore3(y1);
ana7a(frase1);
testo(230,200,'scrivi valore V1  ?');
testo(230,210,'scrivi 0 se non sai ');
readln(nx);
if cx=nx then begin
testo(230,220,'esatto');esatte:=esatte+1;end
 else begin testo(230,220,'errato');errate:=errate+1;end;
ana7b(frase2);;
end;
procedure attiva3(riga,y,y1:integer;frase1,frase2:string;cx:real);
begin
titolando;buretta;graduaa;graduab;aggiunge2;buretta2;
base2(riga,y,y1);
pausa;indicatore3(y1);
ana7a(frase1);
testo(230,200,'scrivi valore N1  con 3 decimali o?');
testo(230,210,'scrivi 0 se non sai ');
readln(nx);
if cx=nx then begin
testo(230,220,'esatto');esatte:=esatte+1;end
 else begin testo(230,220,'errato');errate:=errate+1;end;
ana7b(frase2);;
end;
procedure pro2;
begin
frase1:='dati noti : N1 = 1 N   N2 = 0.250 V2=40cc  ';
frase2:='soluzione: V1 = N2*V2/N1 = 10 cc ';
attiva2(38,12,270,frase1,frase2,10);
end;
procedure pro3;
begin
frase1:='dati noti : N1 = 1 N   N2 = 0.5 N  V2=40cc  ';
frase2:='soluzione: V1 = N2*V2/N1 = 20 cc ';
attiva2(78,12,250,frase1,frase2,20);
end;
procedure pro4;
begin
frase1:='dati noti : N1 = 1 N   N2 = 0.75 N   V2=40cc  ';
frase2:='soluzione: V1 = N2*V2/N1 = 30 cc ';
attiva2(118,12,230,frase1,frase2,30);
end;
procedure pro5;
begin
frase1:='dati noti : N1 = 1 N  N2 = 1 N    V2=40cc  ';
frase2:='soluzione: V1 = N2*V2/N1 = 40 cc ';
attiva2(158,12,210,frase1,frase2,40);
end;
procedure pro6;
begin
frase1:='dati noti : N1 = 1 N   N2 = 0.375   V2=40cc';
frase2:='soluzione: V1 = N2*V2/N1 = 15 cc ';
attiva2(58,12,260,frase1,frase2,15);
end;
procedure pro7;
begin
frase1:='dati noti : N1 = 1 N  V1=10cc     V2=40cc  ';
frase2:='soluzione: N2 = N1*V1/V2 = 0.250 N ';
attiva1(38,12,270,frase1,frase2,0.250);
end;
procedure pro8;
begin
frase1:='dati noti : N1 = 1 N  V1=20cc    V2=40cc  ';
frase2:='soluzione: N2 = N1*V1/V2 = 0.500 N ';
attiva1(78,12,250,frase1,frase2,0.500);
end;
procedure pro9;
begin
frase1:='dati noti : N1 = 1 N  V1=30cc    V2=40cc  ';
frase2:='soluzione: N2 = N1*V1/V2 = 0.750 N ';
attiva1(118,12,230,frase1,frase2,0.750);
end;
procedure pro10;
begin
frase1:='dati noti : N1 = 1 N  V1=40cc    V2=40cc  ';
frase2:='soluzione: N2 = N1*V1/V2 = 1 N ';
attiva1(158,12,210,frase1,frase2,1);
end;
procedure pro11;
begin
frase1:='dati noti : N1 = 1 N  V1=15cc    V2=40cc';
frase2:='soluzione: N2 = N1*V1/V2 = 0.375 ';
attiva1(58,12,260,frase1,frase2,0.375);
end;
procedure pro12;
begin
frase1:='dati noti : N1 = 1 N  V1=25cc    V2=40cc';
frase2:='soluzione: N2 = N1*V1/V2 = 0.625 ';
attiva1(98,12,240,frase1,frase2,0.625);
end;
procedure pro13;
begin
frase1:='dati noti : N1 = 1 N  V1=35cc    V2=40cc';
frase2:='soluzione: N2 = N1*V1/V2 = 0.875 ';
attiva1(138,12,220,frase1,frase2,0.875);
end;
procedure pro14;
begin
frase1:='dati noti : N1 = 1 N  V1=5cc    V2=40cc';
frase2:='soluzione: N2 = N1*V1/V2 = 0.125 ';
attiva1(20,12,280,frase1,frase2,0.125);
end;
procedure pro15;
begin
frase1:='dati noti : N1 = 0.5 N  V1=10cc     V2=40cc  ';
frase2:='soluzione: N2 = N1*V1/V2 = 0.125 N ';
nx:=0.5*10/40;
attiva1(38,12,270,frase1,frase2,nx);
end;
procedure pro16;
begin
frase1:='dati noti : N1 = 0.2 N  V1=20cc    V2=40cc  ';
frase2:='soluzione: N2 = N1*V1/V2 = 0.1005 N ';
nx:=0.2*20/40;
attiva1(78,12,250,frase1,frase2,nx);
end;
procedure pro17;
begin
frase1:='dati noti : N1 = 0.1 N  V1=30cc    V2=40cc  ';
frase2:='soluzione: N2 = N1*V1/V2 = 0.075 N ';
nx:=0.1*30/40;
attiva1(118,12,230,frase1,frase2,nx);
end;
procedure pro18;
begin
frase1:='dati noti : N1 = 1 N  V1=40cc    V2=40cc  ';
frase2:='soluzione: N2 = N1*V1/V2 = 1 N ';
attiva1(158,12,210,frase1,frase2,1);
end;
procedure pro19;
begin
frase1:='dati noti : N1 = 0.6 N  V1=15cc    V2=40cc';
frase2:='soluzione: N2 = N1*V1/V2 = 0.225 ';
nx:=0.6*15/40;
attiva1(58,12,260,frase1,frase2,nx);
end;
procedure pro20;
begin
frase1:='dati noti : N1 = 0.3 N  V1=25cc    V2=40cc';
frase2:='soluzione: N2 = N1*V1/V2 = 0.187 ';
nx:=0.3*25/40;
attiva1(98,12,240,frase1,frase2,nx);
end;
procedure pro21;
begin
frase1:='dati noti : N1 = 0.5 N  V1=35cc    V2=40cc';
frase2:='soluzione: N2 = N1*V1/V2 = 0.437 ';
nx:=0.5*35/40;
attiva1(138,12,220,frase1,frase2,nx);
end;
procedure pro22;
begin
frase1:='dati noti : N1 = 2 N  V1=5cc    V2=40cc';
frase2:='soluzione: N2 = N1*V1/V2 = 0.250 ';
nx:=2*5/40;
attiva1(20,12,280,frase1,frase2,nx);
end;
procedure pro23;
begin
frase1:='dati noti : V1 = 10 cc   N2 = 0.250 V2=40cc  ';
frase2:='soluzione: N1 = N2*V2/V1 = 1 N ';
attiva3(38,12,270,frase1,frase2,1);
end;
procedure pro24;
begin
frase1:='dati noti : V1 = 20 cc   N2 = 0.5 N  V2=40cc  ';
frase2:='soluzione: N1 = N2*V2/V1 = 1 N ';
attiva3(78,12,250,frase1,frase2,1);
end;
procedure pro25;
begin
frase1:='dati noti : V1 = 30 cc   N2 = 0.75 N   V2=40cc  ';
frase2:='soluzione: N1 = N2*V2/V1 = 1 N ';
attiva3(118,12,230,frase1,frase2,1);
end;
procedure fine;  (* conferma uscita operazione *)
begin
writeln('fine operazione:confermare :premi enter');
readln;
end;
procedure scelta;  (* procedura con scelta opzioni e uscita *)
var s,sn:string;opzione:integer;
begin
clearscreen;
writeln('seleziona opzione per ');
writeln('1...descrizione esperimento di titolazione');
writeln('-------------------------------------------------------------');
writeln('2.3.4.5.6..................chiede di calcolare il volume    V1');
writeln('7   8 9  10 11 12 13 14....chiede di calcolare la normalita N2');
writeln('15 16 17 18 19 20 21 22....chiede di calcolare la normalita N2');
writeln('23.24.25...................chiede di calcolare la normalita N1');
writeln('----------------------------------------------------------');
writeln('30...fine ');
writeln('scelta =');readln(opzione);
grafica;
case opzione of
1:pro1;
2:pro2;3:pro3;4:pro4;5:pro5;6:pro6;
7:pro7;8:pro8;9:pro9;10:pro10;
11:pro11;12:pro12;13:pro13;14:pro14;
15:pro15;16:pro16;17:pro17;18:pro18;19:pro19;20:pro20;21:pro21;22:pro22;
23:pro23;24:pro24;25:pro25;
30:fine;
end;
EraseRect(gPort.portRect);
writeln('altra operazione?Esperimenti?:premi S...fine:premi N '); readln(sn);
if ((sn='S') or (sn='s')) then scelta ;
end;
begin            (* programma di lancio *)
clearscreen;
valore:=500;
tempo:=10000;
esatte:=0;errate:=0;
scelta;
cancellagrafo;
writeln(' chiama insegnante per la valutazione ');writeln;
writeln(' risposte  esatte  =   ', esatte:8, ' su domande ':20, esatte+errate:8);
writeln;
writeln(' risposte  errate  =   ', errate:8, ' su domande ':20, esatte+errate:8);
pausa;
end.