Hello
(This is a Google translation from German)
I have a problem with my CNC program.
It is mistaken.
I can not find the error.
I think the formulas are simple. :-(
Also this "NaN" bothers me.
How do I remove it?
I also find that the program is too large.
Does anyone have a tip to shorten it?
I have in the Softwae 200 formulas.
That will be far too long.
Thanks for the help.
Frank
(This is a Google translation from German)
I have a problem with my CNC program.
It is mistaken.
I can not find the error.
I think the formulas are simple. :-(
Also this "NaN" bothers me.
How do I remove it?
I also find that the program is too large.
Does anyone have a tip to shorten it?
I have in the Softwae 200 formulas.
That will be far too long.
Thanks for the help.
Frank
B4X:
'Activity module
'edtTextRechner
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim scvMain As ScrollView
Dim PanelNb As Int : PanelNb=6
Dim PanelHeight As Int : PanelHeight=170dip
Dim Formel, Text(15,15) As String : Formel = "Dreieck"
Dim i As Int
Dim Zahl(30,30) As Double ': zahl(30,30) = numberformat2(zahl(30,30),1,3,3,false)
Dim lblCalc(15,15) As Label
Dim edtCalc(15) As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim pnlCalc(10) As Panel
Dim btnCalc As Button
scvMain.Initialize(1500)
Activity.AddView(scvMain, 0, 0, 100%x, 100%y)
Dreieck ' Labeltexte abholen
For i=0 To PanelNb-1
pnlCalc(i).Initialize("pnlCalc")
scvMain.Panel.AddView(pnlCalc(i),0,5dip+i*PanelHeight,100%x,PanelHeight+5)
pnlCalc(i).Tag=i
If (i Mod 2)=1 Then
pnlCalc(i).Color=Colors.Red
Else
pnlCalc(i).Color=Colors.Blue
End If
'Benennung
lblCalc(i,1).Initialize("lblCalc1")
pnlCalc(i).AddView(lblCalc(i,1),10dip, 5dip, 45%x, 40dip)
lblCalc(i,1).Tag=i
lblCalc(i,1).TextSize=20
lblCalc(i,1).Text= Text(i,1)
lblCalc(i,1).TextColor = Colors.Black
lblCalc(i,1).Gravity = Gravity.RIGHT
'Formel 1
lblCalc(i,2).Initialize("lblCalc1")
pnlCalc(i).AddView(lblCalc(i,2),10dip, 35dip, 45%x, 40dip)
lblCalc(i,2).Tag=i
lblCalc(i,2).TextSize=17
lblCalc(i,2).Text=Text(i,2)
lblCalc(i,2).TextColor = Colors.Black
lblCalc(i,2).Gravity = Gravity.RIGHT
'Formel 2
lblCalc(i,3).Initialize("lblCalc1")
pnlCalc(i).AddView(lblCalc(i,3),10dip, 65dip, 45%x, 40dip)
lblCalc(i,3).Tag=i
lblCalc(i,3).TextSize=17
lblCalc(i,3).Text=Text(i,3)
lblCalc(i,3).TextColor = Colors.Black
lblCalc(i,3).Gravity = Gravity.RIGHT
'Formel 3
lblCalc(i,4).Initialize("lblCalc1")
pnlCalc(i).AddView(lblCalc(i,4),10dip, 95dip, 45%x, 40dip)
lblCalc(i,4).Tag=i
lblCalc(i,4).TextSize=17
lblCalc(i,4).Text=Text(i,4)
lblCalc(i,4).TextColor = Colors.Black
lblCalc(i,4).Gravity = Gravity.RIGHT
'Formel 4
lblCalc(i,9).Initialize("lblCalc1")
pnlCalc(i).AddView(lblCalc(i,9),10dip, 125dip, 45%x, 40dip)
lblCalc(i,9).Tag=i
lblCalc(i,9).TextSize=19
lblCalc(i,9).Text=Text(i,9)
lblCalc(i,9).TextColor = Colors.Black
lblCalc(i,9).Gravity = Gravity.RIGHT
'----------------------------------------------------------------------------
'Eingabefeld
edtCalc(i).Initialize("edtCalc")
pnlCalc(i).AddView(edtCalc(i),55%x, 5dip, 35%x, 35dip)'55%x, 70dip, 35%x, 25dip)
edtCalc(i).Tag=i
edtCalc(i).TextSize=15
edtCalc(i).InputType = edtCalc(i).INPUT_TYPE_NONE
edtCalc(i).Text = 0
'----------------------------------------------------------------------------
'Ergebnis 1
lblCalc(i,5).Initialize("lblCalc")
pnlCalc(i).AddView(lblCalc(i,5),55%x, 40dip, 35%x, 25dip)
lblCalc(i,5).Tag=i&5
lblCalc(i,5).TextSize=17
lblCalc(i,5).Text= Zahl(i,5)
lblCalc(i,5).Color = Colors.LightGray
lblCalc(i,5).TextColor = Colors.Black
lblCalc(i,5).Gravity = Gravity.CENTER_HORIZONTAL
'Ergebnis 2
lblCalc(i,6).Initialize("lblCalc")
pnlCalc(i).AddView(lblCalc(i,6),55%x, 70dip, 35%x, 25dip)
lblCalc(i,6).Tag=i&6
lblCalc(i,6).TextSize=17
lblCalc(i,6).Text=Zahl(i,6)
lblCalc(i,6).Color = Colors.LightGray
lblCalc(i,6).TextColor = Colors.Black
lblCalc(i,6).Gravity = Gravity.CENTER_HORIZONTAL
'Ergebnis 3
lblCalc(i,7).Initialize("lblCalc")
pnlCalc(i).AddView(lblCalc(i,7),55%x, 100dip, 35%x, 25dip)
lblCalc(i,7).Tag=i&7
lblCalc(i,7).TextSize=17
lblCalc(i,7).Text=Zahl(i,7)
lblCalc(i,7).Color = Colors.LightGray
lblCalc(i,7).TextColor = Colors.Black
lblCalc(i,7).Gravity = Gravity.CENTER_HORIZONTAL
'Ergebnis 4
lblCalc(i,8).Initialize("lblCalc")
pnlCalc(i).AddView(lblCalc(i,8),55%x, 130dip, 35%x, 25dip)
lblCalc(i,8).Tag=i&8
lblCalc(i,8).TextSize=17
lblCalc(i,8).Text=Zahl(i,8)
lblCalc(i,8).Color = Colors.LightGray
lblCalc(i,8).TextColor = Colors.Black
lblCalc(i,8).Gravity = Gravity.CENTER_HORIZONTAL
Next
edtCalc(0).Text = 90.0 '"Kathete a"
edtCalc(1).Text = 90.0 '"Kathete b"
edtCalc(2).Text = 0'"Hypotenuse c"
edtCalc(3).Text = 0 '"Winkel Alpha"
edtCalc(4).Text= 0 '"Winkel Beta"
edtCalc(5).Text= 90.0 '"Winkel Gamma"
For i = 0 To 5
edtCalc(i).Text = NumberFormat2(edtCalc(i).Text,0,3,3,False)
Next
scvMain.Panel.Height=PanelNb*PanelHeight+10
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub lblCalc_Click ' übernahme der Ergebnisse in edtCalc
Dim Send As Label
'Dim i As Int
Send=Sender
Activity.Title="Label "&Send.Tag
i = Send.Tag
Select i
Case 05
edtCalc(0).Text = lblCalc(0,5).Text
Case 06
edtCalc(0).Text = lblCalc(0,6).Text
Case 07
edtCalc(0).Text = lblCalc(0,7).Text
' Case 08
' edtCalc(0).Text = lblCalc(0,8).Text
Case 15
edtCalc(1).Text = lblCalc(1,5).Text
Case 16
edtCalc(1).Text = lblCalc(1,6).Text
Case 17
edtCalc(1).Text = lblCalc(1,7).Text
Case 18
edtCalc(1).Text = lblCalc(1,8).Text
Case 25
edtCalc(2).Text = lblCalc(2,5).Text
Case 26
edtCalc(2).Text = lblCalc(2,6).Text
Case 27
edtCalc(2).Text = lblCalc(2,7).Text
Case 28
edtCalc(2).Text = lblCalc(2,8).Text
Case 35
edtCalc(3).Text = lblCalc(3,5).Text
Case 36
edtCalc(3).Text = lblCalc(3,6).Text
Case 37
edtCalc(3).Text = lblCalc(3,7).Text
Case 38
edtCalc(3).Text = lblCalc(3,8).Text
Case 45
edtCalc(4).Text = lblCalc(4,5).Text
Case 46
edtCalc(4).Text = lblCalc(4,6).Text
Case 47
edtCalc(4).Text = lblCalc(4,7).Text
Case 48
edtCalc(4).Text = lblCalc(4,8).Text
Case Else
Msgbox("Send.Tag = "&Send.Tag, "Probleme in lblCalc_click")
End Select
End Sub
Sub btnCalc_Click
Dim Send As Button
Send=Sender
Activity.Title="Button "&Send.Tag
End Sub
Sub pnlCalc_Click
Dim Send As Panel
Send=Sender
Activity.Title="Panel "&Send.Tag
End Sub
Sub edtCalc_EnterPressed 'Berechnung der Ergebnisse
Dim a,b,c,α, β, γ,x As Double
Dim Send As EditText
Send=Sender
Activity.Title="EditText "&Send.Tag&" = "&Send.Text
a = edtCalc(0).Text '"Kathete a"
b = edtCalc(1).Text '"Kathete b"
c = edtCalc(2).Text '"Hypotenuse c"
α = edtCalc(3).Text '"Winkel Alpha"
β = edtCalc(4).Text '"Winkel Beta"
γ = edtCalc(5).Text '"Winkel Gamma"
'Variablen zum "Dreieck"
' edtCalc(0) = '"Kathete a"
' edtCalc(1) = '"Kathete b"
' edtCalc(2) = '"Hypotenuse c"
' edtCalc(3) = '"Winkel Alpha"
' edtCalc(4) = '"Winkel Beta"
' edtCalc(5) = '"Winkel Gamma"
'α β γ
' Text(0,1) = "Kathete a"
' Text(0,2) = "c * sin(α) = "
' Text(0,3) = "c * cos(β)= "
' Text(0,4) = "b / cot(β) ="
' Text(0,9) = ""
Zahl(0,5) = c * SinD(α)
Zahl(0,6) = c * CosD(β)
Zahl(0,7) = b * TanD(α)
Zahl(0,8) = 0
' Text(1,1) = "Kathete b"
' Text(1,2) = "c * cos(α) ="
' Text(1,3) = "c * sin(β) ="
' Text(1,4) = "a / tan(α) ="
' Text(1,9) = ""
Zahl(1,5) = c * CosD(α)
Zahl(1,6) = c * SinD(β)
Zahl(1,7) = a / TanD(α)
Zahl(1,8) = 0
' Text(2,1) = "Hypotenuse c"
' Text(2,2) = "a / sin(α) ="
' Text(2,3) = "b / cos(α) ="
' Text(2,4) = "a / cos(β) ="
' Text(2,9) = ""
Zahl(2,5) = a / SinD(α)
Zahl(2,6) = b / CosD(α)
Zahl(2,7) = a / CosD(β)
Zahl(2,8) = 0
' Text(3,1) = "Winkel Alpha"
' Text(3,2) = "inv Sin(a/c) ="
' Text(3,3) = "inv Cos(b/c)"
' Text(3,4) = "inv Tan(a/b)"
' Text(3,9) = "90 - β"
Zahl(3,5) = ASinD(a/c)
Zahl(3,6) = ACosD(b/c)
Zahl(3,7) = ATanD(a/b)
Zahl(3,8) = 90 - β
' Text(4,1) = "Winkel Beta"
' Text(4,2) = "180 - α - γ ="
' Text(4,3) = "90 - α ="
' Text(4,4) = ""
' Text(4,9) = ""
Zahl(4,5) = 180 - α - γ
Zahl(4,6) = 90 - α
Zahl(4,7) = 0
Zahl(4,8) = 0
' Text(5,1) = "Winkel Gamma"
' Text(5,2) = "180 - α - β ="
' Text(5,3) = ""
' Text(5,4) = ""
' Text(5,9) = ""
Zahl(5,5) = 180 - α - β
Zahl(5,6) = 0
Zahl(5,7) = 0
Zahl(5,8) = 0
For i =0 To 5
' lblCalc(i,5).Text = Zahl(i,5)
' lblCalc(i,6).Text = Zahl(i,6)
' lblCalc(i,7).Text = Zahl(i,7)
lblCalc(i,5).Text = NumberFormat2(Zahl(i,5),0,3,3,False)
lblCalc(i,6).Text = NumberFormat2(Zahl(i,6),0,3,3,False)
lblCalc(i,7).Text = NumberFormat2(Zahl(i,7),0,3,3,False)
Next
End Sub
Sub Dreieck ' Labeltexte
Text(0,1) = "Kathete a"
Text(0,2) = "c * sin(α) ="
Text(0,3) = "c * cos(β) ="
Text(0,4) = "b / cot(β) ="
Text(0,9) = ""
Zahl(0,5) = 0
Zahl(0,6) = 0
Zahl(0,7) = 0
Zahl(0,8) = 0
Text(1,1) = "Kathete b"
Text(1,2) = "c * cos(α) ="
Text(1,3) = "c * sin(β) ="
Text(1,4) = "a / tan(α) ="
Text(1,9) = ""
Zahl(1,5) = 0
Zahl(1,6) = 0
Zahl(1,7) = 0
Zahl(1,8) = 0
Text(2,1) = "Hypotenuse c"
Text(2,2) = "a / sin(α) ="
Text(2,3) = "b / cos(α) ="
Text(2,4) = "a / cos(β) ="
Text(2,9) = ""
Zahl(2,5) = 0
Zahl(2,6) = 0
Zahl(2,7) = 0
Zahl(2,8) = 0
Text(3,1) = "Winkel Alpha"
Text(3,2) = "inv Sin(a/c) ="
Text(3,3) = "inv Cos(b/c) ="
Text(3,4) = "inv Tan(a/b) ="
Text(3,9) = "90 - β ="
Zahl(3,5) = 0
Zahl(3,6) = 0
Zahl(3,7) = 0
Zahl(3,8) = 0
Text(4,1) = "Winkel Beta"
Text(4,2) = "180 - α - γ ="
Text(4,3) = "90 - α ="
Text(4,4) = ""
Text(4,9) = ""
Zahl(4,5) = 0
Zahl(4,6) = 0
Zahl(4,7) = 0
Zahl(4,8) = 0
Text(5,1) = "Winkel Gamma"
Text(5,2) = "180 - α - β ="
Text(5,3) = ""
Text(5,4) = ""
Text(5,9) = ""
Zahl(5,5) = 0
Zahl(5,6) = 0
Zahl(5,7) = 0
Zahl(5,8) = 0
End Sub