PROCEDURE faltkarte;
CONST 
	pageWidth=297;
	pageHeight=210;
	pageFoldX=pageWidth/2;
	pageFoldY=pageHeight/2;
VAR
	objectX1,objectX2,objectX3,objectX4,objectX5,objectX6,objectY1,objectY2,objectY3,objectY4,objectY5,objectY6:REAL;
	width,depth,height,distance:	REAL;
	Breite:integer;
	nVolumes:  INTEGER;
	AnzahlVolumen:integer;
	i:INTEGER;
	makeRandomHeight:BOOLEAN;
	Höhe:integer;

BEGIN
	
	nVolumes:=PAnzahl_Volumen;
	height:=PHöhe;
	width:=PBreite;
	makeRandomHeight:=true;

	{*breite des Zwischenraums berechnen*}	
	distance:= (pageHeight-(nVolumes)*Height)/(nVolumes);

	{*dina a4 blatt zeichnen*}
	penPat(2);
	penFore(0,0,65535);
	moveto(0,0);
	lineto(pageWidth,0);
	lineto(pageWidth,pageHeight);
	lineto(0,pageHeight);
	lineto(0,0);

	{*Faltkante Mitte*}
		penFore(65535,0,0);
		penPat(-5);
	moveto(pageFoldX,0);
	lineto(pageFoldX,pageHeight);

	objectX5:=pageFoldX-2*width;
	objectX6:=pageFoldX+2*width;
	objectY5:=pageFoldY+((nVolumes/2)*height+nVolumes/2*distance-distance/2);
	objectY6:=pageFoldY-((nVolumes/2)*height+nVolumes/2*distance-distance/2);

	{*in dieser Schleife werden die Volumes gezeichnet*}
	FOR i:=1 TO nVolumes-2 DO BEGIN

	
	{*Faltkante links*}	
	moveto(objectX5,objectY6);
		penFore(65535,0,0);
		penPat(-5);
	lineto(objectX5,objectY5);
		penPat(2);
		penFore(0,0,65535);
	lineto(objectX6,objectY5);
		penFore(65535,0,0);
		penPat(-5);
	lineto(objectX6,objectY6);
		penPat(2);
		penFore(0,0,65535);
	lineto(objectX5,objectY6);

	{*schnittkanten difinieren*}
	objectX1:=pageFoldX-width;
	objectX2:=pageFoldX+width;
	objectX3:=objectX1-2*width;
	objectX4:=objectX2+2*width;
	objectY1:=(pageHeight-(nVolumes*height+(nVolumes-1)*distance))/2+i*(height+distance);
	objectY2:=(pageHeight-(nVolumes*height+(nVolumes-1)*distance))/2+i*(height+distance)+height;
	objectY3:=(pageHeight-(nVolumes*height+(nVolumes-1)*distance))/2+i*(height+distance)+height/2-distance/2;
	objectY4:=(pageHeight-(nVolumes*height+(nVolumes-1)*distance))/2+i*(height+distance)+height/2+distance/2;

	{*schnittkanten Objekt Mitte zeichnen*}	
	moveto(objectX1,objectY1);
		penFore(65535,0,0);
		penPat(-5);
	lineto(objectX1,objectY2);
		penPat(2);
		penFore(0,0,65535);
	lineto(objectX2,objectY2);	
		penFore(65535,0,0);
		penPat(-5);
	lineto(objectX2,objectY1);
		penPat(2);
		penFore(0,0,65535);
	lineto(objectX1,objectY1);

	{*schnittkanten Objekt links zeichnen*}
	moveto(objectX1,objectY3);
		penFore(65535,0,0);
		penPat(-5);	
	lineto(objectX1,objectY4);
		penPat(2);
		penFore(0,0,65535);
	lineto(objectX3,objectY4);
		penFore(65535,0,0);
		penPat(-5);
	lineto(objectX3,objectY3);
		penPat(2);
		penFore(0,0,65535);
	lineto(objectX1,objectY3);
	
	{*schnittkanten Objekt rechts zeichnen*}
	moveto(objectX2,objectY3);
		penFore(65535,0,0);
		penPat(-5);	
	lineto(objectX2,objectY4);
		penPat(2);
		penFore(0,0,65535);
	lineto(objectX4,objectY4);
		penFore(65535,0,0);
		penPat(-5);	
	lineto(objectX4,objectY3);
		penPat(2);
		penFore(0,0,65535);
	lineto(objectX2,objectY3);
		
	END;

END;
RUN(faltkarte);