PROCEDURE folding;

VAR
	
	pageWidth:REAL;
	pageHeight:REAL;
	pageFoldY: REAL;
	
	objectX1,objectX2,objectX3:REAL;
	objectY1,objectY2,objectY3,objectY4:REAL;
	
	object2X1,object2X2,object2X3:REAL;
	object2Y1,object2Y2,object2Y3,object2Y4:REAL;

	object3X1,object3X2,object3X3:REAL;
	object3Y1,object3Y2,object3Y3,object3Y4:REAL;

	object4X1,object4X2,object4X3:REAL;
	object4Y1,object4Y2,object4Y3,object4Y4:REAL;	

	object5X1,object5X2,object5X3:REAL;
	object5Y1,object5Y2,object5Y3,object5Y4:REAL;

	object6X1,object6X2,object6X3:REAL;
	object6Y1,object6Y2,object6Y3,object6Y4:REAL;
	
	object7X1,object7X2,object7X3:REAL;
	object7Y1,object7Y2,object7Y3,object7Y4:REAL;

	object8X1,object8X2,object8X3:REAL;
	object8Y1,object8Y2,object8Y3,object8Y4:REAL;

	object9X1,object9X2,object9X3:REAL;
	object9Y1,object9Y2,object9Y3,object9Y4:REAL;	

	object10X1,object10X2,object10X3:REAL;
	object10Y1,object10Y2,object10Y3,object10Y4:REAL;

	width:	REAL;
	depth:	REAL;
	height:	REAL;

BEGIN
	
	{*Variablen berechnen*}
	pageWidth:=210;
	pageHeight:=297;
	pageFoldY:= pageHeight/2;
	
	height:=4;
	width:=40;
	depth:=8;

	{*Stift einstellen*}
	penPat(2);
	penFore(0,0,65535);
	
	{*blatt zeichnen*}
	moveto(0,0);
	lineto(pageWidth,0);
	lineto(pageWidth,pageHeight);
	lineto(0,pageHeight);
	lineto(0,0);
	
	{*Stift einstellen*}
	penFore(65535,0,0);
	penPat(-2);

	{*blatt faltkanten zeichnen*}
	moveto(0,pageFoldY);
	lineto(objectX1,pageFoldY);
	moveto(objectX2,pageFoldY);
	lineto(pageWidth,pageFoldY);

	{*object 1 Variablen berechnen*}
	objectX1:=(pageWidth - width)/2;
	objectX2:=((pageWidth - width)/2) + (width/2);
	objectX3:=objectX2 + (width/2);

	objectY1:=pageFoldY - depth;
	objectY3:=pageFoldY + height; 
	objectY2:=objectY3 - depth;
	objectY4:=objectY3 + depth;

	{*Stift einstellen*}
	penPat(2);
	penFore(0,0,65535);

	{*object 1 schnittkanten zeichnen*}
	moveto(objectX1,objectY1);
	lineto(objectX1,objectY4);
	moveto(objectX2,objectY1);
	lineto(objectX2,objectY2);
	moveto(objectX2,objectY2);
	lineto(objectX3,objectY2);
	moveto(objectX3,objectY2);
	lineto(objectX3,objectY4);

	{*Stift einstellen*}
	penFore(65535,0,0);
	penPat(-2);

	{*object 1 faltkanten zeichnen*}
	moveto(objectX1,objectY1 + depth);
	lineto(objectX2,objectY1 + depth);
	moveto(objectX1,objectY3);
	lineto(objectX3,objectY3);
	moveto(objectX1,objectY4);
	lineto(objectX3,objectY4);

	{*object 2 Variablen berechnen*}
	object2X1:=objectX2 + width + (width/4);
	object2X2:=objectX3 + (width/4);
	object2X3:=(pageWidth - width)/2;

	object2Y1:=objectY1 - (depth/2);
	object2Y3:=objectY3 + (depth/2) + (2*depth); 
	object2Y2:=objectY2 + (depth/2) + (2*depth);
	object2Y4:=object2Y3 + (depth/2) + depth;

	{*Stift einstellen*}
	penPat(2);
	penFore(0,0,65535);

	{object 2 schnittkanten zeichnen*}
	moveto(object2X1,object2Y1);
	lineto(object2X1,object2Y4);
	moveto(object2X2,object2Y1);
	lineto(object2X2,object2Y2);
	moveto(object2X2,object2Y2);
	lineto(object2X3,object2Y2);
	moveto(object2X3,object2Y2);
	lineto(object2X3,object2Y4);

	{*Stift einstellen*}
	penFore(65535,0,0);
	penPat(-2);

	{*object 2 faltkanten zeichnen*}
	moveto(object2X1,object2Y1 + depth + (2*depth/2));
	lineto(object2X2,object2Y1 + depth + (2*depth/2));
	moveto(object2X1,object2Y3);
	lineto(object2X3,object2Y3);
	moveto(object2X1,object2Y4);
	lineto(object2X3,object2Y4);

	{*object 3 Variablen berechnen*}
	object3X1:=objectX1 - (width/2) - (width/4);
	object3X2:=objectX2 - (width/2) - (width/4);
	object3X3:=object2X1;

	object3Y1:=object2Y1;
	object3Y2:=object2Y4 + (depth/2); 
	object3Y3:=object3Y2 + depth;
	object3Y4:=object3Y3 + 2*depth;

	{*Stift einstellen*}
	penPat(2);
	penFore(0,0,65535);

	{object 3 schnittkanten zeichnen*}
	moveto(object3X1,object3Y1);
	lineto(object3X1,object3Y4);
	moveto(object3X2,object3Y1);
	lineto(object3X2,object3Y2);
	moveto(object3X2,object3Y2);
	lineto(object3X3,object3Y2);
	moveto(object3X3,object3Y2);
	lineto(object3X3,object3Y4);

	{*Stift einstellen*}
	penFore(65535,0,0);
	penPat(-2);

	{*object 3 faltkanten zeichnen*}
	moveto(object3X1,object3Y1 + depth);
	lineto(object3X2,object3Y1 + depth);
	moveto(object3X1,object3Y3);
	lineto(object3X3,object3Y3);
	moveto(object3X1,object3Y4);
	lineto(object3X3,object3Y4);

	
	{*object 4 Variablen berechnen*}
	object4X1:=object2X1 + (width/2) + (width/4);
	object4X2:=object2X2 + (width/2) + (width/4);
	object4X3:=object3X1;

	object4Y1:=object3Y1 - (depth/2); 
	object4Y2:=object3Y4 + (depth/2);
	object4Y3:=object4Y2 + depth;
	object4Y4:=object4Y3 + (2*depth);

	{*Stift einstellen*}
	penPat(2);
	penFore(0,0,65535);

	{object 4 schnittkanten zeichnen*}
	moveto(object4X1,object4Y1);
	lineto(object4X1,object4Y4);
	moveto(object4X2,object4Y1);
	lineto(object4X2,object4Y2);
	moveto(object4X2,object4Y2);
	lineto(object4X3,object4Y2);
	moveto(object4X3,object4Y2);
	lineto(object4X3,object4Y4);

	{*Stift einstellen*}
	penFore(65535,0,0);
	penPat(-2);

	{*object 4 faltkanten zeichnen*}
	moveto(object4X1,object4Y1 + (2*depth) + (depth/2));
	lineto(object4X2,object4Y1 + (2*depth) + (depth/2));
	moveto(object4X1,object4Y3);
	lineto(object4X3,object4Y3);
	moveto(object4X1,object4Y4);
	lineto(object4X3,object4Y4);

	{*object 5 Variablen berechnen*}
	object5X1:=objectX1 - width - (width/2);
	object5X2:=objectX2 - width - (width/2);
	object5X3:=objectX3 + width + (width/2);

	object5Y1:=object4Y1 - (depth/2);
	object5Y2:=object4Y4 + (depth/2); 
	object5Y3:=object5Y2 + depth;
	object5Y4:=object5Y3 + (3*depth);

	{*Stift einstellen*}
	penPat(2);
	penFore(0,0,65535);

	{object 5 schnittkanten zeichnen*}
	moveto(object5X1,object5Y1);
	lineto(object5X1,object5Y4);
	moveto(object5X2,object5Y1);
	lineto(object5X2,object5Y2);
	moveto(object5X2,object5Y2);
	lineto(object5X3,object5Y2);
	moveto(object5X3,object5Y2);
	lineto(object5X3,object5Y4);

	{*Stift einstellen*}
	penFore(65535,0,0);
	penPat(-2);

	{*object 5 faltkanten zeichnen*}
	moveto(object5X1,object5Y1 + depth + (depth/2));
	lineto(object5X2,object5Y1 + depth + (depth/2));
	moveto(object5X1,object5Y3);
	lineto(object5X3,object5Y3);
	moveto(object5X1,object5Y4);
	lineto(object5X3,object5Y4);

	{*object 6 Variablen berechnen*}
	object6X1:=(pageWidth - width)/2;
	object6X2:=((pageWidth - width)/2) + (width/2);
	object6X3:=object6X2 + (width/2);

	object6Y1:=pageFoldY + depth;
	object6Y3:=pageFoldY - height; 
	object6Y2:=object6Y3 + depth;
	object6Y4:=object6Y3 - depth;

	{*Stift einstellen*}
	penPat(2);
	penFore(0,0,65535);

	{*object 6 schnittkanten zeichnen*}
	moveto(object6X1,object6Y1);
	lineto(object6X1,object6Y4);
	moveto(object6X2,object6Y1);
	lineto(object6X2,object6Y2);
	moveto(object6X2,object6Y2);
	lineto(object6X3,object6Y2);
	moveto(object6X3,object6Y2);
	lineto(object6X3,object6Y4);

	{*Stift einstellen*}
	penFore(65535,0,0);
	penPat(-2);

	{*object 6 faltkanten zeichnen*}
	moveto(object6X1,object6Y3);
	lineto(object6X3,object6Y3);
	moveto(object6X1,object6Y4);
	lineto(object6X3,object6Y4);

	{*object 7 Variablen berechnen*}
	object7X1:=objectX1 - (width/2) - (width/4);
	object7X2:=objectX2 - (width/2) - (width/4);
	object7X3:=objectX2 + (width/2);

	object7Y1:=object6Y1 + (depth/2);
	object7Y3:=object6Y3 - (depth/2) - (2*depth); 
	object7Y2:=object6Y2 - (depth/2) - (2*depth);
	object7Y4:=object6Y4 - (3*depth);

	{*Stift einstellen*}
	penPat(2);
	penFore(0,0,65535);

	{object 7 schnittkanten zeichnen*}
	moveto(object7X1,object7Y1);
	lineto(object7X1,object7Y4);
	moveto(object7X2,object7Y1);
	lineto(object7X2,object7Y2);
	moveto(object7X2,object7Y2);
	lineto(object7X3,object7Y2);
	moveto(object7X3,object7Y2);
	lineto(object7X3,object7Y4);

	{*Stift einstellen*}
	penFore(65535,0,0);
	penPat(-2);

	{*object 7 faltkanten zeichnen*}
	moveto(object7X1,object7Y3);
	lineto(object7X3,object7Y3);
	moveto(object7X1,object7Y4);
	lineto(object7X3,object7Y4);

	{*object 8 Variablen berechnen*}
	object8X1:=object2X1;
	object8X2:=object6X3 + (width/4);
	object8X3:=object6X1 - (width/2) - (width/4);

	object8Y1:=object7Y1;
	object8Y2:=object7Y4 - (depth/2); 
	object8Y3:=object8Y2 - depth;
	object8Y4:=object8Y3 - 2*depth;

	{*Stift einstellen*}
	penPat(2);
	penFore(0,0,65535);

	{object 8 schnittkanten zeichnen*}
	moveto(object8X1,object8Y1);
	lineto(object8X1,object8Y4);
	moveto(object8X2,object8Y1);
	lineto(object8X2,object8Y2);
	moveto(object8X2,object8Y2);
	lineto(object8X3,object8Y2);
	moveto(object8X3,object8Y2);
	lineto(object8X3,object8Y4);

	{*Stift einstellen*}
	penFore(65535,0,0);
	penPat(-2);

	{*object 8 faltkanten zeichnen*}
	moveto(object8X1,object8Y3);
	lineto(object8X3,object8Y3);
	moveto(object8X1,object8Y4);
	lineto(object8X3,object8Y4);

	
	{*object 9 Variablen berechnen*}
	object9X1:=object6X1 - width - (width/2);
	object9X2:=object6X2 - width - (width/2);
	object9X3:=object2X1;

	object9Y1:=object8Y1 + (depth/2); 
	object9Y2:=object8Y4 - (depth/2);
	object9Y3:=object9Y2 - depth;
	object9Y4:=object9Y3 - (2*depth);

	{*Stift einstellen*}
	penPat(2);
	penFore(0,0,65535);

	{object 9 schnittkanten zeichnen*}
	moveto(object9X1,object9Y1);
	lineto(object9X1,object9Y4);
	moveto(object9X2,object9Y1);
	lineto(object9X2,object9Y2);
	moveto(object9X2,object9Y2);
	lineto(object9X3,object9Y2);
	moveto(object9X3,object9Y2);
	lineto(object9X3,object9Y4);

	{*Stift einstellen*}
	penFore(65535,0,0);
	penPat(-2);

	{*object 9 faltkanten zeichnen*}
	moveto(object9X1,object9Y3);
	lineto(object9X3,object9Y3);
	moveto(object9X1,object9Y4);
	lineto(object9X3,object9Y4);

	{*object 10 Variablen berechnen*}
	object10X1:=object6X3 + width + (width/2);
	object10X2:=object2X2 + (width/2) + (width/4);
	object10X3:=object6X1 - width - (width/2);

	object10Y1:=object9Y1 + (depth/2);
	object10Y2:=object9Y4 - (depth/2); 
	object10Y3:=object10Y2 - depth;
	object10Y4:=object10Y3 - (3*depth);

	{*Stift einstellen*}
	penPat(2);
	penFore(0,0,65535);

	{object 10 schnittkanten zeichnen*}
	moveto(object10X1,object10Y1);
	lineto(object10X1,object10Y4);
	moveto(object10X2,object10Y1);
	lineto(object10X2,object10Y2);
	moveto(object10X2,object10Y2);
	lineto(object10X3,object10Y2);
	moveto(object10X3,object10Y2);
	lineto(object10X3,object10Y4);

	{*Stift einstellen*}
	penFore(65535,0,0);
	penPat(-2);

	{*object 10 faltkanten zeichnen*}
	moveto(object10X1,object10Y3);
	lineto(object10X3,object10Y3);
	moveto(object10X1,object10Y4);
	lineto(object10X3,object10Y4);

END;

RUN(folding);