#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $Group1, $Group2, $Group3, $Group4, $Group5, $Group6, $Group7, $Group8, $Group9
Global $Radio1, $Radio2, $Radio3, $Radio4
Global $Button1, $Button2, $Button3, $Button4, $Button5, $Button6, $Button7
Global $Inp_DP, $Inp_SS, $Inp_LHR, $Inp_LMR, $Inp_Masse, $Inp_VNENN, $Inp_FAB, $Inp_BEMERK, $Inp_PBAR, $Inp_XD
Global $Inp_DD1, $Inp_NG1, $Inp_DD2, $Inp_NG2, $Inp_DD3, $Inp_NG3, $Inp_DD4, $Inp_NG4, $Inp_NS, $Inp_SO, $Inp_LA, $Inp_NA, $Inp_LZ, $Inp_NZ
Global $Label1, $Label2, $Label3, $Label4, $Label5, $Label6, $Label7, $Label8, $Label9, $Label10, $Label11, $Label12, $Label13, $Label14
Global $Label15, $Label16, $Label17, $Label18, $Label19, $Label20, $Label21, $Label22, $Label23, $Label24, $Label25, $Label26, $Label27
Global $Label28, $Label29, $Label30, $Label31, $Label32, $Label33, $Label34, $Label35, $Label36, $Label37, $Label38, $Label39, $Label40
Global $Label41, $Label42, $Label43, $Label44, $Label45, $Label46, $Label47, $Label48, $Label49, $Label50, $Label51, $Label52, $Label53
Global $Label54, $Label55
Global $sLeer = "                                                                      "

Const $Pi4 = 0.7853981633975
Const $G0 = 9.81			; Erdbeschleunigung
Const $RHO = 890			; Öldichte 890 kg/m3 (Liste mit verschiedenen Dichten ?)
Const $NPOL = 1.35		; Polytropenexponent (wovon abhängig ?)
Const $ZETA = 1.55		; Drosselbeiwert     (woher kommt der ? was bedeutet er ?)
Const $ETA = 0.95			; mech. Wirkungsgrad (temperaturabhängig ?)
Const $K = 1.25			; Kurvenformfaktor   (woher kommt der ? was bedeutet er ?)
Const $VFAKT = 1.15		; Aufprallgeschwindigkeit = 115% der Nenngeschwindigkeit nach EN 81 (wird bezweifelt !)
Const $EERSATZ = 1515	; Ersatz E-Modul in N/mm2
Const $sVersion = "Version 3.0.0 vom 19.12.2019"
Const $DATEINAME = "LP 211 - FS-Verlauf.txt"

Dim $hFile, $boBerechnen, $boSpeichern, $sDummy, $nMsg, $sText, $DKZ, $sBOBI
Dim $sDatum, $DP, $SS, $SM, $LHR, $LMR, $D1, $A1, $A2, $D2, $D3, $DKS, $COFF, $CHR, $V0KOPF, $HGAS
Dim $XI, $XI2, $XD, $XDNEU, $X, $SX, $SO, $SA, $SZ, $PRJN, $XPR, $DXPR, $VPXP, $VPX, $FPX1P, $FPX1, $AXIP, $AXI, $TP, $T
Dim $ADX, $ADU, $S, $DAD, $SX, $NS, $ADO, $LA, $ADA, $LZ, $ADZ, $P1X, $ZRA, $P2X, $V0, $AKS, $P0, $FRANF, $FRUECK, $AMITTLS, $AMITTLT
Dim $A1, $FC, $CON, $FPX1, $FPX2, $FVX, $B0, $B1, $B2, $DFP, $FPMAXI, $XFPMAX, $XFPMAXI, $Masse, $AMAX, $XAMAX, $EUM, $VPX2Q, $VPX2
Dim $VP, $VNENN, $FAB, $BEMERK, $EKIN, $EPOT, $EGES, $FPMAX, $PBAR, $P0, $FDYN, $EKINX1, $ANSTFL, $XSCHWING, $SCHWING, $VGAS
Dim $SYSTEM, $ADERF, $DDERF, $NGERF, $NG, $DD, $DD1, $NG1, $AD1, $DD2, $NG2, $AD2, $DD3, $NG3, $AD3, $DD4, $NG4, $AD4, $ADVOR, $ADPRO
Dim $NA, $NZ, $NEUXD, $FU, $FO, $NR, $NE

FelderLoeschen()

#Region ### START Koda GUI section ### Form=c:\users\administrator\dropbox\projekte\liftpuffer\liftpuffer.kxf
$Form1 = GUICreate("Liftpuffer", 624, 883, -1, -1)
GUISetFont(10, 400, 0, "MS Sans Serif")

$Group1 = GUICtrlCreateGroup("Pufferwahl", 8, 8, 601, 129, BitOR($GUI_SS_DEFAULT_GROUP,$BS_LEFT,$BS_FLAT))
$Group2 = GUICtrlCreateGroup("", 16, 24, 585, 105, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT))
$Label1 = GUICtrlCreateLabel("Pufferdurchmesser in mm", 24, 72, 154, 20)
$Inp_DP = GUICtrlCreateInput($DP, 192, 70, 57, 24)
$Label2 = GUICtrlCreateLabel("Pufferhub in mm", 24, 96, 98, 20)
$Inp_SS = GUICtrlCreateInput($SS, 192, 94, 57, 24)
$Radio3 = GUICtrlCreateRadio("Standardpuffer", 24, 40, 113, 17)
$Label3 = GUICtrlCreateLabel("Außenlänge des Hydraulikrohrs in mm", 272, 72, 257, 20)
$Inp_LHR = GUICtrlCreateInput($LHR, 536, 70, 57, 24)
$Label4 = GUICtrlCreateLabel("Außenlänge des Mantelrohrs in mm", 272, 96, 234, 20)
$Inp_LMR = GUICtrlCreateInput($LMR, 536, 94, 57, 24)
$Radio4 = GUICtrlCreateRadio("KEIN Standardpuffer", 272, 40, 145, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$Group4 = GUICtrlCreateGroup("Auslegungsdaten des Puffers", 8, 152, 249, 113, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT))
$Label5 = GUICtrlCreateLabel("aufprallende Masse in kg", 16, 184, 154, 20)
$Inp_Masse = GUICtrlCreateInput($Masse, 192, 182, 57, 24)
$Label6 = GUICtrlCreateLabel("Nenngeschwindigkeit in m/s", 16, 208, 170, 20)
$Inp_VNENN = GUICtrlCreateInput($VNENN, 192, 206, 57, 24)
$Label11 = GUICtrlCreateLabel("Gasdruck in bar", 16, 232, 98, 20)
$Inp_PBAR = GUICtrlCreateInput($PBAR, 192, 230, 57, 24)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$Group6 = GUICtrlCreateGroup("Energie", 264, 152, 345, 89, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT))
$Label9 = GUICtrlCreateLabel("Pufferenergie E in Nm", 272, 184, 133, 20)
$Label44 = GUICtrlCreateLabel($EGES, 450, 184, 108, 18)
GUICtrlSetBkColor(-1, 0x00FFFF)
$Label10 = GUICtrlCreateLabel("max. Pufferkraft FPmax in Nm", 272, 208, 176, 20)
$Label45 = GUICtrlCreateLabel($FPMAX, 450, 208, 108, 18)
GUICtrlSetBkColor(-1, 0x00FFFF)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$Group5 = GUICtrlCreateGroup("Bezeichnung", 264, 256, 345, 89, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT))
$Label7 = GUICtrlCreateLabel("Fabrik-Nummer", 272, 288, 97, 20)
$Inp_FAB = GUICtrlCreateInput($FAB, 376, 286, 81, 24)
$Label8 = GUICtrlCreateLabel("Bemerkung", 272, 312, 73, 20)
$Inp_BEMERK = GUICtrlCreateInput($BEMERK, 376, 310, 225, 24)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$Group7 = GUICtrlCreateGroup("Auslegung des Bohrbilds", 8, 280, 249, 593, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT))
$Label12 = GUICtrlCreateLabel("a) gem. Pufferdefinition", 16, 312, 139, 20)
$Label13 = GUICtrlCreateLabel("erf. Fläche in mm²", 32, 336, 108, 20)
$Label46 = GUICtrlCreateLabel($ADERF, 192, 336, 57, 18)
GUICtrlSetBkColor(-1, 0x00FFFF)
$Label14 = GUICtrlCreateLabel("Durchmesser in mm", 32, 360, 122, 20)
$Label47 = GUICtrlCreateLabel($DDERF, 192, 360, 57, 18)
GUICtrlSetBkColor(-1, 0x00FFFF)
$Label15 = GUICtrlCreateLabel("Anzahl Bohrungen in mm", 32, 384, 150, 20)
$Label48 = GUICtrlCreateLabel($NGERF, 192, 384, 57, 18)
GUICtrlSetBkColor(-1, 0x00FFFF)
$Label16 = GUICtrlCreateLabel("b) eigene Definition", 16, 424, 119, 20)
$Label17 = GUICtrlCreateLabel("b1) Durchmesser D1 in mm", 16, 448, 164, 20)
$Inp_DD1 = GUICtrlCreateInput($DD1, 192, 446, 57, 24)
$Label18 = GUICtrlCreateLabel("Anzahl Bohrungen mit D1", 40, 472, 152, 20)
$Inp_NG1 = GUICtrlCreateInput($NG1, 192, 470, 57, 24)
$Label19 = GUICtrlCreateLabel("Fläche zu D1 in mm²", 40, 496, 123, 20)
$Label49 = GUICtrlCreateLabel($AD1, 192, 496, 57, 18)
GUICtrlSetBkColor(-1, 0x00FFFF)
$Label20 = GUICtrlCreateLabel("b2) Durchmesser D2 in mm", 16, 520, 164, 20)
$Inp_DD2 = GUICtrlCreateInput($DD2, 192, 518, 57, 24)
$Label21 = GUICtrlCreateLabel("Anzahl Bohrungen mit D2", 40, 544, 152, 20)
$Inp_NG2 = GUICtrlCreateInput($NG2, 192, 542, 57, 24)
$Label22 = GUICtrlCreateLabel("Fläche zu D2 in mm²", 40, 568, 123, 20)
$Label50 = GUICtrlCreateLabel($AD2, 192, 568, 57, 18)
GUICtrlSetBkColor(-1, 0x00FFFF)
$Label23 = GUICtrlCreateLabel("b3) Durchmesser D3 in mm", 16, 592, 164, 20)
$Inp_DD3 = GUICtrlCreateInput($DD3, 192, 590, 57, 24)
$Label24 = GUICtrlCreateLabel("Anzahl Bohrungen mit D3", 40, 616, 152, 20)
$Inp_NG3 = GUICtrlCreateInput($NG3, 192, 614, 57, 24)
$Label25 = GUICtrlCreateLabel("Fläche zu D3 in mm²", 40, 640, 123, 20)
$Label51 = GUICtrlCreateLabel($AD3, 192, 640, 57, 18)
GUICtrlSetBkColor(-1, 0x00FFFF)
$Label26 = GUICtrlCreateLabel("b4) Durchmesser D4 in mm", 16, 664, 164, 20)
$Inp_DD4 = GUICtrlCreateInput($DD4, 192, 662, 57, 24)
$Label27 = GUICtrlCreateLabel("Anzahl Bohrungen mit D4", 40, 688, 152, 20)
$Inp_NG4 = GUICtrlCreateInput($NG4, 192, 686, 57, 24)
$Label28 = GUICtrlCreateLabel("Fläche zu D4 in mm²", 40, 712, 123, 20)
$Label52 = GUICtrlCreateLabel($AD4, 192, 712, 57, 18)
GUICtrlSetBkColor(-1, 0x00FFFF)
$Label29 = GUICtrlCreateLabel("c) Ergebnis", 16, 752, 72, 20)
$Label30 = GUICtrlCreateLabel("Gesamtfläche (b1...b4)", 32, 776, 137, 20)
$Label53 = GUICtrlCreateLabel($ADVOR, 192, 776, 57, 18)
GUICtrlSetBkColor(-1, 0x00FFFF)
$Label31 = GUICtrlCreateLabel("entspricht", 32, 800, 61, 20)
$Label54 = GUICtrlCreateLabel($ADPRO, 94, 800, 34, 18, $ES_RIGHT)
GUICtrlSetBkColor(-1, 0x00FFFF)
$Label32 = GUICtrlCreateLabel("% der erf. Fläche.", 128, 800, 107, 20)
$Button1 = GUICtrlCreateButton("Bohrbild berechnen", 64, 832, 139, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$Group8 = GUICtrlCreateGroup("Drosselkurvenexponent", 264, 360, 345, 113, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT))
$Label33 = GUICtrlCreateLabel("Drosselkurvenexponent (0.5 ... 0.6)", 272, 392, 206, 20)
$Inp_NS = GUICtrlCreateInput($NS, 528, 390, 65, 24)
$Label34 = GUICtrlCreateLabel("norm. Wegendpunkt der Kurve (ca. 0.95)", 272, 416, 240, 20)
$Inp_SO = GUICtrlCreateInput($SO, 528, 414, 65, 24)
$Label55 = GUICtrlCreateLabel("Schrittweite (0.0001 ... 1.000 mm)", 272, 440, 191, 20)
$Inp_XD = GUICtrlCreateInput($XD, 528, 438, 65, 24)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$Group9 = GUICtrlCreateGroup("Anstiegsflanke", 264, 488, 345, 193, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT))
$Radio1 = GUICtrlCreateRadio("Anstriegsflanke berücksichtigen", 272, 544, 225, 17)
$Radio2 = GUICtrlCreateRadio("KEINE Anstiegsflanke berücksichtigen", 272, 520, 249, 17)
$Label35 = GUICtrlCreateLabel("Länge der Anstiegsflanke in mm", 288, 576, 194, 20)
$Inp_LA = GUICtrlCreateInput($LA, 528, 574, 65, 24)
$Label36 = GUICtrlCreateLabel("Anzahl Bohrungen in Anstiegsflanke", 288, 600, 216, 20)
$Inp_NA = GUICtrlCreateInput($NA, 528, 598, 65, 24)
$Label37 = GUICtrlCreateLabel("Länge der Zwischenflanke in mm", 288, 624, 198, 20)
$Inp_LZ = GUICtrlCreateInput($LZ, 528, 622, 65, 24)
$Label38 = GUICtrlCreateLabel("Anzahl Bohrungen in Zwischenflanke", 288, 648, 220, 20)
$Inp_NZ = GUICtrlCreateInput($NZ, 528, 646, 65, 24)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$Button2 = GUICtrlCreateButton("Puffer berechnen", 264, 688, 115, 25)
;$Button3 = GUICtrlCreateButton("Speichern", 532, 688, 75, 25)
$Button4 = GUICtrlCreateButton("Felder löschen", 428, 720, 99, 25)
$Button5 = GUICtrlCreateButton("Kennlinie berechnen", 264, 720, 155, 25)
$Button6 = GUICtrlCreateButton("Ende", 532, 720, 75, 25)
;$Button7 = GUICtrlCreateButton("Laden", 346, 720, 75, 25)

$Label39 = GUICtrlCreateLabel("Berechnung der Drosselkennlinie", 272, 752, 202, 20)
$Label40 = GUICtrlCreateLabel("von Hydraulikpuffern Typ LP", 272, 772, 172, 20)
$Label41 = GUICtrlCreateLabel("Nur fü�r Aufzugspuffer in stehender Anordnung !!!", 272, 800, 329, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label42 = GUICtrlCreateLabel("Copyright 2019 by R.Schmidt, D-58332 Schwelm", 272, 828, 286, 20)
$Label43 = GUICtrlCreateLabel($sVersion, 272, 848, 174, 20)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

; Vorgabe : Standardpuffer
If (GUICtrlRead($Radio3) = $GUI_UNCHECKED) And (GUICtrlRead($Radio4) = $GUI_UNCHECKED) Then
	GUICtrlSetState($Radio3, $GUI_CHECKED)
	GUICtrlSetState($Inp_DP, $GUI_ENABLE)
	GUICtrlSetState($Inp_SS, $GUI_ENABLE)
	GUICtrlSetState($Radio4, $GUI_UNCHECKED)
	GUICtrlSetState($Inp_LHR, $GUI_DISABLE)
	GUICtrlSetState($Inp_LMR, $GUI_DISABLE)
EndIf

; Vorgabe : KEINE Anstiegsflanke
If (GUICtrlRead($Radio1) = $GUI_UNCHECKED) And (GUICtrlRead($Radio2) = $GUI_UNCHECKED) Then
	GUICtrlSetState($Radio2, $GUI_CHECKED)
	GUICtrlSetState($Radio1, $GUI_UNCHECKED)
	GUICtrlSetState($Inp_LA, $GUI_DISABLE)
	GUICtrlSetState($Inp_NA, $GUI_DISABLE)
	GUICtrlSetState($Inp_LZ, $GUI_DISABLE)
	GUICtrlSetState($Inp_NZ, $GUI_DISABLE)
EndIf

While 1
	$nMsg = GUIGetMsg()

	Switch $nMsg

		Case $GUI_EVENT_CLOSE
			ProgrammEnde()

		Case $Radio1
			MitAnstiegsflanke()

		Case $Radio2
			OhneAnstiegsflanke()

		Case $Radio3
			Standardpuffer()

		Case $Radio4
			KeinStandardpuffer()

		Case $Button1
			BohrbildBerechnen()

		Case $Button2
			PufferBerechnen()

		Case $Button3
			; Speichern()

		Case $Button4
			FelderLoeschen()

		Case $Button5
			KennlinieBerechnen()

		Case $Button6
			ProgrammEnde()

		Case $Button7
			; Laden()

	EndSwitch
WEnd

Func CheckEingaben()
	; Standardpuffer
	If GUICtrlRead($Radio3) = $GUI_CHECKED Then
		$DP = i_GetNumber($Inp_DP)
		$SS = i_GetNumber($Inp_SS)
		$LHR = 0
		$LMR = 0
		If ($DP > 0) And ($SS > 0) Then
			$boBerechnen = True
			$boSpeichern = True
		Else
			$boBerechnen = False
			$boSpeichern = False
		EndIf
	EndIf

	; kein Standardpuffer
	If GUICtrlRead($Radio4) = $GUI_CHECKED Then
		$DP = 0
		$SS = 0
		$LHR = i_GetNumber($Inp_LHR)
		$LMR = i_GetNumber($Inp_LMR)
		If ($LHR > 0) And ($LMR > 0) Then
			$boBerechnen = True
			$boSpeichern = True
		Else
			$boBerechnen = False
			$boSpeichern = False
		EndIf
	EndIf

	$sDummy = "LA : " & $LA & @CRLF & "NA : " & $NA & @CRLF & "LZ : " & $LZ & @CRLF & "NZ : " & $NZ & @CRLF & @CRLF
	If (GUICtrlRead($Radio1) = $GUI_UNCHECKED) THEN
		$sDummy = $sDummy & "mit Anstiegsflanke : UNCHECKED" & @CRLF
	Else
		$sDummy = $sDummy & "mit Anstiegsflanke : CHECKED" & @CRLF
	EndIf
	If (GUICtrlRead($Radio2) = $GUI_UNCHECKED) THEN
		$sDummy = $sDummy & "KEINE Anstiegsflanke : UNCHECKED" & @CRLF
	Else
		$sDummy = $sDummy & "KEINE Anstiegsflanke : CHECKED" & @CRLF
	EndIf
	;MsgBox(0, "Info", $sDummy)

	; Auslegungsdaten des Puffers
	$Masse = i_GetNumber($Inp_Masse)
	$VNENN = i_GetNumber($Inp_VNENN)
	$PBAR = i_GetNumber($Inp_PBAR)

	If ($Masse > 0) And ($VNENN > 0) And ($PBAR >= 0) Then
		$boBerechnen = True
		$boSpeichern = True
	Else
		$boBerechnen = False
		$boSpeichern = False
	EndIf

	; Fabriknummer und Bemerkung
	$FAB = GUICtrlRead($Inp_FAB)
	$BEMERK = GUICtrlRead($Inp_BEMERK)

	$sDummy = "DP : <" & $DP & ">" & @CRLF & "SS : <" & $SS & ">" & @CRLF & "LHR : <" & $LHR & ">" & @CRLF & "LMR : <" & $LMR & ">" & @CRLF
	$sDummy = $sDummy & "Masse : <" & $Masse & ">" & @CRLF & "VNENN : <" & $VNENN & ">" & @CRLF
	If $boBerechnen = True Then
		$sDummy = $sDummy & "boBerechnen = TRUE" & @CRLF
	Else
		$sDummy = $sDummy & "boBerechnen = FALSE" & @CRLF
	EndIf
	If $boSpeichern = True Then
		$sDummy = $sDummy & "boSpeichern = TRUE" & @CRLF
	Else
		$sDummy = $sDummy & "boSpeichern = FALSE" & @CRLF
	EndIf

	; MsgBox(0,"CheckEingaben", $sDummy)
EndFunc

Func MitAnstiegsflanke()
	GUICtrlSetState($Radio2, $GUI_UNCHECKED)
	GUICtrlSetState($Radio1, $GUI_CHECKED)
	GUICtrlSetState($Inp_LA, $GUI_ENABLE)
	GUICtrlSetState($Inp_NA, $GUI_ENABLE)
	GUICtrlSetState($Inp_LZ, $GUI_ENABLE)
	GUICtrlSetState($Inp_NZ, $GUI_ENABLE)
EndFunc

Func OhneAnstiegsflanke()
	GUICtrlSetState($Radio2, $GUI_CHECKED)
	GUICtrlSetState($Radio1, $GUI_UNCHECKED)
	GUICtrlSetState($Inp_LA, $GUI_DISABLE)
	GUICtrlSetState($Inp_NA, $GUI_DISABLE)
	GUICtrlSetState($Inp_LZ, $GUI_DISABLE)
	GUICtrlSetState($Inp_NZ, $GUI_DISABLE)
EndFunc

Func Standardpuffer()
	GUICtrlSetState($Radio3, $GUI_CHECKED)
	GUICtrlSetState($Inp_DP, $GUI_ENABLE)
	GUICtrlSetState($Inp_SS, $GUI_ENABLE)
	GUICtrlSetState($Radio4, $GUI_UNCHECKED)
	GUICtrlSetState($Inp_LHR, $GUI_DISABLE)
	GUICtrlSetState($Inp_LMR, $GUI_DISABLE)
EndFunc

Func KeinStandardpuffer()
	GUICtrlSetState($Radio3, $GUI_UNCHECKED)
	GUICtrlSetState($Inp_DP, $GUI_DISABLE)
	GUICtrlSetState($Inp_SS, $GUI_DISABLE)
	GUICtrlSetState($Radio4, $GUI_CHECKED)
	GUICtrlSetState($Inp_LHR, $GUI_ENABLE)
	GUICtrlSetState($Inp_LMR, $GUI_ENABLE)
EndFunc

Func BohrbildBerechnen()
	If ($ADERF = 0) Or ($DDERF = 0) Or ($NGERF = 0) Then
		$sDummy = "Drosselfläche, Durchmesser und Anzahl Drosselbohrungen nicht bekannt !" & @CRLF & "Bitte erst einen 'Puffer berechnen'"
		MsgBox(0, "Fehler (Bohrbild)", $sDummy)
	Else
		$DD1 = i_GetNumber($Inp_DD1)
		$NG1 = i_GetNumber($Inp_NG1)
		$DD2 = i_GetNumber($Inp_DD2)
		$NG2 = i_GetNumber($Inp_NG2)
		$DD3 = i_GetNumber($Inp_DD3)
		$NG3 = i_GetNumber($Inp_NG3)
		$DD4 = i_GetNumber($Inp_DD4)
		$NG4 = i_GetNumber($Inp_NG4)

		$AD1 = $NG1 * $DD1 * $DD1 * $Pi4
		$AD2 = $NG2 * $DD2 * $DD2 * $Pi4
		$AD3 = $NG3 * $DD3 * $DD3 * $Pi4
		$AD4 = $NG4 * $DD4 * $DD4 * $Pi4

		$ADVOR = $AD1 + $AD2 + $AD3 + $AD4

		If ($ADERF <> 0) And ($ADVOR <> 0) Then
			$ADPRO = Round($ADVOR / $ADERF * 100, 2)

			If $ADPRO > 100 Then
				$ADPRO = Round($ADPRO, 1)
			EndIf

			$NG = $ADVOR / ($DD1 * $DD1 * $Pi4)					; Gleitkommazahl Anzahl der Bohrungen
			$NR = $NG - Int($NG)										; Nachkommastellen
		EndIf

		; Drosselkurvenexponent und Schrittweite
		$NS = i_GetNumber($Inp_NS)	; Drosselkurvenexponent
		$SO = i_GetNumber($Inp_SO)	; norm. Wedendpunkt

		FelderAnzeigen()
	EndIf

EndFunc

Func KennlinieBerechnen()
	Local $KD_l ; kleinste Durchmesser von den Drosselbohrungen ... also $DD2 oder $DD3 oder $DD4 (solange $DDx <> 0)
	Local $NG_l ; Anzahl aller Drosselbohrungen ... also $NG1 + $NG2 + $NG3 + $NG4
	Local $NR_l ; Anzahl aller Restbohrungen ($NG - $NG1); Restbohrungen sind alles außer Hauptbohrung ... also $NG2 + $NG3 + $NG4

	BohrbildBerechnen()
	If ($ADERF = 0) Or ($DDERF = 0) Or ($NGERF = 0) Then
		Return
	EndIf

	If ($AD1 = 0) Or ($DD1 = 0) Or ($NG1 = 0) Then
		$sDummy = "Mind. 1 Durchmesser und Anzahl für Drosselbohrung angeben !" & @CRLF & "Bitte erst ein 'Bohrbild berechnen'"
		MsgBox(0, "Fehler (Bohrbild)", $sDummy)
		Return
	EndIf

	$KD_l = $DD1
	If ($DD2 < $KD_l) And ($DD2 <> 0) Then $KD_l = $DD2
	If ($DD3 < $KD_l) And ($DD3 <> 0) Then $KD_l = $DD3
	If ($DD4 < $KD_l) And ($DD4 <> 0) Then $KD_l = $DD4
	$NG_l = $NG1 + $NG2 + $NG3 + $NG4					; Anzahl aller Bohrungen
	$NR_l = $NG2 + $NG3 + $NG4								; Anzahl aller Restbohrungen

	$NG = $ADVOR / ($DD1 * $DD1 * $Pi4)					; Gleitkommazahl Anzahl der Bohrungen
	$NR = $NG - Int($NG)										; Nachkommastellen
	;MsgBox(0, "Info", "NR : " & $NR & @CRLF & "NG : " & $NG & @CRLF & "NR_l : " & $NR_l & @CRLF & "NG_l : " & $NG_l)

	$DXPR = $XD / 100											; Fehlergrenze fü�r Abfrage Werte drucken
	$FO = 1														; oberer Funktionswert
	$FU = Round($NR / $NG, 3)								; unterer Funktionswert
	$SA = $LA / $SS											; rel. Länge Anstriegsflanke
	$SZ = $LZ / $SS											; rel. Länge Zwischenflanke

	;$ADO = $DDERF * $DDERF / 1000000 * $Pi4 * $NG_l
	;$ADU = $DDERF * $DDERF / 1000000 * $Pi4 * $NR_l
	$ADO = $ADVOR / 1000000									; Gesamtfläche Drosselbohrungen
	$ADU = ($ADVOR - $AD1) / 1000000						; Gesamtfläche Drosselbohrung der Restbohrungen
	$ADA = $DD1 * $DD1 / 1000000 * $Pi4 * $NA			; Anstiegsflanke
	$ADZ = $DD1 * $DD1 / 1000000 * $Pi4 * $NZ			; Zwischenflanke
	$DAD = $ADO - $ADU - $ADA - $ADZ						; entspricht $AD1 (Fläche der Hauptbohrungen)
	$ZRA = $ZETA * $RHO / 2 * $A1 * $A1
	$V0 = ($A2 * $HGAS / 1000) + $V0KOPF				; Gasvolumen in m3
	$VGAS = Round($V0 * 1000, 2)							; Gasvolumen in l

	;FileWriteLine($hFile, " ")
	;FileWriteLine($hFile, "AD1 : " & $AD1)
	;FileWriteLine($hFile, "NG1 : " & $NG1)
	;FileWriteLine($hFile, "DD1 : " & $DD1)
	;FileWriteLine($hFile, "AD2 : " & $AD2)
	;FileWriteLine($hFile, "NG2 : " & $NG2)
	;FileWriteLine($hFile, "DD2 : " & $DD2)
	;FileWriteLine($hFile, "AD3 : " & $AD3)
	;FileWriteLine($hFile, "NG3 : " & $NG3)
	;FileWriteLine($hFile, "DD3 : " & $DD3)
	;FileWriteLine($hFile, "AD4 : " & $AD4)
	;FileWriteLine($hFile, "NG4 : " & $NG4)
	;FileWriteLine($hFile, "DD4 : " & $DD4)

	;FileWriteLine($hFile, " ")
	;FileWriteLine($hFile, "ADERF : " & $ADERF & " mm")
	;FileWriteLine($hFile, "ADVOR : " & $ADVOR & " mm")
	;FileWriteLine($hFile, "NGERF : " & $NGERF)
	;FileWriteLine($hFile, "DDERF in mm : " & $DDERF)

	;FileWriteLine($hFile, " ")
	;FileWriteLine($hFile, "Fehlergrenze : " & $DXPR)
	;FileWriteLine($hFile, "SA : " & $SA)
	;FileWriteLine($hFile, "SZ : " & $SZ)
	;FileWriteLine($hFile, "ADO : " & $ADO)
	;FileWriteLine($hFile, "ADU : " & $ADU)
	;FileWriteLine($hFile, "ADA : " & $ADA)
	;FileWriteLine($hFile, "ADZ : " & $ADZ)
	;FileWriteLine($hFile, "DAD : " & $DAD)
	;FileWriteLine($hFile, "ZRA : " & $ZRA)

	; Abstand der Druckwerte ausrechnen
	$XPR = (1 + Int(($SS - 5) / 200)) * 5
	If $SS <= 80 THEN $XPR = 2
	If $SS <= 40 THEN $XPR = 1

	; "Kraft-Weg-Verlauf wird gedruckt"
	; Datei öffnen zum (über)schreiben
	$hFile = FileOpen($DATEINAME, 2)
	$sDatum = @MDAY & "." & @MON & "." & @YEAR

	Kopfdrucken()

	; Anfangswerte
	$VPX = $VP
	$FPX1 = 0
	$EKINX1 = $EKIN
	$AXI = 0

	; Energie & Zeit
	$EUM = 0
	$T = 0

	; Spitzenwerte
	$FPMAX = 0
	$XFPMAX = 0
	$AMAX = 0
	$XAMAX = 0

	$ANSTFL = 2
	$SYSTEM = ", beschleunigungsfähiges System" ; Parameter klärt Beschleunigungsverhalten in der Anstiegsflanke - 2 = beschleunigungsfähig
	$XSCHWING = 0
	$SCHWING = 0  	; Parameter zur Schwingungserkennung bei zu großer Schrittweite

	FSVerlauf() 	; Kraft-Weg-Verlauf rechnen

	If $SCHWING = 1 Then
		MsgBox(0, "Info", "Es empfiehlt sich mit verringerter Schrittweite die Berechnung zu wiederholen !" & @CRLF & "Es treten Schwingungen auf !")
	Else
		MsgBox(0, "Info", "Fertig !")
	EndIf

	BohrbildDrucken()

	FileClose($hFile)
EndFunc

Func PufferBerechnen()
	CheckEingaben()

	If ($boBerechnen = False) Or ($boSpeichern = False) Then
		$sDummy = "Bitte folgende Parameter korrekt angeben :" & @CRLF
		If GUICtrlRead($Radio3) = $GUI_CHECKED Then
			$sDummy = $sDummy & "- Pufferdurchmesser in mm" & @CRLF & "- Pufferhub in mm" & @CRLF
		EndIf
		If GUICtrlRead($Radio4) = $GUI_CHECKED Then
			$sDummy = $sDummy & "- Außenlänge des Hydraulikrohrs in mm" & @CRLF & "- Außenlänge des Mantelrohrs in mm" & @CRLF
		EndIf
		$sDummy = $sDummy & "- aufprallende Masse in kg" & @CRLF & "- Nenngeschwindigkeit in m/s"
		MsgBox(0, "Fehler (Pufferwahl)", $sDummy)

		$ADERF = 0
		$DDERF = 0
		$NGERF = 0
		$EGES = 0
		$FPMAX = 0

		FelderAnzeigen()
	Else
		; Pufferwahl Anfang
		$SM = $SS / 1000
		$LMR = 0		; Gasrohrlänge auf 0 setzen

		; Datensätze zu LP 40 / LP 50 einlesen
		i_GetDP_Daten()
		; Anstiegsflanke(n) vorhanden --> Radiobutton setzen
		If ($LA <> 0) And ($LZ <> 0) Then
			GUICtrlSetState($Radio2, $GUI_UNCHECKED)
			GUICtrlSetState($Radio1, $GUI_CHECKED)
			GUICtrlSetState($Inp_LA, $GUI_ENABLE)
			GUICtrlSetState($Inp_NA, $GUI_ENABLE)
			GUICtrlSetState($Inp_LZ, $GUI_ENABLE)
			GUICtrlSetState($Inp_NZ, $GUI_ENABLE)
		EndIf

		; mit Anstiegsflanke
		If (GUICtrlRead($Radio1) = $GUI_CHECKED) And (GUICtrlRead($Radio2) = $GUI_UNCHECKED) Then
			If ($LA < 0) Or ($LA > (0.8 * $SS)) Then
				MsgBox(0, "Fehler - Länge Anstiegsflanke", "Unzulässige Eingabe !" & @CRLF & "Bitte nur Werte von 0 bis " & StringFormat($SS * 0.8, "%.3f") & " nehmen.")
				$LA = 0
			EndIf

			If ($LA <> 0 ) And (($NA < 0) Or ($NA > ($NG - $NR))) Then
				MsgBox(0, "Fehler - Anzahl Bohrungen in der Anstiegsflanke", "Unzulässige Eingabe !" & @CRLF & "Bitte nur Werte von 0 bis " & StringFormat($NG - $NR, "%.3f") & " nehmen.")
				$NA = 0
			EndIf

			If ($LZ < 0) Or ($LZ > (0.8 * $SS)) Then
				MsgBox(0, "Fehler - Länge Zwischenflanke", "Unzulässige Eingabe !" & @CRLF & "Bitte nur Werte von 0 bis " & StringFormat($SS * 0.8, "%.3f") & " nehmen.")
				$LZ = 0
			EndIf

			If ($LZ <> 0) And (($NZ < 0) Or ($NZ > ($NG - $NR))) Then
				MsgBox(0, "Fehler - Anzahl Bohrungen in der Zwischenflanke", "Unzulässige Eingabe !" & @CRLF & "Bitte nur Werte von 0 bis " & StringFormat($NG - $NR, "%.3f") & " nehmen.")
				$NZ = 0
			EndIf
		EndIf

		If Abs($DP - $D1 * 1000) < .001 THEN
			$A1 = $D1 * $D1 * $Pi4							; Hydraulikquerschnitt in m2
			$A2 = ($D3 * $D3 - $D2 * $D2) * $Pi4		; Gasquerschnitt in m2
			$AKS = $DKS * $DKS * $Pi4						; Kolbenstangenfläche in m2

			IF ($LMR = 0) Or ($LMR <= $SS) THEN
				$sDummy = "der gewählte Puffer ist kein Standardhub !" & @CRLF & "Hub : " & $LMR & @CRLF & "Bitte anderen Puffer wählen." & @CRLF & "(KEIN Standardpuffer)"
				MsgBox(0, "Fehler (Hub)", $sDummy)
				Return
			EndIf

		Else
			$sDummy = "Pufferdurchmesser ungültig !" & @CRLF & "DP : " & $DP & @CRLF & "Bitte anderen Puffer wählen." & @CRLF & "(KEIN Standardpuffer)"
			MsgBox(0, "Fehler (Durchmesser)", $sDummy)
			Return
		EndIf ; Pufferauswahl Ende

		; Federkonstante Anstiegsflanke
		$CON = $A1 * 1000000 / $SS * $EERSATZ
		$CON = Int($CON / 100 + 0.5) * 100

		; Aufprallgeschwindigkeit
		$VP = $VFAKT * $VNENN

		; Vortriebskraft in N
		$B0 = $Masse * $G0; Vortriebskraft in N
		$B1 = 0
		$B2 = 0

		; Energie ermitteln
		$EKIN = 0.5 * $Masse * $VP * $VP																			; Ekin in Nm
		$EPOT = ($B0 * $SM) + (0.5 * $B1 * $SM * $SM) + (0.33333333 * $B2 * $SM * $SM * $SM)	; Epot in Nm
		$EGES = Round($EKIN + $EPOT)
		$FPMAX = Int($K * ($EKIN + $EPOT) / $SM)
		;$FPMAX = Round($K * ($EKIN + $EPOT) / $SM)

		$sDummy = "Flanke : " & $CON & @CRLF & "Aufprallgeschw. : " & $VP & @CRLF & "Masse : " & $Masse & @CRLF & "EKIN : " & $EKIN & @CRLF
		$sDummy = $sDummy & "EPOT : " & $EPOT & @CRLF & "EGES : " & $EGES & @CRLF & "FPMAX : " & $FPMAX & @CRLF
		$sDummy = $sDummy & "VFAKT : " & $VFAKT & @CRLF & "VNENN : " & $VNENN & @CRLF
		; MsgBox(0, "Info (Energie)", $sDummy)

		; Gasdruck in N/m2 ermitteln
		$P0 = $PBAR * 100000		; Gasdruck in N/m2
		$FDYN = ($EKIN + $EPOT) / $SM

		;ADERF = VP * A1 * SQR(ZETA * RHO * A1 / 2 / FDYN): REM erf. Drosselfl„che in m2
		;NG = INT(.07 * S + .5): REM Vorschlag Gesamtzahl der Bohrungen
		;DDM = SQR(ADERF / PI4 / NG): REM Drosselbohrung in m
		;DD = INT(DDM * 10000 + .5) / 10: REM Drosselbohrung in mm
		;IF DD > 1.8 THEN LET DD = 1.8
		;IF DD < 1 THEN LET DD = 1!
		;NGERF = ADERF / (DD * DD * PI4) * 1000000!: REM erf. Bohrungszahl
		;NG = INT(NGERF * 10 + .5) / 10
		;PRINT : PRINT "Drosselrohrbohrbild: Bohrungs-í "; DD; " mm, "; NG; " Bohrungen"
		;PRINT : PRINT "Bitte w„hlen Sie:"
		;INPUT "Drosselbohrungs-í in mm: "; DD
		;NGERF = ADERF / (DD * DD * PI4) * 1000000!: REM erf. Bohrungszahl
		;NG = INT(NGERF * 10 + .5) / 10

		; erforderl. Drosselfläche, Bohrungsdurchmesser und Anzahl der Bohrungen ermitteln
		$ADERF = $VP * $A1 * Sqrt($ZETA * $RHO * $A1 / 2 / $FDYN)	; erf. Drosselfläche in m2
		$NGERF = 0.07 * $SS														; Vorschlag Bohrungsanzahl (gesamt) nach der 7%-Regel
		$DDERF = Sqrt($ADERF / $Pi4 / $NGERF) * 1000						; Durchmesser Drosselbohrung in mm
		$ADERF = $ADERF * 1000000												; erf. Drosselfläche in mm2

		$sDummy = "ADERF (mm2) : " & Round($ADERF, 3) & @CRLF & "NGERF : " & $NGERF & @CRLF & "DDERF (mm) : " & $DDERF & @CRLF & @CRLF

		If $DDERF > 1.8 Then $DDERF = 1.8									; Durchmesser Drosselbohrung neu
		If $DDERF < 1 Then $DDERF = 1

		$NGERF = $ADERF / ($DDERF * $DDERF * $Pi4)						; erf. Bohrungszahl nach Drosselfläche und Durchmessergröße

		$sDummy = $sDummy & "ADERF (mm2) : " & Round($ADERF, 3) & @CRLF & "NGERF : " & $NGERF & @CRLF & "DDERF (mm) : " & $DDERF
		; MsgBox(0, "Info (Drosselbohrungen)", $sDummy)

		; Drosselkurvenexponent und Schrittweite
		If $NS = 0 Then
			$NS = i_GetNumber($Inp_NS)	; Drosselkurvenexponent
		EndIf
		If $SO = 0 Then
			$SO = i_GetNumber($Inp_SO)	; norm. Wedendpunkt
		EndIf

		If $SO <> 0 Then
			If ($SO > 1) Or ($SO < 0.8) Then
				$sDummy = "norm. Wegendpunkt muss zwischen 0.8 und 1.0 liegen !" & @CRLF & "Bitte korrigieren."
				MsgBox(0, "Fehler (norm. Wegendpunkt)", $sDummy)
			EndIf
		EndIf

		; Schrittweite überprüfen
		$XD = 0.02 ; Schrittweite in mm
		If $SS > 200 Then $XD = 0.05
		If $SS > 700 Then $XD = 0.1

		$sDummy = ""
		If $VP < 0.61 Then ; eventuell Schrittweite verkleinern ?
			$sDummy = "geringe Aufprallgeschwindikeit (" & $VP & "m/s) !!"
		EndIf

		;If ($B0 / $Masse) > 4 Then ; eventuell Schrittweite verkleinern ?
		;	$sDummy = "Verhältnis Vortriebskraft zur Masse sehr hoch !!" & @CRLF
		;	$sDummy = $sDummy & "Vortriebskraft / Masse = " & Round($B0/$Masse, 3)
		;EndIf
		;
		; normalerweise ist $B0 = M * G0 (Erdanziehung mit 9,81 m/s2 --> $B0 / M ist 9,81 ... und somit IMMER größer 4 !!
		; was soll dann die Abfrage ??? macht keinen Sinn ...

		If $SCHWING = 1 Then ; eventuell Schrittweite verkleinern ?
			$sDummy = "wir haben Schwingungen !!"
		EndIf

		If $sDummy <> "" Then
			$sDummy = $sDummy & @CRLF & @CRLF & "eventuell Schrittweite verkleinern ?" & @CRLF & @CRLF
			$sDummy = $sDummy & "Schrittweite von 0.0001 mm ... 1.0 mm möglich !" & @CRLF & "Bei Bedarf bitte anpassen."
			MsgBox(0, "Info (Schrittweite)", $sDummy)
		EndIf

		FelderAnzeigen()

	EndIf
EndFunc

Func Speichern()
	Local $MyDocsFolder = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}"
	Local $ZielDatei = FileSaveDialog("Speichern - Bitte Dateiname wählen...", $MyDocsFolder, "(*.txt)")
	Local $hFile1_l, $hFile2_l, $sDummy_l, $i

	If @error Then
		MsgBox(0, "Speichern", "Speichern abgebrochen.")
	Else
		$hFile1_l = FileOpen($ZielDatei, 2)
		FileWriteLine($hFile1_l, $FAB)
		FileWriteLine($hFile1_l, $BEMERK)
		FileWriteLine($hFile1_l, $sDatum)
		FileWriteLine($hFile1_l, $DP)
		FileWriteLine($hFile1_l, $SS)
		FileWriteLine($hFile1_l, $LHR)
		FileWriteLine($hFile1_l, $LMR)
		FileWriteLine($hFile1_l, $Masse)
		FileWriteLine($hFile1_l, $VNENN)
		FileWriteLine($hFile1_l, $PBAR)
		FileWriteLine($hFile1_l, $DD1)
		FileWriteLine($hFile1_l, $NG1)
		FileWriteLine($hFile1_l, $AD1)
		FileWriteLine($hFile1_l, $DD2)
		FileWriteLine($hFile1_l, $NG2)
		FileWriteLine($hFile1_l, $AD2)
		FileWriteLine($hFile1_l, $DD3)
		FileWriteLine($hFile1_l, $NG3)
		FileWriteLine($hFile1_l, $AD3)
		FileWriteLine($hFile1_l, $DD4)
		FileWriteLine($hFile1_l, $NG4)
		FileWriteLine($hFile1_l, $AD4)
		FileWriteLine($hFile1_l, $NS)
		FileWriteLine($hFile1_l, $SO)
		FileWriteLine($hFile1_l, $LA)
		FileWriteLine($hFile1_l, $LZ)
		FileWriteLine($hFile1_l, $NA)
		FileWriteLine($hFile1_l, $NZ)

		;If FileExists($DATEINAME) Then
		;	$hFile2_l = FileOpen($DATEINAME, 0)
		;	For $i = 1 To UBound($hFile2_l)
		;		$sDummy_l = FileReadLine($DATEINAME)
		;		FileWriteLine($hFile1_l, $sDummy_l)
		;	Next
		;	FileClose($hFile2_l)
		;EndIf

		FileClose($hFile1_l)

		MsgBox(0, "Speichern", "Fertig !" & @CRLF & $ZielDatei)
	EndIf

EndFunc

Func Laden()
	Local $MyDocsFolder = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}"
	Local $QuellDatei = FileOpenDialog("Laden - Bitte Datei auswählen...", $MyDocsFolder & "\", "(*.txt)")
	Local $hFile_l

	If @error Then
		MsgBox(0, "Laden", "Laden abgebrochen.")
	Else
		FelderLoeschen()
		$hFile_l = FileOpen($QuellDatei)
		FileReadLine($hFile_l, $FAB)
		FileReadLine($hFile_l, $BEMERK)
		FileReadLine($hFile_l, $sDatum)
		FileReadLine($hFile_l, $DP)
		FileReadLine($hFile_l, $SS)
		FileReadLine($hFile_l, $LHR)
		FileReadLine($hFile_l, $LMR)
		FileReadLine($hFile_l, $Masse)
		FileReadLine($hFile_l, $VNENN)
		FileReadLine($hFile_l, $PBAR)
		FileReadLine($hFile_l, $DD1)
		FileReadLine($hFile_l, $NG1)
		FileReadLine($hFile_l, $AD1)
		FileReadLine($hFile_l, $DD2)
		FileReadLine($hFile_l, $NG2)
		FileReadLine($hFile_l, $AD2)
		FileReadLine($hFile_l, $DD3)
		FileReadLine($hFile_l, $NG3)
		FileReadLine($hFile_l, $AD3)
		FileReadLine($hFile_l, $DD4)
		FileReadLine($hFile_l, $NG4)
		FileReadLine($hFile_l, $AD4)
		FileReadLine($hFile_l, $NS)
		FileReadLine($hFile_l, $SO)
		FileReadLine($hFile_l, $LA)
		FileReadLine($hFile_l, $LZ)
		FileReadLine($hFile_l, $NA)
		FileReadLine($hFile_l, $NZ)
		FileClose($hFile_l)

		; MsgBox(0, "Laden", "Fertig !" & @CRLF & $QuellDatei)
		FelderAnzeigen()
	EndIf

EndFunc

Func FelderLoeschen()
	$DP = 0			; Pufferdurchmesser (mm)
	$SS = 0			; Pufferhub (mm)

	$LHR = 0			; Länge Hydraulikrohr (mm)
	$LMR = 0			; Länge Mantelrohr (mm)

	$Masse = 0		; Masse (kg)
	$VNENN = 0		; Nenngeschwindigkeit (m/s)
	$PBAR = 0		; Gasdruck (bar)

	$EGES = 0		; Gesamt-Energie (Nm)
	$FPMAX = 0		; max. Pufferkraft (N)

	$FAB = ""		; Fabrikationsnummer
	$BEMERK = ""	; Bemerkungen

	$ADERF = 0		; erforderliche Drosselfläche in m²
	$DDERF = 0		; Vorschlag Bohrungsdurchmesser Drosselbohrung
	$NGERF = 0		; Vorschlag Anzahl Drosselbohrungen
	$DD1 = 0			; 1. Bohrungsdurchmesser Drosselbohrung in mm
	$NG1 = 0			; Anzahl Bohrungen von $DD1
	$AD1 = 0			; Teilfläche aus $DD1 * $NG1
	$DD2 = 0			; 2. Bohrungsdurchmesser Drosselbohrung in mm
	$NG2 = 0			; Anzahl Bohrungen von $DD2
	$AD2 = 0			; Teilfläche aus $DD2 * $NG2
	$DD3 = 0			; 3. Bohrungsdurchmesser Drosselbohrung in mm
	$NG3 = 0			; Anzahl Bohrungen von $DD3
	$AD3 = 0			; Teilfläche aus $DD3 * $NG3
	$DD4 = 0			; 4. Bohrungsdurchmesser Drosselbohrung in mm
	$NG4 = 0			; Anzahl Bohrungen von $DD4
	$AD4 = 0			; Teilfläche aus $DD4 * $NG4
	$ADVOR = 0		; vorhandene Drosselfläche in m² ($AD1 ... $AD4)
	$ADPRO = 0		; Prozente

	$NS = 0			; Drosselkurvenexponent
	$SO = 0			; Wegendpunkt der Drosselkurve
	$XD = 0			; Schrittweite (0.0001 ... 1.000)

	$LA = 0			; Länge Anstiegsflanke
	$LZ = 0			; Länge Zwischenflanke
	$NA = 0			; Anzahl Drosselbohrungen von nG in der Anstiegsflanke
	$NZ = 0			; Anzahl Drosselbohrungen von nG in der Zwischenflanke

	FelderAnzeigen()
EndFunc

Func FelderAnzeigen()
	GUICtrlSetData($Inp_DP, $DP)
	GUICtrlSetData($Inp_SS, $SS)
	GUICtrlSetData($Inp_LHR, $LHR)
	GUICtrlSetData($Inp_LMR, $LMR)
	GUICtrlSetData($Inp_Masse, $Masse)
	GUICtrlSetData($Inp_VNENN, i_ZahlKomma($VNENN))
	GUICtrlSetData($Inp_PBAR, i_ZahlKomma($PBAR))
	GUICtrlSetData($Label44, i_ZahlPunkt($EGES))
	GUICtrlSetData($Label45, i_ZahlPunkt($FPMAX))
	GUICtrlSetData($Inp_FAB, $FAB)
	GUICtrlSetData($Inp_BEMERK, $BEMERK)
	GUICtrlSetData($Label46, i_ZahlKomma(Round($ADERF, 3)))
	GUICtrlSetData($Label47, i_ZahlKomma(Round($DDERF, 3)))
	GUICtrlSetData($Label48, i_ZahlKomma(Round($NGERF, 3)))
	GUICtrlSetData($Inp_DD1, i_ZahlKomma($DD1))
	GUICtrlSetData($Inp_NG1, $NG1)
	GUICtrlSetData($Label49, i_ZahlKomma(Round($AD1, 3)))
	GUICtrlSetData($Inp_DD2, i_ZahlKomma($DD2))
	GUICtrlSetData($Inp_NG2, $NG2)
	GUICtrlSetData($Label50, i_ZahlKomma(Round($AD2, 3)))
	GUICtrlSetData($Inp_DD3, i_ZahlKomma($DD3))
	GUICtrlSetData($Inp_NG3, $NG3)
	GUICtrlSetData($Label51, i_ZahlKomma(Round($AD3, 3)))
	GUICtrlSetData($Inp_DD4, i_ZahlKomma($DD4))
	GUICtrlSetData($Inp_NG4, $NG4)
	GUICtrlSetData($Label52, i_ZahlKomma(Round($AD4, 3)))
	GUICtrlSetData($Label53, i_ZahlKomma(Round($ADVOR, 3)))
	GUICtrlSetData($Label54, i_ZahlKomma(Round($ADPRO, 2)))
	GUICtrlSetData($Inp_NS, i_ZahlKomma($NS))
	GUICtrlSetData($Inp_SO, i_ZahlKomma($SO))
	GUICtrlSetData($Inp_XD, i_ZahlKomma($XD))
	GUICtrlSetData($Inp_LA, i_ZahlKomma($LA))
	GUICtrlSetData($Inp_NA, i_ZahlKomma($NA))
	GUICtrlSetData($Inp_LZ, i_ZahlKomma($LZ))
	GUICtrlSetData($Inp_NZ, i_ZahlKomma($NZ))
	GUISetState(@SW_SHOW)
EndFunc

Func ProgrammEnde()
	Exit
EndFunc

Func BohrbildDrucken()
	$sText = ""

	$N1 = 1 / $NS
	$NE = $NG - $NR
	$FO2 = $FO * ($NG - $NA - $NZ) / $NG ; Reduzierung bei Anstiegsflanke

	$DFN = ($FO2 - $FU) / ($NE - $NA - $NZ)
	$XOFF = $COFF + $SS ; Offsetlänge

	FileWriteLine($hFile, " ")
	FileWriteLine($hFile, " ")
	FileWriteLine($hFile, " ")

	$sText = "*** Henning GmbH, D-58332 Schwelm ***" & StringLeft($sLeer, 70 - 37 - StringLen($sVersion)) & $sVersion
	FileWriteLine($hFile, $sText)

	FileWriteLine($hFile, "Pufferauslegung mit Programm LP am " & $sDatum)

	FileWriteLine($hFile, " ")

	FileWriteLine($hFile, "*** Bohrbild der Drosselbohrungen ***")

	$sText = "LP " & $DP & "/" & $SS & " *** Fabr.-Nr.: "
	$sText = StringLeft($sText & $FAB, 70)
	FileWriteLine($hFile, $sText)

	FileWriteLine($hFile, "**********************************************************************")

	$sText = "Länge Hydraulikrohr = " & $LHR & " mm "
	If StringLen($BEMERK) > 0 Then $sText = StringLeft($sText & "; " & $BEMERK, 70)
	FileWriteLine($hFile, $sText)

	FileWriteLine($hFile, " ")

	FileWriteLine($hFile, "*** Auslegungsdaten des Puffers: ***")

	$sText = "aufprallende Masse       M = " & $Masse & " kg"
	$sText = StringLeft($sText & $sLeer, 41) & "Vortriebskraft FV = " & $B0 & " N"
	FileWriteLine($hFile, $sText)

	$sText = "Nenngeschwindigkeit  vNenn = " & $VNENN & " m/s"
	$sText = StringLeft($sText & $sLeer, 41) & "Aufprallgeschw.v1 = " & $VP & " m/s"
	FileWriteLine($hFile, $sText)

	$sText = "Gasdruck                p0 = " & $PBAR & " bar"
	$sText = StringLeft($sText & $sLeer, 41) & "Gasvolumen     V0 = " & $VGAS & " l"
	FileWriteLine($hFile, $sText)

	$sText = "Durchm. Drosselbohrung  dD = " & $DD1 & " mm"
	$sText = StringLeft($sText & $sLeer, 41) & "Anzahl : " & $NG1
	FileWriteLine($hFile, $sText)

	FileWriteLine($hFile, "Restbohrungen R1: "&$NG2&" Ø "&$DD2&" mm ; "&"R2: "&$NG3&" Ø "&$DD3&" mm ; "&"R3: "&$NG4&" Ø "&$DD4&" mm")
	FileWriteLine($hFile, "Bohrungen:   Gesamtzahl ng = " & $NG1 + $NG2 + $NG3 + $NG4)

	$sText = "Drosselkurvenexponent   nS = " & $NS
	$sText = StringLeft($sText & $sLeer, 41) & "norm. Wegendpunkt  so = " & $SO
	FileWriteLine($hFile, $sText)

	If (($LA = 0) And ($LZ = 0)) Then
		$sText = "unterer Funktionswert   fu = " & $FU
		$sText = StringLeft($sText & $sLeer, 41) & "oberer Funktionsw. fo = " & $FO
		FileWriteLine($hFile, $sText)
	EndIf

	If $LA <> 0 Then
		$sText = "Anstiegsflanke Länge    lA = " & $LA & " mm"
		$sText = StringLeft($sText & $sLeer, 41) & "Anzahl Bohrungen   nA = " & $NA
		FileWriteLine($hFile, $sText)
	EndIf

	If $LZ <> 0 Then
		$sText = "Zwischenflanke Länge    lZ = " & $LZ & " mm"
		$sText = StringLeft($sText & $sLeer, 41) & "Anzahl Bohrungen   nZ = " & $NZ
		FileWriteLine($hFile, $sText)
	EndIf

	FileWriteLine($hFile, "")
	FileWriteLine($hFile, "Bohrung Nr.     Bohrkoordinate x in mm      x rel")
	;                               1         2         3         4         5         6
	;                      123456789012345678901234567890123456789012345678901234567890
	FileWriteLine($hFile, "----------------------------------------------------")
	; Berechnung der Lage der Bohrungen

	; BohrungenAnstieg:
	If $NA <> 0 Then
		For $NI = 1 To $NA
			$XIB = $SA / $NA * ($NI - 0.5)
			$XA = $XIB * $SS ; Bohrkoordinate ab Hubanfang
			$XIB = Int($XIB * 1000 + .5) / 1000 ; rel. Hubkoordinate
			$XBOHR = $XOFF - $XA ; Bohrkoordinate ab Hydraulikrohrende
			$XBOHR = Int($XBOHR * 100 + .5) / 100
			$sText = StringRight($sLeer & $NI, 9) & StringRight($sLeer & StringFormat("%.2f", $XBOHR), 26) & StringRight($sLeer & StringFormat("%.3f", $XIB), 13)
			FileWriteLine($hFile, $sText)
			;If $NG > 45 And $NI = 40 Then Umbruch()
			;If $NG > 98 And $NI = 95 Then Umbruch()
		Next
	EndIf

	; BohrungenZflanke:
	If $NZ <> 0 Then
		For $NI = ($NA + 1) To ($NA + $NZ)
			$XIB = $SA + $SZ / $NZ * ($NI - 0.5)
			$XA = $XIB * $SS ; Bohrkoordinate ab Hubanfang
			$XIB = Int($XIB * 1000 + .5) / 1000 ; rel. Hubkoordinate
			$XBOHR = $XOFF - $XA ; Bohrkoordinate ab Hydraulikrohrende
			$XBOHR = Int($XBOHR * 100 + .5) / 100
			$sText = StringRight($sLeer & $NI, 9) & StringRight($sLeer & StringFormat("%.2f", $XBOHR), 26) & StringRight($sLeer & StringFormat("%.3f", $XIB), 13)
			FileWriteLine($hFile, $sText)
			;If $NG > 45 And $NI = 40 Then Umbruch()
			;If $NG > 98 And $NI = 95 Then Umbruch()
		Next
	EndIf

	; Hauptbohrungen:
	For $NI = ($NA + $NZ + 1) To $NE
		$FI = $FO2 - ($NI - $NA - $NZ - 0.5) * $DFN
		$FQ = ($FI - $FU) / ($FO2 - $FU)
		$XIB = ($SO - $SA - $SZ) * (1 - $FQ ^ $N1) + $SA + $SZ
		$XA = $XIB * $SS				; Bohrkoordinate ab Hubanfang
		$XIB = Int($XIB * 1000 + .5) / 1000
		$XBOHR = $XOFF - $XA			; Bohrkoordinate ab Hydraulikrohrende
		$XBOHR = Int($XBOHR * 100 + .5) / 100
		$sText = StringRight($sLeer & $NI, 9) & StringRight($sLeer & StringFormat("%.2f", $XBOHR), 26) & StringRight($sLeer & StringFormat("%.3f", $XIB), 13)
		FileWriteLine($hFile, $sText)
		;If $NG > 45 And $NI = 40 Then Umbruch()
		;If $NG > 98 And $NI = 95 Then Umbruch()
	Next

	IF ($DD2 <> 0) And ($NG2 <> 0) Then
		For $NI = 1 To $NG2
			$XBOHR = $CHR     ; Konstante ab Hydraulikrohrende
			$XA = $XOFF - $XBOHR
			$XIB = Int($XA / $SS * 1000 + 0.5) / 1000
			FileWriteLine($hFile, "Restbohrung R1 : " & $NG2 & " Ø " & $DD2 & " mm")
			$sText = StringRight($sLeer & ($NG1 + $NI), 9) & StringRight($sLeer & StringFormat("%.2f", $XBOHR), 26) & StringRight($sLeer & StringFormat("%.3f", $XIB), 13)
			FileWriteLine($hFile, $sText)
		Next
	EndIf

	IF ($DD3 <> 0) And ($NG3 <> 0) Then
		For $NI = 1 To $NG3
			$XBOHR = $CHR     ; Konstante ab Hydraulikrohrende
			$XA = $XOFF - $XBOHR
			$XIB = Int($XA / $SS * 1000 + 0.5) / 1000
			FileWriteLine($hFile, "Restbohrung R1 : " & $NG2 & " Ø " & $DD2 & " mm")
			$sText = StringRight($sLeer & ($NG1 + $NG2 + $NI), 9) & StringRight($sLeer & StringFormat("%.2f", $XBOHR), 26) & StringRight($sLeer & StringFormat("%.3f", $XIB), 13)
			FileWriteLine($hFile, $sText)
		Next
	EndIf

	IF ($DD4 <> 0) And ($NG4 <> 0) Then
		For $NI = 1 To $NG4
			$XBOHR = $CHR     ; Konstante ab Hydraulikrohrende
			$XA = $XOFF - $XBOHR
			$XIB = Int($XA / $SS * 1000 + 0.5) / 1000
			FileWriteLine($hFile, "Restbohrung R1 : " & $NG2 & " Ø " & $DD2 & " mm")
			$sText = StringRight($sLeer & ($NG1 + $NG2 + $NG3 + $NI), 9) & StringRight($sLeer & StringFormat("%.2f", $XBOHR), 26) & StringRight($sLeer & StringFormat("%.3f", $XIB), 13)
			FileWriteLine($hFile, $sText)
		Next
	EndIf

	;While 1
	;	If $NR = 0 Then ExitLoop ; GOTO Seitenvorschub1     ; Koordinaten für Restbohrungen berechnen
	;	If $NR <= 0 Or $NR >= 1 Then
	;		$NYZ = $NE + 1     ;   Restbohrung(en) mit gleichem Durchmesser
	;		For $NI = $NYZ To $NG
	;			$XBOHR = $CHR     ; Konstante ab Hydraulikrohrende
	;			$XA = $XOFF - $XBOHR
	;			$XIB = Int($XA / $SS * 1000 + 0.5) / 1000
	;			$sText = StringRight($sLeer & $NI, 9) & StringRight($sLeer & StringFormat("%.2f", $XBOHR), 26) & StringRight($sLeer & StringFormat("%.3f", $XIB), 13)
	;			FileWriteLine($hFile, $sText)
				;If $NG > 45 And $NI = 40 Then Umbruch()
				;If $NG > 98 And $NI = 95 Then Umbruch()
	;		Next
	;		ExitLoop ; GOTO Seitenvorschub1
	;	EndIf

		; Kleinerestbohrung:
		;   1 Restbohrung mit kleine; Durchmesser
	;	$DREST = $DD * Sqrt($NR)
	;	$DREST = Int($DREST * 100 + 0.5) / 100     ;  Durchmesser Restbohrung
	;	FileWriteLine($hFile, "Restbohrung Ø" & $DREST & "mm")
	;	$XBOHR = $CHR     ; Konstante ab Hydraulikrohrende
	;	$XA = $XOFF - $XBOHR
	;	$XIB = Int($XA / $SS * 1000 + 0.5) / 1000
	;	$sText = StringRight($sLeer & $NI, 9) & StringRight($sLeer & StringFormat("%.2f", $XBOHR), 26) & StringRight($sLeer & StringFormat("%.3f", $XIB), 13)
	;	FileWriteLine($hFile, $sText)
	;	ExitLoop
	;WEnd

EndFunc

Func KopfDrucken()
	$sText = "*** Henning GmbH, D-58332 Schwelm ***" & StringLeft($sLeer, 70 - 37 - StringLen($sVersion)) & $sVersion
	FileWriteLine($hFile, $sText)

	FileWriteLine($hFile, "Pufferauslegung mit Programm LP am " & $sDatum)

	FileWriteLine($hFile, " ")

	$sText = "LP " & $DP & "/" & $SS & " *** Fabr.-Nr.: "
	$sText = StringLeft($sText & $FAB, 70)
	FileWriteLine($hFile, $sText)

	FileWriteLine($hFile, "**********************************************************************")

	$sText = "Länge Hydraulikrohr = " & $LHR & " mm "
	If StringLen($BEMERK) > 0 Then $sText = StringLeft($sText & "; " & $BEMERK, 70)
	FileWriteLine($hFile, $sText)

	FileWriteLine($hFile, " ")

	FileWriteLine($hFile, "*** Auslegungsdaten des Puffers: ***")

	$sText = "aufprallende Masse       M = " & $Masse & " kg"
	$sText = StringLeft($sText & $sLeer, 41) & "Vortriebskraft FV = " & $B0 & " N"
	FileWriteLine($hFile, $sText)

	$sText = "Nenngeschwindigkeit  vNenn = " & $VNENN & " m/s"
	$sText = StringLeft($sText & $sLeer, 41) & "Aufprallgeschw.v1 = " & $VP & " m/s"
	FileWriteLine($hFile, $sText)

	$sText = "Gasdruck                p0 = " & $PBAR & " bar"
	$sText = StringLeft($sText & $sLeer, 41) & "Gasvolumen     V0 = " & $VGAS & " l"
	FileWriteLine($hFile, $sText)

	$sText = "Drosselbohrung          dD = " & $NG1 & " Ø " & $DD1 & " mm"
	FileWriteLine($hFile, $sText)

	If $NG2 > 0 Then
		$sText = "Restbohrung            dR1 = " & $NG2 & " Ø " & $DD2 & " mm"
		FileWriteLine($hFile, $sText)
	EndIf

	If $NG3 > 0 Then
		$sText = "Restbohrung            dR2 = " & $NG3 & " Ø " & $DD3 & " mm"
		FileWriteLine($hFile, $sText)
	EndIf

	If $NG4 > 0 Then
		$sText = "Restbohrung            dR3 = " & $NG4 & " Ø " & $DD4 & " mm"
		FileWriteLine($hFile, $sText)
	EndIf

	$sText = "Bohrungen:   Gesamtzahl ng = " & $NG1 + $NG2 + $NG3 + $NG4
	If $sBOBI <> "" Then
		$sText = $sText & StringRight($sLeer & $sBOBI, 39)
		FileWriteLine($hFile, $sText)
	EndIf

	$sText = "Drosselkurvenexponent   nS = " & $NS
	$sText = StringLeft($sText & $sLeer, 41) & "norm. Wegendpunkt  so = " & $SO
	FileWriteLine($hFile, $sText)

	If (($LA = 0) And ($LZ = 0)) Then
		$sText = "unterer Funktionswert   fu = " & $FU
		$sText = StringLeft($sText & $sLeer, 41) & "oberer Funktionsw. fo = " & $FO
		FileWriteLine($hFile, $sText)
	EndIf

	If $LA <> 0 Then
		$sText = "Anstiegsflanke Länge    lA = " & $LA & " mm"
		$sText = StringLeft($sText & $sLeer, 41) & "Anzahl Bohrungen   nA = " & $NA
		FileWriteLine($hFile, $sText)
	EndIf

	If $LZ <> 0 Then
		$sText = "Zwischenflanke Länge    lZ = " & $LZ & " mm"
		$sText = StringLeft($sText & $sLeer, 41) & "Anzahl Bohrungen   nZ = " & $NZ
		FileWriteLine($hFile, $sText)
	EndIf

	; FileWriteLine($hFile, "Schrittweite xD ="; XD; "mm "
	FileWriteLine($hFile, @CRLF & "   Weg         Geschwindigk.  Kraft        Verzögerung    Zeit")
	FileWriteLine($hFile, " x [mm]         v [m/s]      F [N]          a/g0         t [s]")
	FileWriteLine($hFile, "---------------------------------------------------------------")
EndFunc

Func FSVerlauf()
	$sDummy_l = ""

; Unterprogramm Kraft-Weg-Verlauf
	For $XI = 0 To $SS Step $XD
		$XI = Int($XI * 1000 + .5) / 1000
		$X = $XI / $SS
		$SX = ($SO - $X) / ($SO - $SA - $SZ)
		$PRJN = $XI / $XPR

		$sText = "Abs($PRJN - Int($PRJN)) : " & Abs($PRJN - Int($PRJN)) & "     " & "$DXPR : " & $DXPR & "     "
		If Not (Abs($PRJN - Int($PRJN)) > $DXPR) THEN
			$sText = $sText & "Not"
		Else
			$sText = $sText & "nicht Not"
		EndIf
		$sText = $sText & @CRLF & "$XI : " & $XI & @CRLF & "$X : " & $X
		;FileWriteLine($hFile, $sText)

		If $XI <> 0 Then $XI2 = $XI

		If Not (Abs($PRJN - Int($PRJN)) > $DXPR) THEN
			$VPXP = Int($VPX * 1000 + .5) / 1000
			$FPX1P = Int($FPX1)
			$AXIP = Int($AXI / $G0 * 1000 + .5) / 1000
			$TP = Int($T * 1000 + .5) / 1000

			$sText = StringRight("        " & StringFormat("%.1f", $XI), 7) ; 1 Leerzeichen, 4 Ziffern und 2 Nachkommastellen
			$sText = $sText & StringRight("                    " & StringFormat("%.3f", $VPXP), 16)
			$sText = $sText & StringRight("                    " & StringFormat("%d", $FPX1P), 11)
			$sText = $sText & StringRight("                    " & StringFormat("%.3f", $AXIP), 16)
			$sText = $sText & StringRight("                    " & StringFormat("%.3f", $TP), 12)
			FileWriteLine($hFile, $sText)
		EndIf

		; 420:
		$ADX = $ADU

		; 440:
		If $SX > 0 Then
			$ADX = $ADU + $DAD * $SX^$NS

			If (($LA > 0) And ($XI <= $LA)) Then
				$ADX = $ADO - $XI / $LA * $ADA
			EndIf

			If (($LA > 0) And ($LZ > 0) And ($XI > $LA) And ($XI < ($LA + $LZ))) Then
				$ADX = $ADO - $XI / $LA * $ADA - ($XI - $LA) / $LZ * $ADZ
			EndIf
		EndIf

		$P1X = $ZRA * $VPX * $VPX / $ADX / $ADX
		$P2X = ($V0 / ($V0 - $AKS * $XI / 1000))^$NPOL * $P0
		$FPX2 = ($A1 * $P1X + $AKS * $P2X) / $ETA
		$FC = $CON * ($XI + $XD)

		If $FPX2 >= $FC Then
			$FPX2 = $FC
		EndIf

		$FVX = $B0 + $B1 * $X + $B2 * $X * $X
		If $FVX > $FPX2 Then
			FVzuhoch()
		EndIf

		$DFP = $FPX2 - $FVX

		$FPMAXI = $FPX2
		$XFPMAXI = $XI					; Spitzenwert Pufferkraft

		If $FPMAXI > $FPMAX Then
			$FPMAX = $FPMAXI
			$XFPMAX = $XFPMAXI
		EndIf

		$AXI = $DFP / $Masse					; max. Verzögerung

		If $AXI > $AMAX Then
			$AMAX = $AXI
			$XAMAX = $XI
		EndIf

		$EUM = $EUM + ($FPX1 + $FPX2) / 2000 * $XD
		$VPX2Q = $VPX * $VPX - 0.002 * $XD * $DFP / $Masse

		If $VPX2Q <= 0 Then
			Stillstand()
			Return
		EndIf

		$VPX2 = Sqrt($VPX2Q)
		$T = $T + $XD / ($VPX + $VPX2) * 0.002
		$FPX1 = $FPX2
		$VPX = $VPX2
	Next

	FileWriteLine($hFile, @CRLF)
	FileWriteLine($hFile, "Puffer fährt auf Anschlag!")

	Stillstand(); Ende drucken
EndFunc

Func FVzuhoch()
	Local $JaNein_l = 0

	If $ANSTFL = 0 Then
		$sText = "Die hohe Vortriebskraft erlaubt keine Verzögerung !" & @CRLF & "Bitte w„hlen Sie Ihr passendes System aus:" & @CRLF & @CRLF
		$sText = $sText & "  1  - Aufprallgeschwindigkeit v1 kann nicht �berschritten werden" & @CRLF
		$sText = $sText & "  2  - System kann beschleunigen" & @CRLF & @CRLF & "Bitte wählen Sie <1> oder <2>" & @CRLF

		Do
			$JaNein_l = InputBox("FZ zu hoch", $sText, "", 250, 190)
		Until ($JaNein_l = "1") Or ($JaNein_l = "2")
	EndIf

	;If Not (($ANSTFL = 1) And ($VPX >= $VP)) Then
	;	MsgBox(0, "Achtung !", "Vortriebskraft zu hoch! System beschleunigt bei x = " & $XI & " mm")
	;EndIf

	If ($ANSTFL = 1) And ($VPX >= $VP) Then
		$FVX = $FPX2	; Höchstegewschindigkeit nicht überschreiten
	EndIf

	If $ANSTFL = 1 Then $SYSTEM = ", geschwindigkeitsbegrenztes System, v <= v1"
	If $ANSTFL = 2 Then $SYSTEM = ", beschleunigungsfähiges System"

	;Schwingungserkennung am Hubende
	$DSCHWING = $XI - $XSCHWING - 2 * $XD
	$XSCHWING = $XI
	IF Abs($DSCHWING) < ($XD / 100) Then
		$SCHWING = 1
		MsgBox(0, "Info Schwingen", "System schwingt bei " & $XI & " mm")
	EndIf
EndFunc

Func Stillstand()
	$VPXP = Int($VPX * 1000 + .5) / 1000
	$FPX1P = Int($FPX1)
	$TP = Int($T * 1000 + .5) / 1000

	If Abs($PRJN - Int($PRJN)) > Abs($DXPR) Then
		$sText = StringRight("        " & StringFormat("%.1f", $XI2), 7) ; 1 Leerzeichen, 4 Ziffern und 2 Nachkommastellen
		$sText = $sText & StringRight("                    " & StringFormat("%.3f", $VPXP), 16)
		$sText = $sText & StringRight("                    " & StringFormat("%d", $FPX1P), 11)
		$sText = $sText & StringRight("                    " & StringFormat("%.3f", $AXIP), 16)
		$sText = $sText & StringRight("                    " & StringFormat("%.3f", $TP), 12)
		FileWriteLine($hFile, $sText)
		FileWriteLine($hFile, " ")
	EndIf

	;MsgBox(0, "Info", "VPXP : " & $VPXP & @CRLF & "XD : " & $XD & @CRLF & "XI : " & $XI)

	FileWriteLine($hFile, "Daten bei Bewegungsende (Schrittweite xD = " & StringFormat("%.2f", $XD) & " mm):")

	$FRANF = $AKS * $P0 * $ETA 	; Rü�ckstellkraft Hubanfang in N
	$FRUECK = $AKS * $P2X * $ETA 	; Rü�ckstellkraft bei Bewegungsende in N

	FileWriteLine($hFile, "Pufferenergie : " & Int($EUM) & " Nm" & $SYSTEM)
	FileWriteLine($hFile, "max. Pufferkraft : " & Int($FPMAX) & " N bei Hub " & $XFPMAX & " mm; Rü�ckstellkraft : " & Int($FRUECK) & " N")

	$AMITTLS = $VP * $VP / 2 / $SM		;  mittlere Verzögerung ü�ber den Hub
	$AMITTLT = ($VP - $VPXP) / $T			;  mittlere Verzögerung ü�ber die Zeit

	FileWriteLine($hFile, "max. Verzögerung : " & Round($AMAX, 2) & " m/s2 bei Hub " & $XAMAX & " mm")
	FileWriteLine($hFile, "mittlere Verzögerung, zeitlich : " & Round($AMITTLT, 2) & " m/s2 ü�ber den Hub : " & Round($AMITTLS, 2) & " m/s2")
EndFunc

Func i_GetNumber(byRef $sDummy)
	Return Number(StringReplace(GUICtrlRead($sDummy), ",", "."))
EndFunc

Func i_GetDP_Daten()
	; Daten fü�r LP 40    Stand 26.03.2000
	If $DP = 40 Then
		$D1 = 0.04
		$D2 = 0.05
		$D3 = 0.1
		$DKS = 0.032
		$COFF = 16.5
		$CHR = 13.5
		$V0KOPF = 0
		; CLMR = .072

		; Rohrlängen fü�r LP 40   Stand 24.09.2000/17.08.2000/16.08.2015
		Select
			Case $SS = 80
				$LHR = 146
				$LMR = 177
				$HGAS = 44.5
				$DD = 1.3
				$NG = 6.3787
				$NR = 0.3787
				$DD1 = 1.3
				$NG1 = 6
				$DD2 = 0.8
				$NG2 = 1
				$DD3 = 0
				$NG3 = 0
				$DD4 = 0
				$NG4 = 0
				$NS = 0.72
				$SO = 0.95
				$LA = 0
				$NA = 0
				$LZ = 0
				$NZ = 0
				$DKZ = 97410103
				$BOBI = "B2d-97410103"

			Case $SS = 120
				$LHR = 186
				$LMR = 217
				$HGAS = 44.5
				$DD = 1.3
				$NG = 7.3787
				$NR = 0.3787
				$DD1 = 1.3
				$NG1 = 7
				$DD2 = 0.8
				$NG2 = 1
				$DD3 = 0
				$NG3 = 0
				$DD4 = 0
				$NG4 = 0
				$NS = 0.67
				$SO = 0.95
				$LA = 0
				$NA = 0
				$LZ = 0
				$NZ = 0
				$DKZ = 97410202
				$BOBI = "B2a1-97410202"

			Case $SS = 175
				$LHR = 241
				$LMR = 272
				$HGAS = 44.5
				$DD = 1.2
				$NG = 11.4444
				$NR = 0.4444
				$DD1 = 1.2
				$NG1 = 11
				$DD2 = 0.8
				$NG2 = 1
				$DD3 = 0
				$NG3 = 0
				$DD4 = 0
				$NG4 = 0
				$NS = 0.78
				$SO = 0.97
				$LA = 0
				$NA = 0
				$LZ = 0
				$NZ = 0
				$DKZ = 97410303
				$BOBI = "B2d-97410303"

			Case $SS = 190
				$LHR = 266
				$LMR = 297
				$HGAS = 54.5
				$DD = 0
				$NG = 0
				$NR = 0
				$DD1 = 0
				$NG1 = 0
				$DD2 = 0
				$NG2 = 0
				$DD3 = 0
				$NG3 = 0
				$DD4 = 0
				$NG4 = 0
				$NS = 0
				$SO = 0
				$LA = 0
				$NA = 0
				$LZ = 0
				$NZ = 0
				$DKZ = 0
				$BOBI = ""

			Case $SS = 235
				$LHR = 321
				$LMR = 352
				$HGAS = 64.5
				$DD = 0
				$NG = 0
				$NR = 0
				$DD1 = 0
				$NG1 = 0
				$DD2 = 0
				$NG2 = 0
				$DD3 = 0
				$NG3 = 0
				$DD4 = 0
				$NG4 = 0
				$NS = 0
				$SO = 0
				$LA = 0
				$NA = 0
				$LZ = 0
				$NZ = 0
				$DKZ = 0
				$BOBI = ""

			Case $SS = 275
				$LHR = 361
				$LMR = 392
				$HGAS = 64.5
				$DD = 1.3
				$NG = 12.3787
				$NR = 0.3787
				$DD1 = 1.3
				$NG1 = 12
				$DD2 = 0.8
				$NG2 = 1
				$DD3 = 0
				$NG3 = 0
				$DD4 = 0
				$NG4 = 0
				$NS = 0.75
				$SO = 0.97
				$LA = 0
				$NA = 0
				$LZ = 0
				$NZ = 0
				$DKZ = 97410503
				$BOBI = "B2c-97410503"

			Case $SS = 295
				$LHR = 391
				$LMR = 422
				$HGAS = 74.5
				$DD = 0
				$NG = 0
				$NR = 0
				$DD1 = 0
				$NG1 = 0
				$DD2 = 0
				$NG2 = 0
				$DD3 = 0
				$NG3 = 0
				$DD4 = 0
				$NG4 = 0
				$NS = 0
				$SO = 0
				$LA = 0
				$NA = 0
				$LZ = 0
				$NZ = 0
				$DKZ = 0
				$BOBI = ""

			Case $SS = 430
				$LHR = 556
				$LMR = 587
				$HGAS = 91
				$DD = 1.6
				$NG = 10.25
				$NR = 0.25
				$DD1 = 1.6
				$NG1 = 10
				$DD2 = 0.8
				$NG2 = 1
				$DD3 = 0
				$NG3 = 0
				$DD4 = 0
				$NG4 = 0
				$NS = 0.69
				$SO = 0.97
				$LA = 0
				$NA = 0
				$LZ = 0
				$NZ = 0
				$DKZ = 97410703
				$BOBI = "B2b-97410703"
		EndSelect
	EndIf

	; Daten fü�r LP 50    Stand 24.09.2000
	If $DP = 50 Then
		$D1 = 0.05
		$D2 = 0.065
		$D3 = 0.1382
		$DKS = 0.045
		$COFF = 16.5
		$CHR = 13.5
		$V0KOPF = 0
		; CLMR = ?

		; Rohrlängen fü�r LP 50   Stand 24.09.2000
		Select
			Case $SS = 175
				$LHR = 253
				$LMR = 291
				$HGAS = 54.5
				$DD = 0
				$NG = 0
				$NR = 0
				$DD1 = 0
				$NG1 = 0
				$DD2 = 0
				$NG2 = 0
				$DD3 = 0
				$NG3 = 0
				$DD4 = 0
				$NG4 = 0
				$NS = 0
				$SO = 0
				$LA = 0
				$NA = 0
				$LZ = 0
				$NZ = 0
				$DKZ = 0
				$BOBI = ""

			Case $SS = 425
				$LHR = 548
				$LMR = 586
				$HGAS = 99.5
				$DD = 1.8
				$NG = 13.3086
				$NR = 0.3086
				$DD1 = 1.8
				$NG1 = 13
				$DD2 = 0.8
				$NG2 = 1
				$DD3 = 0
				$NG3 = 0
				$DD4 = 0
				$NG4 = 0
				$NS = 0.82
				$SO = 0.97
				$LA = 0
				$NA = 0
				$LZ = 0
				$NZ = 0
				$DKZ = 97510403
				$BOBI = "B2c-97510403"

			Case $SS = 695
				$LHR = 878
				$LMR = 916
				$HGAS = 159.5
				$DD = 1.8
				$NG = 19.3086
				$NR = 0.3086
				$DD1 = 1.6
				$NG1 = 19
				$DD2 = 0.8
				$NG2 = 1
				$DD3 = 0
				$NG3 = 0
				$DD4 = 0
				$NG4 = 0
				$NS = 0.82
				$SO = 0.97
				$LA = 0
				$NA = 0
				$LZ = 0
				$NZ = 0
				$DKZ = 97510603
				$BOBI = "B2c-97510603"

			Case $SS = 950 ; Entwurf ! $HGAS und Hub prüfen !!
				$LHR = 1193
				$LMR = 1231
				$HGAS = 206
				$DD = 1.7
				$NG = 26.346
				$NR = 0.346
				$DD1 = 1.7
				$NG1 = 26
				$DD2 = 1
				$NG2 = 1
				$DD3 = 0
				$NG3 = 0
				$DD4 = 0
				$NG4 = 0
				$NS = 0.78
				$SO = 0.97
				$LA = 125
				$NA = 0
				$LZ = 150
				$NZ = 9
				$DKZ = 97510910
				$BOBI = "B09-97510910"
		EndSelect
	EndIf

	$sDummy = "DP : " & $DP & @CRLF & "D1 : " & $D1 & @CRLF & "D2 : " & $D2 & @CRLF & "D3 : " & $D3 & @CRLF & "DKS : " & $DKS & @CRLF
	$sDummy = $sDummy & "COFF : " & $COFF & @CRLF & "CHR : " & $CHR & @CRLF & "V0KOPF : " & $V0KOPF & @CRLF & "SS : " & $SS & @CRLF
	$sDummy = $sDummy & "SM : " & $SM & @CRLF & "LHR : " & $LHR & @CRLF & "LMR : " & $LMR & @CRLF & "HGAS : " & $HGAS
	; MsgBox(0, "Info", $sDummy)
EndFunc

Func i_ZahlPunkt($sZahl)
	Local $sDummy = "", $sNeg = ""

	$sZahl = StringReplace($sZahl, ".", "")
	$sZahl = StringReplace($sZahl, ",", "")

	If StringLeft($sZahl, 1) = "-" Then
		$sNeg = "-"
		$sZahl = StringTrimLeft($sZahl, 1)
	Else
		$sNeg = ""
	EndIf

	While StringLen($sZahl) > 3
		$sDummy = "." & StringRight($sZahl, 3) & $sDummy
		$sZahl = StringTrimRight($sZahl, 3)
	WEnd

	If StringLen($sZahl) > 0 Then
		$sDummy = $sZahl & $sDummy
	EndIf

	While (StringLeft($sDummy, 1) = " ") or (StringLeft($sDummy, 1) = ".")
		$sDummy = StringTrimLeft($sDummy, 1)
	WEnd

	Return $sNeg & $sDummy
EndFunc

Func i_ZahlKomma($sZahl)
	Return StringReplace($sZahl, ".", ",")
EndFunc
