PROCEDURE faltkarte;

VAR		
		pageWidth:		REAL;
		pageHeight:		REAL;
		pageFoldY:		REAL;
		objectX1,objectX2,objectX3,objectX4,objectX5,objectX6:REAL;
		objectY1,objectY2,objectY3,objectY4,objectY5,objectY6,objectY7:REAL;

		objectX10,objectX20,objectX30,objectX40,objectX50,objectX60:REAL;
		objectY10,objectY20,objectY30,objectY40,objectY50,objectY60,objectY70:REAL;

		width:		REAL;
		depth:		REAL;
		height:		REAL;
		p:				REAL;
		delta: 		REAL;
		lineXR:		REAL;
		lineXL:		REAL;
		i,anzahl: 		INTEGER;

BEGIN
		pageWidth:=210;
		pageHeight:=297;
		pageFoldY:=pageHeight/2;	

		p:=pp;
		height:=pheight;
		width:=pwidth;	
		depth:=pdepth;
		anzahl:=panzahl;	
		delta:=pdelta;

		{ BLATTRAND }		
		penPat (2);
		penFore(0,0,65535);

		moveto(-pageWidth/2, -pageHeight/2);
		lineto(pageWidth/2, -pageHeight/2);
		lineto(pageWidth/2, pageHeight/2);
		lineto(-pageWidth/2, pageHeight/2);
		lineto(-pageWidth/2, -pageHeight/2);

		
		FOR i:=0 To anzahl DO BEGIN

			{ RECHTE SEITE }
			objectY1:=(0-depth)+i*20;
			objectY2:=objectY1+10;
			objectY3:=objectY2-(height+(i*10));
			objectY4:=objectY1+20;
			objectY5:=objectY4+10;
			objectY7:=height+i*10;

			objectX1:=p+i*width;		
			objectX2:=objectX1+5;
			objectX3:=objectX2+width;
			objectX4:=objectX3-5;
			objectX5:=objectX4+((objectY7-objectY5)*delta);
			objectX6:=objectX1+((objectY7-objectY2)*delta);

			{ SCHNITTLINIEN RECHTS }
			penPat (2);
			penFore(0,0,65535);

			moveto(objectX1,objectY1);
			lineto(objectX1,objectY2);
			lineto(objectX6,objectY7);
			moveto(objectX2,objectY3);
			lineto(objectX2,objectY1);
			moveto(objectX3,objectY3);
			lineto(objectX3,objectY4);
			moveto(objectX4,objectY4);
			lineto(objectX4,objectY5);
			lineto(objectX5,objectY7);

			{ FALTLINIEN RECHTS }
			penFore(65535,0,0);
			penPat (-2);
		
			moveto(objectX2,objectY3);
			lineto(objectX3,objectY3);
			moveto(objectX1,objectY1);
			lineto(objectX2,objectY1);
			moveto(objectX1,objectY2);
			lineto(objectX3,objectY2);
			moveto(objectX4,objectY4);
			lineto(objectX3,objectY4);
			moveto(objectX6,objectY7);
			lineto(objectX5,objectY7);

			{ LINKE SEITE }
			objectY10:=(0-depth)+i*20;
			objectY20:=objectY10+10;
			objectY30:=objectY20-(height+(i*10));
			objectY40:=objectY10+20;
			objectY50:=objectY40+10;
			objectY70:=height+i*10;

			objectX10:=-p-i*width;		
			objectX20:=objectX10-5;
			objectX30:=objectX20-width;
			objectX40:=objectX30+5;
			objectX50:=objectX40-((objectY70-objectY50)*delta);
			objectX60:=objectX10-((objectY70-objectY20)*delta);

			{ SCHNITTLINIEN LINKS }
			penPat (2);
			penFore(0,0,65535);

			moveto(objectX10,objectY10);
			lineto(objectX10,objectY20);
			lineto(objectX60,objectY70);
			moveto(objectX20,objectY30);
			lineto(objectX20,objectY10);
			moveto(objectX30,objectY30);
			lineto(objectX30,objectY40);
			moveto(objectX40,objectY40);
			lineto(objectX40,objectY50);
			lineto(objectX50,objectY70);

			{ FALTLINIEN LINKS }			
			penFore(65535,0,0);
			penPat (-2);
				
			moveto(objectX20,objectY30);
			lineto(objectX30,objectY30);
			moveto(objectX10,objectY10);
			lineto(objectX20,objectY10);
			moveto(objectX10,objectY20);
			lineto(objectX30,objectY20);
			moveto(objectX40,objectY40);
			lineto(objectX30,objectY40);
			moveto(objectX60,objectY70);
			lineto(objectX50,objectY70);

			{ MITTLERER BLATTFALZ}
			IF( i=0 ) THEN BEGIN
				lineXR:=objectX1+((0-objectY2)*delta);
				lineXL:=objectX10-((0-objectY2)*delta);
				moveto(lineXL,0);
				lineto(lineXR,0);
			END;	

			IF( i=anzahl ) THEN BEGIN
				IF (objectY4>0) THEN BEGIN
					{ UNTEN }
					lineXR:=objectX3;
					lineXL:=objectX30;
					moveto(pageWidth*(-0.5),0);
					lineto(lineXL,0);
					moveto(pageWidth*(0.5),0);
					lineto(lineXR,0);
			
				END ELSE IF (objectY5<0) THEN BEGIN
					{ OBEN }
					lineXR:=objectX4+((0-objectY5)*delta);
					lineXL:=objectX40-((0-objectY50)*delta);
					
					moveto(pageWidth*(-0.5),0);
					lineto(lineXL,0);
					moveto(pageWidth*(0.5),0);
					lineto(lineXR,0);

				END ELSE BEGIN
					{ MITTE }
					lineXR:=objectX4;
					lineXL:=objectX40;
					moveto(pageWidth*(-0.5),0);
					lineto(lineXL,0);
					moveto(pageWidth*(0.5),0);
					lineto(lineXR,0);
				END;
			END;	

END;

END;
RUN(Faltkarte);