unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure Button3Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

procedure Syrena(okres :Integer =100; dlg :Byte=10);

implementation

{$R *.dfm}

procedure Syrena(okres :Integer =100; dlg :Byte=10);
var
  i :Cardinal;
  wysokosc :Cardinal;
begin
for i:=1 to okres do
  begin
  wysokosc:=100+Round(100*(1+Sin(i*2*Pi/okres)));
  Windows.Beep(wysokosc,dlg);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Syrena(25,10);
Syrena(75);
Syrena();
Syrena;
end;

{
procedure Kwadrat(var argument: Integer);
begin
argument:=argument*argument;
end;
}

function Kwadrat(argument: Integer) :Integer;
begin
Result:=argument*argument;
end;

function E :Extended;
begin
Result:=2.71828182845904523536028747135266249;
end;

procedure TForm1.Button2Click(Sender: TObject);
var n :Integer;
begin
n:=2;
//Kwadrat(n); ShowMessage('n='+IntToStr(n));
ShowMessage('n='+IntToStr(Kwadrat(n)));
end;

procedure TForm1.Button3Click(Sender: TObject);
var
  S1 :procedure; //typ procedury Syrena z Listingu 4.1
  S2 :procedure(okres :Integer =100; dlg :Byte=10);
  K :function(argument: Integer) :Integer;
begin
//przypisanie
S2:=Syrena;
K:=Kwadrat;
//uzycie
S2(100,10);
ShowMessage('n='+IntToStr(K(2)));
end;

end.
