'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright by Weinmann Holzbausystemtechnik GmbH (c) 2004
'
' Filename:
'
' Description:
'
' Author:                tb32sot
'
' Date:                        20040121
'
' Version:                V0.01
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

SUB MAIN

 CONST BOHRDURCHMESSER = 10

 DIM dPX(16)
 DIM i
 DIM sIni
 DIM SLOPE_DEFAULT

 SLOPE_DEFAULT = 30

 'Holen Parameterbezeichnungen abhaengig von der Landessprache
 sIni = "l" + GETACTUALLANGUAGE() + ".ini"

IF NOT FINDFIRSTSELECTED THEN
	DIM BEAMCOUNTER

	BEAMCOUNTER = GETCOUNTTYPE(CalcType("LS"))
	BEAMCOUNTER = BEAMCOUNTER + GETCOUNTTYPE(CalcType("QS"))
	BEAMCOUNTER = BEAMCOUNTER + GETCOUNTTYPE(CalcType("BT4"))
	BEAMCOUNTER = BEAMCOUNTER + GETCOUNTTYPE(CalcType("BT6"))

	IF BEAMCOUNTER = 1 THEN
		IF GETCOUNTTYPE(CalcType("LS")) = 1 THEN
			FINDFIRSTTYPE(CalcType("LS"))
		END IF
		IF GETCOUNTTYPE(CalcType("QS")) = 1 THEN
			FINDFIRSTTYPE(CalcType("QS"))
		END IF
		IF GETCOUNTTYPE(CalcType("BT4")) = 1 THEN
			FINDFIRSTTYPE(CalcType("BT4"))
		END IF
		IF GETCOUNTTYPE(CalcType("BT6")) = 1 THEN
			FINDFIRSTTYPE(CalcType("BT6"))
		END IF
	ELSE
	  MsgBox GETPRIVATEPROFILESTRING("Fehler", "F1", " ", sIni), _
		vbOkOnly + vbCritical + vbSystemModal,"Error"
	  exit sub
	END IF
END IF

IF NOT ( ISBEAM OR ( ISBEAMPROCESSING AND SELECTPARENTBEAM() ) ) THEN
  MsgBox GETPRIVATEPROFILESTRING("Fehler", "F2", " ", sIni), _
    vbOkOnly + vbCritical + vbSystemModal,"Error"
  exit sub
END IF

FOR i = LBOUND(dPX) TO UBOUND(dPX)
    dPX(i) = 0.0
NEXT

dPX(6) = 90 ' always perpendicular

dPX(16) = 3 ' fixed to anfgang

IF MsgBox(GETPRIVATEPROFILESTRING("Anfang/Ende_orientiert", "T1", " ", sIni) & vbCrLf & vbCrLf & _
   GETPRIVATEPROFILESTRING("Anfang/Ende_orientiert", "T2", " ", sIni), _
   vbYesNo + vbQuestion, _
   GETPRIVATEPROFILESTRING("Anfang/Ende_orientiert", "T0", " ", sIni)) = vbYes THEN
   dPX(16) = 3       ' anfgang (links)
ELSE
    dPX(16) = 4        ' ende (rechts)
END IF


DO

  dPX(0) = InputBoxI( _
  GETPRIVATEPROFILESTRING("Ebene", "T1", " ", sIni) & vbCrLf & vbCrLf & _
  GETPRIVATEPROFILESTRING("Ebene", "T2", " ", sIni) & vbCrLf & vbCrLf & _
  GETPRIVATEPROFILESTRING("Ebene", "T3", " ", sIni) & vbCrLf & _
  GETPRIVATEPROFILESTRING("Ebene", "T4", " ", sIni) & vbCrLf & _
  GETPRIVATEPROFILESTRING("Ebene", "T5", " ", sIni) & vbCrLf & _
  GETPRIVATEPROFILESTRING("Ebene", "T6", " ", sIni) & vbCrLf & vbCrLf, _
  "", 1)

  IF bInputBoxCancel = 1 THEN
    EXIT SUB
  END IF

  IF (1 <= dPX(0)) and (dPX(0) <= 4)  THEN
      EXIT DO
  ELSE
      F_Title = GETPRIVATEPROFILESTRING("Fehler", "F3", " ", sIni)
          MsgBox F_Title,vbOkOnly + vbCritical + vbSystemModal,"Error"
  END IF
LOOP

'dPX(0) = 1

        dPX(1) = inputboxfloc("P1:" ,"",0)

        IF bInputBoxCancel = 1 THEN
                EXIT SUB
        END IF

	dPX(7) = GetTempParam(0)
	IF dPX(7) = 0 THEN
   		dPX(7) = SLOPE_DEFAULT
	END IF
        dPX(7) = inputboxf("P7:","", dPX(7) )

        IF bInputBoxCancel = 1 THEN
                EXIT SUB
        END IF
	SetTempParam 0,dPX(7)

        dPX(8) = 90.0 + dPX(7)


		dPX(6) = inputboxfloc("P6:" ,"",90)

        IF bInputBoxCancel = 1 THEN
                EXIT SUB
        END IF


        dPX(11) = inputboxfloc("P11:","",30)


        IF bInputBoxCancel = 1 THEN
                EXIT SUB
        END IF

		dPX(12) = dPX(11)

        dPX(12) = inputboxfloc("P12:","",dPX(12))


        IF bInputBoxCancel = 1 THEN
                EXIT SUB
        END IF


		DIM DRILLDEPTH

        IF dPX(0) = 1 OR dPX(0) = 3 THEN
                dPX(13) = GETPARAM(3) ' top or bottom ebene -> assign balken width
                DRILLDEPTH = GETPARAM(2)
'                dPX(1) = dPX(1) + ( GETPARAM(2) - dPX(11) ) * TAN (  ( dPX(7) * PI ) / 180 )
        ELSE
                dPX(13) = GETPARAM(2) ' otherwise assign balken height
                DRILLDEPTH = GETPARAM(3)
'                dPX(1) = dPX(1) + ( GETPARAM(3) - dPX(11) ) * TAN (  ( dPX(7) * PI ) / 180 )
        END IF

        DIM RETVAL
        RETVAL = BTLFUNCTION(dPX(16),20,dPX(0),dPX(1),dPX(2),dPX(3),dPX(4),dPX(5),dPX(6),dPX(7),dPX(8),dPX(9),dPX(10),dPX(11),dPX(12),dPX(13),dPX(14),dPX(15))

        IF NOT RETVAL THEN
                MsgBox GETLASTERROR,vbOkOnly + vbCritical + vbSystemModal,"Error"
        END IF

'	  	RETVAL = MsgBox(GETPRIVATEPROFILESTRING("Kerve", "P16", " ", sIni), vbYesNo + vbQuestion + vbSystemModal,"")
'
'	  	DIM OFFSET
'	  	OFFSET = 45.0 - dPX(7)
'
'
'		IF RETVAL = vbYes THEN
'			PAF dPX(0)
'			MP dPX(1) - OFFSET, dPX(13) / 2.0, BOHRDURCHMESSER / 2.0, -DRILLDEPTH, 211, 0
'		END IF

END SUB
MAIN
