esercizi di vario tipo con turbo pascal 1.1 su mac

 

Program stile;
{ esempio uso stili diversi per testo }
{$U-}
   USES Memtypes,QuickDraw,OSIntf,ToolIntf;
   
   VAR
      gPort:   GrafPort;      
      sagoma: EventRecord;
      vertici:rect;
      stile1,stile2,stile3,stile4,stile5,stile6:style;
procedure testo;
var y:integer;
begin
y:=20;
 stile1:=[bold];stile2:=[italic];stile3:=[outline];
 stile4:=[underline];stile5:=[shadow];stile6:=[];
 textface(stile1);
 moveto(20,Y);
 drawstring('testo con caratteri speciali ');
  textface(stile2);y:=y+20;
 moveto(20,Y);
 drawstring('testo con caratteri speciali ');
textface(stile3);y:=y+20;
 moveto(20,Y);
 drawstring('testo con caratteri speciali ');
textface(stile4);y:=y+20;
 moveto(20,Y);
 drawstring('testo con caratteri speciali ');
textface(stile5);y:=y+20;
 moveto(20,Y);
 drawstring('testo con caratteri speciali ');
textface(stile6);y:=y+20;
 moveto(20,Y);
 drawstring('testo con caratteri normali ');
end;
     
      
procedure disegna;
var x,y:integer;
 begin
  setrect(vertici,50,150,200,250);
  framerect(vertici);
  end; 
BEGIN
{inizializzazione sottoprogrammi o routine}
   InitGraf(@thePort);      
   initfonts;
   InitCursor;
   HideCursor;
   OpenPort(@gPort);   
   
{inizio programma principale}   
   PenPat(black);
   BackPat(white);
   EraseRect(gPort.portRect);
   FrameRect(gPort.portRect);
   { procedura operativa modificabile..altre procedure aggiungere }
   testo;disegna;
   WHILE NOT OSEventAvail(mDownMask + keyDownMask, sagoma) DO;
END.

Program stile1;
{ esempio uso stili diversi per testo :variante di STILE}
{ varia FONT...STILE..DIMENSIONE }
{$U-}
   USES Memtypes,QuickDraw,OSIntf,ToolIntf;
   
   VAR
      gPort:   GrafPort;      
      sagoma: EventRecord;
      vertici:rect;
      stile:array[0..5] of style;
      
procedure testo;
var y,a:integer;
begin
y:=20;
 stile[0]:=[bold];stile[1]:=[italic];stile[2]:=[outline];
 stile[3]:=[underline];stile[4]:=[shadow];stile[5]:=[]; 
   for a:=0 to 5 do
    begin
     moveto(20,Y*a+20);
     textface(stile[a]);
     drawstring('testo con stile variabile');
    end; 
 end;
     
procedure testo1;
var y,a:integer;
begin
y:=20;
 stile[0]:=[bold];stile[1]:=[italic];stile[2]:=[outline];
 stile[3]:=[underline];stile[4]:=[shadow];stile[5]:=[]; 
   for a:=0 to 5 do
    begin
     moveto(250,Y*a+20);
     textfont(a);
     textface(stile[a]);
     drawstring('testo con stile e font vario');
    end; 
 end;
      
procedure testo2;
var y,a,k:integer;
begin
y:=150;k:=10;
 stile[0]:=[bold];stile[1]:=[italic];stile[2]:=[outline];
 stile[3]:=[underline];stile[4]:=[shadow];stile[5]:=[]; 
   for a:=0 to 5 do
    begin
     moveto(10,y);
     textfont(a);
     textface(stile[a]);
     textsize(10+k);
     drawstring('stile e font dimensioni varie');
     k:=k+2;Y:=y+25;
    end; 
 end;

BEGIN
{inizializzazione sottoprogrammi o routine}
   InitGraf(@thePort);      
   initfonts;
   InitCursor;
   HideCursor;
   OpenPort(@gPort);   
   
{inizio programma principale}   
   PenPat(black);
   BackPat(white);
   EraseRect(gPort.portRect);
   FrameRect(gPort.portRect);
   { procedura operativa modificabile..altre procedure aggiungere }
   testo;testo1;testo2;
   WHILE NOT OSEventAvail(mDownMask + keyDownMask, sagoma) DO;
END.

Program stile2;
{ esempio uso stili diversi per testo :variante di STILE1}
{ varia FONT...STILE..DIMENSIONE }
{$U-}
   USES Memtypes,QuickDraw,OSIntf,ToolIntf;
   
   VAR
      gPort:   GrafPort;      
      sagoma: EventRecord;
      vertici:rect;
      stile:array[0..5] of style;
      
procedure testo;
var y,a:integer;
begin
y:=20;
   for a:=0 to 5 do
    begin
     moveto(20,Y*a+20);
     textface(stile[a]);
     drawstring('testo con stile variabile');
    end; 
 end;
     
procedure testo1;
var y,a:integer;
begin
y:=20;
   for a:=0 to 5 do
    begin
     moveto(250,Y*a+20);
     textfont(a);
     textface(stile[a]);
     drawstring('testo con stile e font vario');
    end; 
 end;
      
procedure testo2;
var y,a,k:integer;
begin
y:=150;k:=10;
   for a:=0 to 5 do
    begin
     moveto(10,y);
     textfont(a);
     textface(stile[a]);
     textsize(10+k);
     drawstring('stile e font dimensioni varie');
     k:=k+2;Y:=y+25;
    end; 
 end;

BEGIN
{inizializzazione sottoprogrammi o routine}
   InitGraf(@thePort);      
   initfonts;
   InitCursor;
   HideCursor;
   OpenPort(@gPort);   
   
{inizio programma principale}   
   PenPat(black);
   BackPat(white);
   EraseRect(gPort.portRect);
   FrameRect(gPort.portRect);
   { procedura operativa modificabile..altre procedure aggiungere }
    stile[0]:=[bold];stile[1]:=[italic];stile[2]:=[outline];
   stile[3]:=[underline];stile[4]:=[shadow];stile[5]:=[]; 
   testo;testo1;testo2;
   WHILE NOT OSEventAvail(mDownMask + keyDownMask, sagoma) DO;
END.

program varia1;
{ tipi di variabili }
uses memtypes,fixmath;
const costante=3.14;
var 
       reale:real;
       doppio:double;
       intero:integer;
       fisso:fixed;
       lungo:longint;
       massimo:integer;
       stringa:string;
       lettera:char;
       
       
begin
 writeln(costante);
 intero:=100;
 writeln(intero);
 reale:=123.45;
 writeln(reale);
 fisso:=123456789;
 writeln(fisso);
 doppio:=12345678;
 writeln(doppio);
 lungo:=123456789;
 writeln(lungo);
 massimo:=maxint;
 writeln(massimo);
 writeln('--------');
 stringa:=('testo stringa');
 writeln(stringa);
 lettera:='A';
 writeln(lettera);
 readln;
 end.