PROCEDURE Lampe1;

VAR

i, j,k, u, m , counter: integer;
txt : STRING;

T, ST, H, B, MH, SB : REAL;

X1, X2, X3, X4, X5, XX1, XX2, XX3, XX4, XX5, l1x, l2x, l3x, l4x, l5x, ly1, ly2 : REAL;

x : array[0..4] of real;
Xend: array[0..4] of real;

BEGIN

k := 0;

B := 20;
H := 100;

{Grundrechteck}
rect(0,0,B,H);

{Linien auf Grundrechteck}
MH := 5;

for j := 1 to H / (2*MH) -1 do begin

k:=k+2;

	moveto (0,j*2*MH);
	lineto (B,j*2*MH);

{--------------------------------------}

counter:=0;

txt := '';

{array zufaellig fuellen}

for i:= 0 TO 4 Do BEGIN
	x[i] := random*B;
	message(x[i]);
END;

{sortieren}
for m:= 0 TO 4 Do BEGIN
	counter:= 0;
	for i:= 0 TO 4 Do BEGIN
		if(x[m] > x[i]) Then BEGIN
			counter := counter+1;
		End;
	END;
	
	Xend[counter]:= x[m];
	
END;

for i:= 0 TO 4 Do BEGIN
	txt:=Concat(txt,' : ', xend[i]);
END;
message(txt);

{----------------------------------------------------------------------------}

{ Lichtmuster zeichnen }

T:= 0.3 * 2 * MH + k*MH;
ST:=0.7 * 2 * MH + k*MH;

MoveTo(0,T);
lineto(xend[0],T);
lineto(xend[0],ST);

lineto(xend[1],ST);
lineto(xend[1],T);

lineto(xend[2],T);
lineto(xend[2],ST);

lineto(xend[3],ST);
lineto(xend[3],T);

lineto(xend[4],T);
lineto(xend[4],ST);

lineto(B,ST);
end;

{Zusatzlinie :) ---------------------------------------------}

T:= 0.3 * 2 * MH;
ST:=0.7 * 2 * MH;

MoveTo(0,T);
lineto(xend[0],T);
lineto(xend[0],ST);

lineto(xend[1],ST);
lineto(xend[1],T);

lineto(xend[2],T);
lineto(xend[2],ST);

lineto(xend[3],ST);
lineto(xend[3],T);

lineto(xend[4],T);
lineto(xend[4],ST);

lineto(B,ST);

END;

Run(Lampe1);