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EN
	CALL TEXT('S',H1,ANGLE,XL1,YL1,0.,0,'+',1,'A')
	ELSEIF(SCH.LT.0.0)THEN
	CALL TEXT('S',H1,ANGLE,XL1,YL1,0.0,0,'-',1,'A')
	SCH=ABS(SCH)
	ENDIF
	XL1=XL1+0.6*H*COS(ANG1)
	YL1=YL1+0.6*H*SIN(ANG1)
	CALL TEXT('S',H1,ANGLE,XL1,YL1,SCH,0,'0',1,'F')
	XL1=XL+(ZL1+0.2*H)*COS(ANG1)
	YL1=YL+(ZL1+0.2*H)*SIN(ANG1)
	IF(XCH.EQ.0)THEN
	CALL TEXT('S',H1,ANGLE,XL1,YL1,0.,0,' 0',2,'A')
	ELSEIF(XCH.GT.0.0)THEN
	CALL TEXT('S',H1,ANGLE,XL1,YL1,0.0,0,'+',1,'A')
	ELSEIF(XCH.LT.0.0)THEN
	CALL TEXT('S',H1,ANGLE,XL1,YL1,0.0,0,'-',1,'A')
	XCH=ABS(XCH)
	ENDIF
	XL1=XL1+0.6*H*COS(ANG1)
	YL1=YL1+0.6*H*SIN(ANG1)
	CALL TEXT('S',H1,ANGLE,XL1,YL1,XCH,0,'0',1,'F')
	GOTO 40
  30	IF(FOL.NE.'     ')THEN
    	XL1=XL+(ZL1+0.25*H)*COS(ANG1)
	YL1=YL+(ZL1+0.25*H)*SIN(ANG1)
	CALL TEXT('S',H,ANGLE,XL1,YL1,0.,0,FOL,4,'A')
	ENDIF
  40	RETURN
	END

	SUBROUTINE BGD(X,Y,OUTR,ZO,DGCH,PRE,OH,Y0,ID,IL,IR,XB,YB,ANG,
     #	ZF,GCH)
	DIMENSION X(50),Y(50),OUTR(30,13),ZO(30)
	CHARACTER*1 DL,OH,ZF
	CHARACTER*2 OUTA(30)
	CHARACTER*4 GCH(13,56)
	CHARACTER*5 DGCH
	CHARACTER*3 TQGD(2,13),PRE,GD,GDL,GDR
	DATA TQGD/'GD9','GF9','GD9','GF9','GD9','GF9',
     #	'GD8','GF8','GD8','GF8','GD7','GF7','GD7',
     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QGD(2,N)
	ENDIF
	IF(ZFL.EQ.'Z')THEN
	GDL=TQGD(1,N)
	ELSEIF(ZFL.EQ.'F')THEN
	GDL=TQGD(2,N)
	ENDIF
	IF(ZFR.EQ.'Z')THEN
	GDR=TQGD(1,N)
	ELSEIF(ZFR.EQ.'F')THEN
	GDR=TQGD(2,N)
	ENDIF
	IF(PRE.EQ.'%%C')THEN
	CALL INSERT(GD,XB,YB,5.,5.,0.)
	ELSEIF(PRE.EQ.'SHL')THEN
	CALL INSERT(GDL,XBL,YBL,5.,5.,90.)
	CALL INSERT(GDR,XBR,YBR,5.,5.,-90.)
	ELSEIF(PRE.EQ.'DEF')THEN
	CALL INSERT(GD,XB,YB,5.,5.,ANG)
	ENDIF
  10	RETURN
	END

	SUBROUTINE GDDJ(GCH,DGCH,N)
	CHARACTER*4 GCH(13,56)
	CHARACTER*5 DGCH
	N=0
    	DO 20 I=1,13
	DO 20 J=1,56
	IF(GCH(I,J).EQ.DGCH)THEN
	N=I
	RETURN
	ENDIF
  20	CONTINUE
	RETURN
	END

	SUBROUTINE DIMP(ANG,X,Y,DG,D,L)
	DIMENSION X(50),Y(50)
	CHARACTER*5 DG
	CHARACTER*25 FORM
	COMMON SCL
	IF(D/SCL.LE.50)THEN
	IF(ANG.EQ.90.)THEN
	CALL LINE(X(3),Y(1),X(3),Y(2))
	ELSEIF(ANG.EQ.0.)THEN
	CALL LINE(X(1),Y(3),X(2),Y(3))
	ENDIF
	ENDIF
	WRITE(1,'(A)')'DIM'
	WRITE(1,'(A)')'ROTATED'
	WRITE(1,'(E12.7)')ANG
	WRITE(1,'(E12.7,A1,E12.7)')X(1),',',Y(1)
	WRITE(1,'(E12.7,A1,E12.7)')X(2),',',Y(2)
	WRITE(1,'(E12.7,A1,E12.7)')X(3),',',Y(3)
	IF(L.EQ.1)THEN
	WRITE(1,'(A2,2A1)')'G ',DG,'"'
	ELSEIF(L.EQ.2)THEN
	WRITE(1,'(A2,A2,A1)')'G ',DG,'"'
	ELSE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
	ENDIF
	CALL DIMGCH(X1,Y1,4.,OUTY(I0,2)*SCL,0.,0.,90.,'%%C','     ')
	ELSEIF(OUTY(I0,1).GT.OUTY(I0,2))THEN
      IF(OUTY(I0,13)*SCL.EQ.2.0)GOTO88
	IF(ROH(I0).EQ.'LO')THEN
	XL0=XL0-12
	X1(3)=XL0
	ROH(I0)='/'
	ELSEIF(ROH(I0).EQ.'RO')THEN
	XR0=XR0+12
	X1(3)=XR0
	ROH(I0)='/'
	ENDIF
	CALL DIMGCH(X1,Y1,4.,OUTY(I0,2)*SCL,0.,0.,90.,'%%C','     ')
88      IF(OUTY(I0,13)*SCL.EQ.1.0)GOTO77
	IF(LOH(I0).EQ.'LO')THEN
	XL0=XL0-12
	X(3)=XL0
	LOH(I0)='/'
	ELSEIF(LOH(I0).EQ.'RO')THEN
	XR0=XR0+12
	X(3)=XR0
	LOH(I0)='/'
	ENDIF
	CALL DIMGCH(X,Y,4.,OUTY(I0,1)*SCL,0.,0.,90.,'%%C','     ')
77	ENDIF
	ELSE
      IF(OUTY(I0,13)*SCL.EQ.1.0.AND.OUTY(I0,1).GT.OUTY(I0,2))GOTO11
      IF(OUTY(I0,13)*SCL.EQ.2.0.AND.OUTY(I0,1).LT.OUTY(I0,2))GOTO11
	IF(LOH(I0).EQ.'LO')THEN
	XL0=XL0-12
	X(3)=XL0
	LOH(I0)='/'
	CALL DIMGCH(X,Y,4.,OUTY(I0,1)*SCL,0.,0.,90.,'%%C','     ')
	ENDIF
11    IF(OUTY(I0,13)*SCL.EQ.2.0.AND.OUTY(I0,1).GT.OUTY(I0,2))GOTO22
      IF(OUTY(I0,13)*SCL.EQ.1.0.AND.OUTY(I0,1).LT.OUTY(I0,2))GOTO22
	IF(ROH(I0).EQ.'RO')THEN
	XR0=XR0+12
	X1(3)=XR0
	ROH(I0)='/'
	CALL DIMGCH(X1,Y1,4.,OUTY(I0,2)*SCL,0.,0.,90.,'%%C','     ')
	ENDIF
22	ENDIF
C	CALL BZD(OUTY,ZZ,IOH,GCH,Y0,OH,CONS,K,I0)
	ENDIF
	RETURN
	END

	SUBROUTINE BZD(OUTY,ZZ,IOH,GCH,Y0,OH,CONS,K,I0)
	DIMENSION OUTY(30,13),ZZ(30),CONS(100,2)
	CHARACTER*1 OH
	CHARACTER*5 GCH(30)
	XC=(ZZ(I0)+ZZ(I0+1))/2
      IF(GCH(I0).EQ.'    ')GOTO222
	IF(OH.EQ.'O')THEN
	YG=Y0+AMAX1(OUTY(I0,1),OUTY(I0,2))/2+8
	YM=Y0+(OUTY(I0,1)+OUTY(I0,2))/4
	ELSEIF(OH.EQ.'H')THEN
	YG=Y0-AMIN1(OUTY(I0,1),OUTY(I0,2))/2+4
	YM=Y0-(OUTY(I0,1)+OUTY(I0,2))/4
	ENDIF
	IF(GCH(I0).EQ.' 0  '.OR.GCH(I0).EQ.' 1  '.OR.GCH(I0).EQ.
     #	' 2  '.OR.GCH(I0).EQ.' 3  '.OR.GCH(I0).EQ.' 4  '.OR.GCH(I0)
     #	.EQ.' 5  '.OR.GCH(I0).EQ.' 6  ')THEN
	XF=XC-13
	XE=XC+13
	CALL INSERT('MOS',XF+2,YG+1,4.,4.,0.)
	CALL TEXT('R',4.,0.,XF+16,YG+1.0,0.,0,GCH(I0),4,'A')
	ELSE
	XF=XC-8
	XE=XC+8
	CALL TEXT('R',4.,0.,XC,YG+1,0.,0,GCH(I0),4,'A')
      ENDIF
	 CALL SCON(CONS,K,XF,XE)
      IF(GCH(I0).NE.'     ')THEN
        YG=YG+1.5
        IF(OUTY(I0,1).LT.OUTY(I0,2))THEN
	CALL LINE(XF,YG,XF,YG+4.0)
	CALL LINE(XF,YG+4.0,XF-10.0,YG+2.0)
	CALL LINE(XF-10,YG+2.0,XF,YG)
        ELSE
	CALL LINE(XF,YG+2.0,XF-10.0,YG+4.0)
	CALL LINE(XF-10.0,YG+4.0,XF-10.0,YG)
	CALL LINE(XF-10,YG,XF,YG+2.0)
        ENDIF
	CALL LINE(XE-4,YG-1.5,XF-10.0,YG-1.5)
	CALL LINE(XF-10.0,YG-1.5,XC,YM)
	ENDIF
 222  RETURN
	END

	SUBROUTINE DIMS(ANG,X,Y,H,D,S,PRE,FOL)
	DIMENSION X(50),Y(50)
	CHARACTER*2 PRE
	CHARACTER*5 FOL
	CHARACTER*25 FORM
	COMMON SCL
	WRITE(1,'(A)')'DIM'
	WRITE(1,'(A)')'ROTATED'
	WRITE(1,'(E12.7)')ANG
	WRITE(1,'(E12.7,A1,E12.7)')X(1),',',Y(1)
	WRITE(1,'(E12.7,A1,E12.7)')X(2),',',Y(2)
	WRITE(1,'(E12.7,A1,E12.7)')X(3),',',Y(3)
	WRITE(1,'(X)')
	WRITE(1,'(A)')'EXIT'
	ND1=0
	IF(D.LT.10.)THEN
	IF(FLOAT(INT(D+0.01)).EQ.D)THEN
	ND1=1
	ELSEIF(FLOAT(INT(D*10+0.01)).EQ.D*10.)THEN
	ND1=2
	ENDIF
	ENDIF
	ND=200
	IF(D.GE.10.AND.D.LT.100)ND=200
	IF(D.GE.100.AND.D.LT.1000)ND=300
	IF(D.GE.1000.AND.D.LT.10000)ND=400
	IF(S.LT.10)THEN
	IF(FLOAT(INT(S+0.01)).EQ.S)THEN
	NS=10
	ELSEIF(FLOAT(INT(S*10+0.01)).EQ.S*10)THEN
	NS=11
	ELSEIF(FLOAT(INT(S*100+0.01)).EQ.S*100)THEN
	NS=12
	ENDIF
	ELSEIF(S.GE.10.AND.S.LT.100)THEN
	IF(FLOAT(INT(S+0.01)).EQ.S)THEN
	NS=20
	ELSEIF(FLOAT(INT(S*10+0.01)).EQ.S*10)THEN
	NS=21
	ELSEIF(FLOAT(INT(S*100+0.01)).EQ.S*100)THEN
	NS=22
	ENDIF
	ENDIF
	NF=ND+NS
 	IF(NF.EQ.210)THEN
	ZL=11*H
	ELSEIF(NF.EQ.211)THEN
	ZL=13*H
     	ELSEIF(NF.EQ.212)THEN
	ZL=14*H
     	ELSEIF(NF.EQ.220)THEN
	ZL=12*H
     	ELSEIF(NF.EQ.221)THEN
	ZL=14*H
     	ELSEIF(NF.EQ.222)THEN
	ZL=15*H
     	ELSEIF(NF.EQ.310)THEN
	ZL=12*H
     	ELSEIF(NF.EQ.311)THEN
	ZL=14*H
     	ELSEIF(NF.EQ.312)THEN
	ZL=15*H
     	ELSEIF(NF.EQ.320)THEN
	ZL=13*H
     	ELSEIF(NF.EQ.321)THEN
	ZL=15*H
     	ELSEIF(NF.EQ.322)THEN
	ZL=16*H
	ENDIF
	IF(ND1.EQ.1)ZL=ZL-H
	IF(ND1.EQ.2)ZL=ZL+H
	ID=INT(D)
	IS=INT(S)
	IF(FOL.EQ.'     ')THEN
	ZL=ZL-6*H
	ENDIF
	IF((D/SCL-ZL).GE.12)THEN
	XL=X(3)-0.5*H
	YL=(Y(1)+Y(2))/2-ZL/2
	ELSE
	CALL LINE(X(3),Y(1),X(3),Y(2))
	IF(Y(1).LT.Y(2))THEN
	YL=Y(2)+9
	ELSE
	YL=Y(2)-9-ZL
	ENDIF
	XL=X(3)+H/2
	ENDIF
	CALL TEXT('S',H,90.0,XL,YL,0.0,0,PRE,1,'A')
	YL=YL+1.2*H
	IF(ND1.EQ.0)THEN
	CALL TEXT('S',H,90.,XL,YL,0.,ID,'0',1,'I')
	YL=YL+ND*H/100
	ELSEIF(ND1.EQ.1)THEN
	CALL TEXT('S',H,90.,XL,YL,0.,ID,'0',1,'I')
	YL=YL+H
	ELSEIF(ND1.EQ.2)THEN
	CALL TEXT('S',H,90.,XL,YL,D,0,'0',1,'F')
	YL=YL+2.5*H
	ENDIF
	CALL TEXT('S',H,90.,XL,YL,0.,0,'X',1,'A')
	YL=YL+H
	IF(NS.EQ.10.OR.NS.EQ.20)THEN
	CALL TEXT('S',H,90.,XL,YL,0.,IS,'0',1,'I')
	YL=YL+NS*H/10
	ELSE
	CALL TEXT('S',H,90.,XL,YL,S,0,'0',1,'F')
	YL=YL+H*(INT(NS/10)+NS-INT(NS/10)*10+1)
	ENDIF
	IF(FOL.NE.'     ')THEN
	CALL TEXT('S',H,90.,XL,YL,0.,0,'-',1,'A')
	CALL TEXT('S',H,90.,XL,YL+H,0.,0,FOL,5,'A')
	ENDIF
	RETURN
	END
	
	SUBROUTINE DECIM(W,ND,NS)
	AW=W
	IF(AW.LT.0.)AW=-AW
	IF(AW.LT.10)ND=10
	IF(AW.GE.10.AND.AW.LT.100)ND=20
	IF(AW.GE.100.AND.AW.LT.1000)ND=30
	IF(AW.GE.1000.AND.AW.LT.10000)ND=40
	AX0=FLOAT(INT(AW+0.00001))
	IF(AW.LT.1)AX0=0
	AX1=FLOAT(INT(AW*10.+0.0001))/10.
	AX2=FLOAT(INT(AW*100.+0.001))/100.
	IF(AW.EQ.AX0)THEN
	NS=0
	GOTO 10
	ENDIF
	IF(AW.EQ.AX1)THEN
	NS=1
	GOTO 10
	ENDIF
	IF(AW.EQ.AX2)THEN
	NS=2
	GOTO 10
	ENDIF
	NS=3
  10	RETURN
	END

	SUBROUTINE BYK(XC,YC,Y0,R1,R2,CL,KN,KS,ANK,DMAX,TH,ITY,KTG,K)
	CHARACTER*2 TH
	CHARACTER*5 KTG
	IF((K.EQ.1.AND.ANK.EQ.0.).OR.(K.EQ.2.AND.ANK.NE.0.))THEN
	AT=8.
	ELSE
	AT=24.
	ENDIF
	X3=XC+0.707*R1/2
	Y3=YC-0.707*R1/2
	X4=XC-0.707*R1/2
	Y4=YC+0.707*R1/2
	X2=X3+2.8
	Y2=Y3-2.8
	X1=X2+2.8
	Y1=Y2-2.8
	X5=X4-2.8
	Y5=Y4+2.8
	Y6=Y0+DMAX/2+AT
      IF(KS.EQ.1.AND.ANK.EQ.180.)THEN
      Y6=Y0-DMAX/2-AT
      ENDIF
	X6=XC-Y6+YC
	IF(KN.EQ.1.AND.KTG.EQ.'  ')THEN
	LLX=25
	ELSE
	LLX=35
	ENDIF
	IF((K.EQ.1.AND.ANK.EQ.0.).OR.K.EQ.2.OR.(KS.EQ.1.AND.
     # ANK.EQ.180.))THEN
	X7=X6-LLX
	XF=X7
	ELSE
	X7=X6+LLX
	XF=X6
	ENDIF
	Y7=Y6
	WRITE(1,'(A)')'PLINE'
	WRITE(1,'(E12.7,A1,E12.7)')X1,',',Y1
	WRITE(1,'(A)')'W'
	WRITE(1,'(F2.1)').0
	WRITE(1,'(F2.1)').0
	WRITE(1,'(E12.7,A1,E12.7)')X2,',',Y2
	WRITE(1,'(A)')'W'
	WRITE(1,'(F3.1)')1.4
	WRITE(1,'(F2.1)').0
	WRITE(1,'(E12.7,A1,E12.7)')X3,',',Y3
	WRITE(1,'(E12.7,A1,E12.7)')X4,',',Y4
	WRITE(1,'(A)')'W'
	WRITE(1,'(F2.1)').0
	WRITE(1,'(F3.1)')1.4
	WRITE(1,'(E12.7,A1,E12.7)')X5,',',Y5
	WRITE(1,'(A)')'W'
	WRITE(1,'(F2.1)').0
	WRITE(1,'(F2.1)').0
	WRITE(1,'(E12.7,A1,E12.7)')X6,',',Y6
	WRITE(1,'(E12.7,A1,E12.7,X)')X7,',',Y7
	IF(KN.EQ.2.AND.KTG.EQ.' ')THEN
	XL=XF+11
	ELSE
	XL=XF+5
	ENDIF
	YL=Y6+0.8
	IF(KS.GT.1)THEN
	CALL TEXT('S',4.,0.,XL,YL,0.0,KS,'0',1,'I')
	IF(KS.GT.10)THEN
      XL=XL+6.5
      ELSE
      XL=XL+4.
      ENDIF
	CALL TEXT('S',4.,0.,XL,YL,0.0,0,'-',1,'A')
	ENDIF
	XL=XL+4.
	IF(TH.EQ.'DK'.OR.TH.EQ.'LK')THEN
	CALL TEXT('S',4.,0.,XL,YL,0.0,0,'M',1,'A')
	ELSE
	CALL TEXT('S',4.,0.,XL,YL,0.0,0,'%%C',3,'A')
	ENDIF
	XL=XL+4.
	CALL TEXT('S',4.,0.,XL,YL,R1,0,'0',1,'F')
	IF(KTG.NE.'     '.AND.TH.NE.'GK')THEN
	IF(R1.LT.10)THEN
	XL=XL+4
	ELSE
	XL=XL+8
	ENDIF
	CALL TEXT('S',4.,0.,XL,YL,0.0,0,'-',1,'A')
	CALL TEXT('S',4.,0.,XL+4,YL,0.0,0,KTG,4,'A')
	ENDIF
	IF(TH.EQ.'ZK')THEN
	IF(R1.LT.10.)THEN
	XL=XL+4
	ELSE
	XL=XL+8
	ENDIF
	CALL SHAPE('ZXAUK',0.3,0.,XL,YL)
	ENDIF
	IF(KN.EQ.2)THEN
	XL1=XF+5
	YL1=Y6-4.8
	CALL INSERT('CGK',XL1,YL1,4.8,4.8,0.)
	XL1=XL1+8.
	CALL TEXT('S',4.,0.,XL1,YL1,0.0,0,'%%C',3,'A')
	XL1=XL1+4.
	CALL TEXT('S',4.,0.,XL1,YL1,R2,0,'0',1,'F')
	IF(R2.LT.10)THEN
	XL1=XL1+4.
	ELSE
	XL1=XL1+8
	ENDIF
	IF(ITY.EQ.2)THEN
	CALL INSERT('XGZ',XL1,YL1,3.4,4.3,0.)
	XL1=XL1+4.
	CALL TEXT('S',4.,0.,XL1,YL1,CL,0,'0',1,'F')
	ELSE
	CALL TEXT('S',4.,0.,XL1,YL1,0.0,0,'X',1,'A')
	XL1=XL1+4
	CALL TEXT('S',4.,0.,XL1,YL1,0.0,0,'90',2,'A')
	XL1=XL1+8
	CALL TEXT('S',4.,0.,XL1,YL1,0.0,0,'%%D',3,'A')
	ENDIF
	ENDIF
	IF(KN.NE.2.AND.TH.NE.'LK'.AND.TH.NE.'XK')THEN
	IF(KTG.NE.'    ')THEN
	XL1=XF+15
	ELSE
	XL1=XF+8
	ENDIF
	YL1=Y6-4.8
	CALL INSERT('XGZ',XL1,YL1,3.4,4.3,0.)
	XL1=XL1+4.
	CALL TEXT('S',4.,0.,XL1,YL1,CL,0,'0',1,'F')
	ENDIF
	RETURN
	END

	SUBROUTINE ARC(XA,YA,XC,YC,ALF)
	WRITE(1,'(A)')'ARC'
	WRITE(1,'(E12.7,A1,E12.7)')XA,',',YA
	WRITE(1,'(A)')'C'
	WRITE(1,'(E12.7,A1,E12.7)')XC,',',YC
	WRITE(1,'(A)')'A'
	WRITE(1,'(E12.7)')ALF
	RETURN
	END

	SUBROUTINE SHAPE(NAME,H,ANG,X,Y)
	CHARACTER*5 NAME
	WRITE(1,'(A)')'LOAD'
	WRITE(1,'(A)')'JCSHZ'
	WRITE(1,'(A)')'SHAPE'
	WRITE(1,'(A)')NAME
	WRITE(1,'(E12.7,A1,E12.7)')X,',',Y
	WRITE(1,'(E12.7)')H
	WRITE(1,'(E12.7)')ANG
	RETURN
	END

        SUBROUTINE PLINE(XF,YF,XM,YM)
        A=0.0
        B=1.2
        WRITE(1,'(A)')'PLINE'
        WRITE(1,'(E12.7,A1,E12.7)')XF,',',YF
        WRITE(1,'(A)')'W'
        WRITE(1,'(E12.7)')A
        WRITE(1,'(E12.7)')B
        WRITE(1,'(E12.7,A1,E12.7,X)')XM,',',YM
        RETURN
        END
