Sign in to follow this  
Followers 0
Sym98

[Autoit Error] Can not redeclare a parameter inside a user function.

9 posts in this topic

#1 ·  Posted (edited)

Hello everyone, today I encountered the following error:

"Can not redeclare a parameter inside a user function."

Can you tell me what is this?

The error is within a function, in which there are several cycles If that based on the contents of a variable assigned to the variable "$ s_E" a different value. I think the error is due to the fact that "$ s_E" is defined if more than one cycle, but it must be said that executes a single loop within the function.

For not to post the entire code of the program, I shrunk it:

;Script Created By Sym98
#include <GUIConstants.au3>
#include <GUIEdit.au3>

;Variabili
Global $FlagArea = 0
Global $FlagPerimetro = 0
Global $FlagC1 = 0
Global $FlagC2 = 0
Global $FlagIpotenusa = 0
Global $FlagHP = 0
Global $Flag2Area = 0
Global $Flag2Perimetro = 0
Global $Flag2C1 = 0
Global $Flag2C2 = 0
Global $Flag2Ipotenusa = 0
Global $Flag2HP = 0
Global $FlagDisableArea = 1
Global $FlagDisablePerimetro = 1
Global $FlagDisableC1T = 1
Global $FlagDisableC2T = 1
Global $FlagDisableC1 = 1
Global $FlagDisableC2 = 1
Global $FlagDisableIpotenusa = 1
Global $FlagDisableHP = 1
Global $FlagEquivalenzaArea = 0
Global $FlagEquivalenzaPerimetro = 0
Global $FlagEquivalenzaC1 = 0
Global $FlagEquivalenzaC2 = 0
Global $FlagEquivalenzaIpotenusa = 0
Global $FlagEquivalenzaHP = 0
Global $Area, $Label2, $A_Incognita, $Label3, $Perimetro, $DUEP_Incognita, _
$Label5, $C2, $C2_Incognita, $Altezza, $h_Incognita, $Label5, $LabelBase, _
$Base, $B_Incognita, $On_off_A, $Misura_A, $Misura_B, $On_off_B, $Misura_h, $On_off_h, $Misura_2P, $On_off_2P, $Label, $Label6, $Misura_Comune
Global $Flag1 = 1
Global $Flag2 = 0
Global $Flag3 = 0
Global $Flag4 = 0
Global $Flag5 = 0
Global $FlagMisura = "mm"



;GUI
Global $GUI = GUICreate("SGP - Solve Geometric Problems By Sym98", 625, 522)
GUISetFont(10, 800, 0, "Comic Sans MS")
Global $Group1 = GUICtrlCreateGroup("Figura", 366, 53, 244, 242)
Global $Figura = GUICtrlCreatePic("Images\Triangolo Rettangolo.jpg", 371, 73, 235, 217)
GUICtrlSetData(-1, "Figura")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Tipe = GUICtrlCreateCombo("Triangolo Rettangolo", 366, 28, 243, 25)
GUICtrlSetData(-1, "Triangolo Isoscele|Triangolo Equilatero|Triangolo Scaleno")
Global $Label1 = GUICtrlCreateLabel("Solve Geometric Problems", 9, 3, 305, 39)
GUICtrlSetFont(-1, 18, 800, 0, "Comic Sans MS")
$Calcola = GUICtrlCreateButton("Calcola", 17, 262, 325, 50, 0)
$Group2 = GUICtrlCreateGroup("Dati", 10, 42, 345, 219)
$Area = GUICtrlCreateInput("", 54, 61, 106, 27)
$Label2 = GUICtrlCreateLabel("Area:", 12, 63, 40, 23)
$A_Incognita = GUICtrlCreateButton("Incognita", 257, 56, 94, 32, 0)
$Label3 = GUICtrlCreateLabel("Perimetro:", 12, 202, 70, 23)
$Perimetro = GUICtrlCreateInput("", 81, 198, 79, 27)
$DUEP_Incognita = GUICtrlCreateButton("Incognita", 263, 196, 90, 32, 0)
$Label5 = GUICtrlCreateLabel("C2:", 16, 137, 26, 23)
$C2 = GUICtrlCreateInput("", 54, 133, 105, 27)
$C2_Incognita = GUICtrlCreateButton("Incognita", 258, 130, 94, 32, 0)
$Label = GUICtrlCreateLabel("C1:", 13, 101, 26, 23)
$C1 = GUICtrlCreateInput("", 55, 97, 106, 27)
$C1_Incognita = GUICtrlCreateButton("Incognita", 258, 94, 94, 32, 0)
$On_off_A = GUICtrlCreateButton("-", 214, 58, 42, 29, 0)
$Misura_A = GUICtrlCreateCombo("mm²", 164, 61, 49, 25)
GUICtrlSetData(-1, "cm²|dm²|m²|dam²|hm²|km²")
$Misura_C1 = GUICtrlCreateCombo("mm", 165, 95, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$On_off_C1 = GUICtrlCreateButton("-", 215, 95, 42, 29, 0)
$Misura_C2 = GUICtrlCreateCombo("mm", 166, 132, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$On_off_C2 = GUICtrlCreateButton("-", 216, 131, 42, 29, 0)
$Misura_2P = GUICtrlCreateCombo("mm", 167, 199, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$On_off_2P = GUICtrlCreateButton("-", 220, 198, 42, 29, 0)
$Label4 = GUICtrlCreateLabel("I:", 14, 166, 17, 23)
$Ipotenusa = GUICtrlCreateInput("", 53, 164, 105, 27)
$Misura_Ipotenusa = GUICtrlCreateCombo("mm", 166, 163, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$On_off_Ipotenusa = GUICtrlCreateButton("-", 218, 164, 42, 29, 0)
$I_Incognita = GUICtrlCreateButton("Incognita", 259, 162, 94, 32, 0)
$Labelx = GUICtrlCreateLabel("Altezza(I):", 13, 230, 68, 20)
GUICtrlSetFont(-1, 9, 800, 0, "Comic Sans MS")
$HP = GUICtrlCreateInput("", 85, 227, 75, 27)
$Misura_HP = GUICtrlCreateCombo("mm", 167, 229, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$On_off_HP = GUICtrlCreateButton("-", 221, 227, 42, 29, 0)
$HP_Incognita = GUICtrlCreateButton("Incognita", 262, 228, 90, 29, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group3 = GUICtrlCreateGroup("Procedimento", 291, 319, 322, 125)
Global $Edit_Procedimento = GUICtrlCreateEdit("", 291, 336, 321, 107)
GUICtrlSetData(-1, "")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("Incognite", 16, 311, 261, 132)
$Edit_Incognite = GUICtrlCreateEdit("", 19, 331, 255, 113)
GUICtrlSetData(-1, "")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Label7 = GUICtrlCreateLabel("Created By Sym98", 391, 457, 222, 39)
GUICtrlSetFont(-1, 18, 800, 0, "Comic Sans MS")
Global $Azzera = GUICtrlCreateButton("Azzera", 15, 452, 366, 45, 0)
$Misura_Comune = GUICtrlCreateCombo("mm", 539, 295, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$Label6 = GUICtrlCreateLabel("Unità di misura comune:", 372, 297, 159, 23)
GUISetState(@SW_SHOW)

;While
_Main()
Func _Main()
While 1
Global $s_Area = GUICtrlRead($Area)
Global $s_C1 = GUICtrlRead($C1)
Global $s_C2 = GUICtrlRead($C2)
Global $s_Ipotenusa = GUICtrlRead($Ipotenusa)
Global $s_Perimetro = GUICtrlRead($Perimetro)
Global $s_HP = GUICtrlRead($HP)
Global $s_Tipe = GUICtrlRead($Tipe)
Global $s_Misura_Comune = GUICtrlRead($Misura_Comune)
If $s_Tipe = "Triangolo Rettangolo" And $Flag1 = 0 Then 
;Rettangolo
GUICtrlDelete($Group2)
GUICtrlDelete($Area)
GUICtrlDelete($Label2)
GUICtrlDelete($A_Incognita)
GUICtrlDelete($Label3)
GUICtrlDelete($Perimetro)
GUICtrlDelete($DUEP_Incognita)
GUICtrlDelete($Label5)
GUICtrlDelete($C2)
GUICtrlDelete($C2_Incognita)
GUICtrlDelete($Label)
GUICtrlDelete($C1)
GUICtrlDelete($C1_Incognita)
GUICtrlDelete($On_off_A)
GUICtrlDelete($Misura_A)
GUICtrlDelete($Misura_C1)
GUICtrlDelete($On_off_C1)
GUICtrlDelete($Misura_C2)
GUICtrlDelete($On_off_C2)
GUICtrlDelete($Misura_2P)
GUICtrlDelete($On_off_2P)
GUICtrlDelete($Label4)
GUICtrlDelete($Ipotenusa)
GUICtrlDelete($Misura_Ipotenusa)
GUICtrlDelete($On_off_Ipotenusa)
GUICtrlDelete($I_Incognita)
GUICtrlDelete($Labelx)
GUICtrlDelete($HP)
GUICtrlDelete($Misura_HP)
GUICtrlDelete($On_off_HP)
GUICtrlDelete($HP_Incognita)
;Isoscele ecc...
GUICtrlDelete($Group2)
GUICtrlDelete($Area)
GUICtrlDelete($Label2)
GUICtrlDelete($A_Incognita)
GUICtrlDelete($Label3)
GUICtrlDelete($Perimetro)
GUICtrlDelete($DUEP_Incognita)
GUICtrlDelete($Label5)
GUICtrlDelete($Altezza)
GUICtrlDelete($h_Incognita)
GUICtrlDelete($LabelBase)
GUICtrlDelete($Base)
GUICtrlDelete($B_Incognita)
GUICtrlDelete($On_off_A)
GUICtrlDelete($Misura_A)
GUICtrlDelete($Misura_B)
GUICtrlDelete($On_off_B)
GUICtrlDelete($Misura_h)
GUICtrlDelete($On_off_h)
GUICtrlDelete($Misura_2P)
GUICtrlDelete($On_off_2P)
$Group2 = GUICtrlCreateGroup("Dati", 10, 42, 345, 219)
$Area = GUICtrlCreateInput("", 54, 61, 106, 27)
$Label2 = GUICtrlCreateLabel("Area:", 12, 63, 40, 23)
$A_Incognita = GUICtrlCreateButton("Incognita", 257, 56, 94, 32, 0)
$Label3 = GUICtrlCreateLabel("Perimetro:", 12, 202, 70, 23)
$Perimetro = GUICtrlCreateInput("", 81, 198, 79, 27)
$DUEP_Incognita = GUICtrlCreateButton("Incognita", 263, 196, 90, 32, 0)
$Label5 = GUICtrlCreateLabel("C2:", 16, 137, 26, 23)
$C2 = GUICtrlCreateInput("", 54, 133, 105, 27)
$C2_Incognita = GUICtrlCreateButton("Incognita", 258, 130, 94, 32, 0)
$Label = GUICtrlCreateLabel("C1:", 13, 101, 26, 23)
$C1 = GUICtrlCreateInput("", 55, 97, 106, 27)
$C1_Incognita = GUICtrlCreateButton("Incognita", 258, 94, 94, 32, 0)
$On_off_A = GUICtrlCreateButton("-", 214, 58, 42, 29, 0)
$Misura_A = GUICtrlCreateCombo("mm²", 164, 61, 49, 25)
GUICtrlSetData(-1, "cm²|dm²|m²|dam²|hm²|km²")
$Misura_C1 = GUICtrlCreateCombo("mm", 165, 95, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$On_off_C1 = GUICtrlCreateButton("-", 215, 95, 42, 29, 0)
$Misura_C2 = GUICtrlCreateCombo("mm", 166, 132, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$On_off_C2 = GUICtrlCreateButton("-", 216, 131, 42, 29, 0)
$Misura_2P = GUICtrlCreateCombo("mm", 167, 199, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$On_off_2P = GUICtrlCreateButton("-", 220, 198, 42, 29, 0)
$Label4 = GUICtrlCreateLabel("I:", 14, 166, 17, 23)
$Ipotenusa = GUICtrlCreateInput("", 53, 164, 105, 27)
$Misura_Ipotenusa = GUICtrlCreateCombo("mm", 166, 163, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$On_off_Ipotenusa = GUICtrlCreateButton("-", 218, 164, 42, 29, 0)
$I_Incognita = GUICtrlCreateButton("Incognita", 259, 162, 94, 32, 0)
$Labelx = GUICtrlCreateLabel("Altezza(I):", 13, 230, 68, 20)
GUICtrlSetFont(-1, 9, 800, 0, "Comic Sans MS")
$HP = GUICtrlCreateInput("", 85, 227, 75, 27)
$Misura_HP = GUICtrlCreateCombo("mm", 167, 229, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$On_off_HP = GUICtrlCreateButton("-", 221, 227, 42, 29, 0)
$HP_Incognita = GUICtrlCreateButton("Incognita", 262, 228, 90, 29, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlDelete($Calcola)
Global $Calcola = GUICtrlCreateButton("Calcola", 17, 262, 325, 50, 0)
GUICtrlDelete($Figura)
$Figura = GUICtrlCreatePic("Images\Triangolo Rettangolo.jpg", 371, 75, 235, 217)
;GUICtrlSetData(-1, "Figura")
$Flag1 = 1
$Flag2 = 0
$Flag3 = 0
$Flag4 = 0
$Flag5 = 0
EndIf
If $s_Tipe = "Triangolo Isoscele" And $Flag2 = 0 Then 
;Rettangolo
GUICtrlDelete($Group2)
GUICtrlDelete($Area)
GUICtrlDelete($Label2)
GUICtrlDelete($A_Incognita)
GUICtrlDelete($Label3)
GUICtrlDelete($Perimetro)
GUICtrlDelete($DUEP_Incognita)
GUICtrlDelete($Label5)
GUICtrlDelete($C2)
GUICtrlDelete($C2_Incognita)
GUICtrlDelete($Label)
GUICtrlDelete($C1)
GUICtrlDelete($C1_Incognita)
GUICtrlDelete($On_off_A)
GUICtrlDelete($Misura_A)
GUICtrlDelete($Misura_C1)
GUICtrlDelete($On_off_C1)
GUICtrlDelete($Misura_C2)
GUICtrlDelete($On_off_C2)
GUICtrlDelete($Misura_2P)
GUICtrlDelete($On_off_2P)
GUICtrlDelete($Label4)
GUICtrlDelete($Ipotenusa)
GUICtrlDelete($Misura_Ipotenusa)
GUICtrlDelete($On_off_Ipotenusa)
GUICtrlDelete($I_Incognita)
GUICtrlDelete($Labelx)
GUICtrlDelete($HP)
GUICtrlDelete($Misura_HP)
GUICtrlDelete($On_off_HP)
GUICtrlDelete($HP_Incognita)
;Isoscele ecc...
GUICtrlDelete($Group2)
GUICtrlDelete($Area)
GUICtrlDelete($Label2)
GUICtrlDelete($A_Incognita)
GUICtrlDelete($Label3)
GUICtrlDelete($Perimetro)
GUICtrlDelete($DUEP_Incognita)
GUICtrlDelete($Label5)
GUICtrlDelete($Altezza)
GUICtrlDelete($h_Incognita)
GUICtrlDelete($LabelBase)
GUICtrlDelete($Base)
GUICtrlDelete($B_Incognita)
GUICtrlDelete($On_off_A)
GUICtrlDelete($Misura_A)
GUICtrlDelete($Misura_B)
GUICtrlDelete($On_off_B)
GUICtrlDelete($Misura_h)
GUICtrlDelete($On_off_h)
GUICtrlDelete($Misura_2P)
GUICtrlDelete($On_off_2P)
Global $Group2 = GUICtrlCreateGroup("Dati", 10, 42, 345, 173)
Global $Area = GUICtrlCreateInput("", 54, 61, 106, 27)
Global $Label2 = GUICtrlCreateLabel("Area:", 12, 63, 40, 23)
Global $A_Incognita = GUICtrlCreateButton("Incognita", 257, 56, 94, 32, 0)
Global $Label3 = GUICtrlCreateLabel("Perimetro:", 13, 174, 70, 23)
Global $Perimetro = GUICtrlCreateInput("", 86, 168, 79, 27)
Global $DUEP_Incognita = GUICtrlCreateButton("Incognita", 262, 164, 90, 32, 0)
Global $Label5 = GUICtrlCreateLabel("Altezza:", 16, 137, 58, 23)
Global $Altezza = GUICtrlCreateInput("", 78, 133, 85, 27)
Global $h_Incognita = GUICtrlCreateButton("Incognita", 258, 130, 94, 32, 0)
Global $LabelBase = GUICtrlCreateLabel("Base:", 13, 101, 38, 23)
Global $Base = GUICtrlCreateInput("", 55, 97, 106, 27)
Global $B_Incognita = GUICtrlCreateButton("Incognita", 256, 95, 94, 32, 0)
Global $On_off_A = GUICtrlCreateButton("-", 214, 58, 42, 29, 0)
Global $Misura_A = GUICtrlCreateCombo("mm²", 164, 61, 49, 25)
GUICtrlSetData(-1, "cm²|dm²|m²|dam²|hm²|km²")
Global $Misura_B = GUICtrlCreateCombo("mm", 165, 95, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
Global $On_off_B = GUICtrlCreateButton("-", 215, 95, 42, 29, 0)
Global $Misura_h = GUICtrlCreateCombo("mm", 166, 132, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
Global $On_off_h = GUICtrlCreateButton("-", 216, 131, 42, 29, 0)
Global $Misura_2P = GUICtrlCreateCombo("mm", 168, 168, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
Global $On_off_2P = GUICtrlCreateButton("-", 218, 167, 42, 29, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlDelete($Calcola)
$Calcola = GUICtrlCreateButton("Calcola", 18, 233, 325, 50, 0)
GUICtrlDelete($Figura)
$Figura = GUICtrlCreatePic("Images\Triangolo Isoscele.jpg", 371, 75, 235, 217)
$Flag1 = 0
$Flag2 = 1
$Flag3 = 0
$Flag4 = 0
$Flag5 = 0
EndIf
If $s_Tipe = "Triangolo Equilatero" And $Flag3 = 0 Then 
;Rettangolo
GUICtrlDelete($Group2)
GUICtrlDelete($Area)
GUICtrlDelete($Label2)
GUICtrlDelete($A_Incognita)
GUICtrlDelete($Label3)
GUICtrlDelete($Perimetro)
GUICtrlDelete($DUEP_Incognita)
GUICtrlDelete($Label5)
GUICtrlDelete($C2)
GUICtrlDelete($C2_Incognita)
GUICtrlDelete($Label)
GUICtrlDelete($C1)
GUICtrlDelete($C1_Incognita)
GUICtrlDelete($On_off_A)
GUICtrlDelete($Misura_A)
GUICtrlDelete($Misura_C1)
GUICtrlDelete($On_off_C1)
GUICtrlDelete($Misura_C2)
GUICtrlDelete($On_off_C2)
GUICtrlDelete($Misura_2P)
GUICtrlDelete($On_off_2P)
GUICtrlDelete($Label4)
GUICtrlDelete($Ipotenusa)
GUICtrlDelete($Misura_Ipotenusa)
GUICtrlDelete($On_off_Ipotenusa)
GUICtrlDelete($I_Incognita)
GUICtrlDelete($Labelx)
GUICtrlDelete($HP)
GUICtrlDelete($Misura_HP)
GUICtrlDelete($On_off_HP)
GUICtrlDelete($HP_Incognita)
;Isoscele ecc...
GUICtrlDelete($Group2)
GUICtrlDelete($Area)
GUICtrlDelete($Label2)
GUICtrlDelete($A_Incognita)
GUICtrlDelete($Label3)
GUICtrlDelete($Perimetro)
GUICtrlDelete($DUEP_Incognita)
GUICtrlDelete($Label5)
GUICtrlDelete($Altezza)
GUICtrlDelete($h_Incognita)
GUICtrlDelete($LabelBase)
GUICtrlDelete($Base)
GUICtrlDelete($B_Incognita)
GUICtrlDelete($On_off_A)
GUICtrlDelete($Misura_A)
GUICtrlDelete($Misura_B)
GUICtrlDelete($On_off_B)
GUICtrlDelete($Misura_h)
GUICtrlDelete($On_off_h)
GUICtrlDelete($Misura_2P)
GUICtrlDelete($On_off_2P)
Global $Group2 = GUICtrlCreateGroup("Dati", 10, 42, 345, 173)
Global $Area = GUICtrlCreateInput("", 54, 61, 106, 27)
Global $Label2 = GUICtrlCreateLabel("Area:", 12, 63, 40, 23)
Global $A_Incognita = GUICtrlCreateButton("Incognita", 257, 56, 94, 32, 0)
Global $Label3 = GUICtrlCreateLabel("Perimetro:", 13, 174, 70, 23)
Global $Perimetro = GUICtrlCreateInput("", 86, 168, 79, 27)
Global $DUEP_Incognita = GUICtrlCreateButton("Incognita", 262, 164, 90, 32, 0)
Global $Label5 = GUICtrlCreateLabel("Altezza:", 16, 137, 58, 23)
Global $Altezza = GUICtrlCreateInput("", 78, 133, 85, 27)
Global $h_Incognita = GUICtrlCreateButton("Incognita", 258, 130, 94, 32, 0)
Global $LabelBase = GUICtrlCreateLabel("Base:", 13, 101, 38, 23)
Global $Base = GUICtrlCreateInput("", 55, 97, 106, 27)
Global $B_Incognita = GUICtrlCreateButton("Incognita", 256, 95, 94, 32, 0)
Global $On_off_A = GUICtrlCreateButton("-", 214, 58, 42, 29, 0)
Global $Misura_A = GUICtrlCreateCombo("mm²", 164, 61, 49, 25)
GUICtrlSetData(-1, "cm²|dm²|m²|dam²|hm²|km²")
Global $Misura_B = GUICtrlCreateCombo("mm", 165, 95, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
Global $On_off_B = GUICtrlCreateButton("-", 215, 95, 42, 29, 0)
Global $Misura_h = GUICtrlCreateCombo("mm", 166, 132, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
Global $On_off_h = GUICtrlCreateButton("-", 216, 131, 42, 29, 0)
Global $Misura_2P = GUICtrlCreateCombo("mm", 168, 168, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
Global $On_off_2P = GUICtrlCreateButton("-", 218, 167, 42, 29, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlDelete($Calcola)
$Calcola = GUICtrlCreateButton("Calcola", 18, 233, 325, 50, 0)
GUICtrlDelete($Figura)
$Figura = GUICtrlCreatePic("Images\Triangolo Equilatero.jpg", 371, 75, 235, 217)
$Flag1 = 0
$Flag2 = 0
$Flag3 = 1
$Flag4 = 0
$Flag5 = 0
EndIf
If $s_Tipe = "Triangolo Scaleno" And $Flag4 = 0 Then 
;Rettangolo
GUICtrlDelete($Group2)
GUICtrlDelete($Area)
GUICtrlDelete($Label2)
GUICtrlDelete($A_Incognita)
GUICtrlDelete($Label3)
GUICtrlDelete($Perimetro)
GUICtrlDelete($DUEP_Incognita)
GUICtrlDelete($Label5)
GUICtrlDelete($C2)
GUICtrlDelete($C2_Incognita)
GUICtrlDelete($Label)
GUICtrlDelete($C1)
GUICtrlDelete($C1_Incognita)
GUICtrlDelete($On_off_A)
GUICtrlDelete($Misura_A)
GUICtrlDelete($Misura_C1)
GUICtrlDelete($On_off_C1)
GUICtrlDelete($Misura_C2)
GUICtrlDelete($On_off_C2)
GUICtrlDelete($Misura_2P)
GUICtrlDelete($On_off_2P)
GUICtrlDelete($Label4)
GUICtrlDelete($Ipotenusa)
GUICtrlDelete($Misura_Ipotenusa)
GUICtrlDelete($On_off_Ipotenusa)
GUICtrlDelete($I_Incognita)
GUICtrlDelete($Labelx)
GUICtrlDelete($HP)
GUICtrlDelete($Misura_HP)
GUICtrlDelete($On_off_HP)
GUICtrlDelete($HP_Incognita)
;Isoscele ecc...
GUICtrlDelete($Group2)
GUICtrlDelete($Area)
GUICtrlDelete($Label2)
GUICtrlDelete($A_Incognita)
GUICtrlDelete($Label3)
GUICtrlDelete($Perimetro)
GUICtrlDelete($DUEP_Incognita)
GUICtrlDelete($Label5)
GUICtrlDelete($Altezza)
GUICtrlDelete($h_Incognita)
GUICtrlDelete($LabelBase)
GUICtrlDelete($Base)
GUICtrlDelete($B_Incognita)
GUICtrlDelete($On_off_A)
GUICtrlDelete($Misura_A)
GUICtrlDelete($Misura_B)
GUICtrlDelete($On_off_B)
GUICtrlDelete($Misura_h)
GUICtrlDelete($On_off_h)
GUICtrlDelete($Misura_2P)
GUICtrlDelete($On_off_2P)
Global $Group2 = GUICtrlCreateGroup("Dati", 10, 42, 345, 173)
Global $Area = GUICtrlCreateInput("", 54, 61, 106, 27)
Global $Label2 = GUICtrlCreateLabel("Area:", 12, 63, 40, 23)
Global $A_Incognita = GUICtrlCreateButton("Incognita", 257, 56, 94, 32, 0)
Global $Label3 = GUICtrlCreateLabel("Perimetro:", 13, 174, 70, 23)
Global $Perimetro = GUICtrlCreateInput("", 86, 168, 79, 27)
Global $DUEP_Incognita = GUICtrlCreateButton("Incognita", 262, 164, 90, 32, 0)
Global $Label5 = GUICtrlCreateLabel("Altezza:", 16, 137, 58, 23)
Global $Altezza = GUICtrlCreateInput("", 78, 133, 85, 27)
Global $h_Incognita = GUICtrlCreateButton("Incognita", 258, 130, 94, 32, 0)
Global $LabelBase = GUICtrlCreateLabel("Base:", 13, 101, 38, 23)
Global $Base = GUICtrlCreateInput("", 55, 97, 106, 27)
Global $B_Incognita = GUICtrlCreateButton("Incognita", 256, 95, 94, 32, 0)
Global $On_off_A = GUICtrlCreateButton("-", 214, 58, 42, 29, 0)
Global $Misura_A = GUICtrlCreateCombo("mm²", 164, 61, 49, 25)
GUICtrlSetData(-1, "cm²|dm²|m²|dam²|hm²|km²")
Global $Misura_B = GUICtrlCreateCombo("mm", 165, 95, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
Global $On_off_B = GUICtrlCreateButton("-", 215, 95, 42, 29, 0)
Global $Misura_h = GUICtrlCreateCombo("mm", 166, 132, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
Global $On_off_h = GUICtrlCreateButton("-", 216, 131, 42, 29, 0)
Global $Misura_2P = GUICtrlCreateCombo("mm", 168, 168, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
Global $On_off_2P = GUICtrlCreateButton("-", 218, 167, 42, 29, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlDelete($Calcola)
$Calcola = GUICtrlCreateButton("Calcola", 18, 233, 325, 50, 0)
GUICtrlDelete($Figura)
$Figura = GUICtrlCreatePic("Images\Triangolo Scaleno.jpg", 371, 75, 235, 217)
$Flag1 = 0
$Flag2 = 0
$Flag3 = 0
$Flag4 = 1
$Flag5 = 0
EndIf
If $Flag1 = 1 Then
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
;Incognite
Case $A_Incognita
GUICtrlSetData($Area, "?")
Case $DUEP_Incognita
GUICtrlSetData($Perimetro, "?")
Case $C1_Incognita
GUICtrlSetData($C1, "?")
Case $C2_Incognita
GUICtrlSetData($C2, "?")
Case $I_Incognita
GUICtrlSetData($Ipotenusa, "?")
Case $HP_Incognita
GUICtrlSetData($HP, "?")
;Disabilita
Case $On_off_A
If $FlagArea <> 3 Then
GUICtrlSetData($Area, "-")
GUICtrlSetData($On_off_A, "+")
GUICtrlSetState($Area, $GUI_Disable)
$FlagArea = 3
Else
GUICtrlSetData($Area, "")
GUICtrlSetState($Area, $GUI_Enable)
GUICtrlSetData($On_off_A, "-")
$FlagArea = 0
EndIf
Case $On_off_2P
If $FlagPerimetro <> 3 Then
GUICtrlSetData($Perimetro, "-")
GUICtrlSetData($On_off_2P, "+")
GUICtrlSetState($Perimetro, $GUI_Disable)
$FlagPerimetro = 3
Else
GUICtrlSetData($Perimetro, "")
GUICtrlSetState($Perimetro, $GUI_Enable)
GUICtrlSetData($On_off_2P, "-")
$FlagPerimetro = 0
EndIf
Case $On_off_C1
If $FlagC1 <> 3 Then
GUICtrlSetData($C1, "-")
GUICtrlSetData($On_off_C1, "+")
GUICtrlSetState($C1, $GUI_Disable)
$FlagC1 = 3
Else
GUICtrlSetData($C1, "")
GUICtrlSetState($C1, $GUI_Enable)
GUICtrlSetData($On_off_C1, "-")
$FlagC1 = 0
EndIf
Case $On_off_C2
If $FlagC2 <> 3 Then
GUICtrlSetData($C2, "-")
GUICtrlSetData($On_off_C2, "+")
GUICtrlSetState($C2, $GUI_Disable)
$FlagC2 = 3
Else
GUICtrlSetData($C2, "")
GUICtrlSetState($C2, $GUI_Enable)
GUICtrlSetData($On_off_C2, "-")
$FlagC2 = 0
EndIf
Case $On_off_Ipotenusa
If $FlagIpotenusa <> 3 Then
GUICtrlSetData($Ipotenusa, "-")
GUICtrlSetData($On_off_Ipotenusa, "+")
GUICtrlSetState($Ipotenusa, $GUI_Disable)
$FlagIpotenusa = 3
Else
GUICtrlSetData($Ipotenusa, "")
GUICtrlSetState($Ipotenusa, $GUI_Enable)
GUICtrlSetData($On_off_Ipotenusa, "-")
$FlagIpotenusa = 0
EndIf
Case $On_off_HP
If $FlagHP <> 3 Then
GUICtrlSetData($HP, "-")
GUICtrlSetData($On_off_HP, "+")
GUICtrlSetState($HP, $GUI_Disable)
$FlagHP = 3
Else
GUICtrlSetData($HP, "")
GUICtrlSetState($HP, $GUI_Enable)
GUICtrlSetData($On_off_HP, "-")
$FlagHP = 0
EndIf
;Azzera
Case $Azzera
GUICtrlSetData($Area, "")
GUICtrlSetData($Perimetro, "")
GUICtrlSetData($C1, "")
GUICtrlSetData($C2, "")
GUICtrlSetData($Ipotenusa, "")
GUICtrlSetData($HP, "")
GUICtrlSetData($Edit_Incognite, "")
GUICtrlSetData($Edit_Procedimento, "")
GUICtrlSetState($Area, $GUI_Enable)
GUICtrlSetState($Perimetro, $GUI_Enable)
GUICtrlSetState($C1, $GUI_Enable)
GUICtrlSetState($C2, $GUI_Enable)
GUICtrlSetState($Ipotenusa, $GUI_Enable)
GUICtrlSetState($HP, $GUI_Enable)
GUICtrlSetData($Edit_Incognite, "")
GUICtrlSetData($Edit_Procedimento, "")
Global $FlagArea = 0
Global $FlagPerimetro = 0
Global $FlagC1 = 0
Global $FlagC2 = 0
Global $FlagIpotenusa = 0
Global $FlagHP = 0
Global $Flag2Area = 0
Global $Flag2Perimetro = 0
Global $Flag2C1 = 0
Global $Flag2C2 = 0
Global $Flag2Ipotenusa = 0
Global $Flag2HP = 0
GUICtrlSetData($On_off_A, "-")
GUICtrlSetData($On_off_2P, "-")
GUICtrlSetData($On_off_C1, "-")
GUICtrlSetData($On_off_C2, "-")
GUICtrlSetData($On_off_Ipotenusa, "-")
GUICtrlSetData($On_off_HP, "-")
;Calcola
Case $Calcola
Global $s_Misura_Comune = "dm"
Global $s_Misura_Ipotenusa = "cm"
Global $s_Ipotenusa = "136"
Global $s_C1 = 12
Global $s_Area = "?"
Global $s_C2 = "-"
Global $s_2P = "-"
Global $s_HP = "-"
_Equivalenza($s_Misura_Ipotenusa, $s_Ipotenusa, "I", 0)
EndSwitch
EndIf
If $Flag2 = 1 Then
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $A_Incognita
GUICtrlSetData($Area, "?")
Case $DUEP_Incognita
GUICtrlSetData($Perimetro, "?")
Case $B_Incognita
GUICtrlSetData($Base, "?")
Case $h_Incognita
GUICtrlSetData($Altezza, "?")
EndSwitch
EndIf
If $Flag3 = 1 Then
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $A_Incognita
GUICtrlSetData($Area, "?")
Case $DUEP_Incognita
GUICtrlSetData($Perimetro, "?")
Case $B_Incognita
GUICtrlSetData($Base, "?")
Case $h_Incognita
GUICtrlSetData($Altezza, "?")
EndSwitch
EndIf
If $Flag4 = 1 Then
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $A_Incognita
GUICtrlSetData($Area, "?")
Case $DUEP_Incognita
GUICtrlSetData($Perimetro, "?")
Case $B_Incognita
GUICtrlSetData($Base, "?")
Case $h_Incognita
GUICtrlSetData($Altezza, "?")
EndSwitch
EndIf
WEnd
EndFunc


Func _Equivalenza($s_Misura, $s_E, $Simbolo, $Quadrato)
If $s_Misura <> $s_Misura_Comune Then
If $s_Misura = "cm" And $s_Misura_Comune = "mm" Then
$r_E = $s_E * 10
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "dm" And $s_Misura_Comune = "mm" Then
$r_E = $s_E * 100
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "m" And $s_Misura_Comune = "mm" Then
$r_E = $s_E * 1000
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "dam" And $s_Misura_Comune = "mm" Then
$r_E = $s_E * 10000
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "hm" And $s_Misura_Comune = "mm" Then
$r_E = $s_E * 100000
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "km" And $s_Misura_Comune = "mm" Then
$r_E = $s_E * 10000
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "mm" And $s_Misura_Comune = "cm" Then
$r_E = $s_E / 10
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "dm" And $s_Misura_Comune = "cm" Then
$r_E = $s_E * 10
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "m" And $s_Misura_Comune = "cm" Then
$r_E = $s_E * 100
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "dam" And $s_Misura_Comune = "cm" Then
$r_E = $s_E * 1000
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "hm" And $s_Misura_Comune = "cm" Then
$r_E = $s_E * 10000
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "km" And $s_Misura_Comune = "cm" Then
$r_E = $s_E * 100000
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "mm" And $s_Misura_Comune = "dm" Then
$r_E = $s_E / 100
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "cm" And $s_Misura_Comune = "dm" Then
$r_E = $s_E / 10
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "m" And $s_Misura_Comune = "dm" Then
$r_E = $s_E * 10
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "dam" And $s_Misura_Comune = "dm" Then
$r_E = $s_E * 100
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "hm" And $s_Misura_Comune = "dm" Then
$r_E = $s_E * 1000
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "km" And $s_Misura_Comune = "dm" Then
$r_E = $s_E * 10000
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "mm" And $s_Misura_Comune = "m" Then
$r_E = $s_E / 1000
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "cm" And $s_Misura_Comune = "m" Then
$r_E = $s_E / 100
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "dm" And $s_Misura_Comune = "m" Then
$r_E = $s_E / 10
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "dam" And $s_Misura_Comune = "m" Then
$r_E = $s_E * 10
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "hm" And $s_Misura_Comune = "m" Then
$r_E = $s_E * 100
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "km" And $s_Misura_Comune = "m" Then
$r_E = $s_E * 1000
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "mm" And $s_Misura_Comune = "dam" Then
$r_E = $s_E / 10000
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "cm" And $s_Misura_Comune = "dam" Then
$r_E = $s_E / 1000
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "dm" And $s_Misura_Comune = "dam" Then
$r_E = $s_E / 100
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "m" And $s_Misura_Comune = "dam" Then
$r_E = $s_E / 10
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "hm" And $s_Misura_Comune = "dam" Then
$r_E = $s_E * 10
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "km" And $s_Misura_Comune = "dam" Then
$r_E = $s_E * 100
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "mm" And $s_Misura_Comune = "hm" Then
$r_E = $s_E / 100000
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "cm" And $s_Misura_Comune = "hm" Then
$r_E = $s_E / 10000
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "dm" And $s_Misura_Comune = "hm" Then
$r_E = $s_E / 1000
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "m" And $s_Misura_Comune = "hm" Then
$r_E = $s_E / 100
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "dam" And $s_Misura_Comune = "hm" Then
$r_E = $s_E / 10
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "km" And $s_Misura_Comune = "hm" Then
$r_E = $s_E * 10
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "mm" And $s_Misura_Comune = "km" Then
$r_E = $s_E / 1000000
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "cm" And $s_Misura_Comune = "km" Then
$r_E = $s_E / 100000
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "dm" And $s_Misura_Comune = "km" Then
$r_E = $s_E / 10000
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "m" And $s_Misura_Comune = "km" Then
$r_E = $s_E / 1000
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "dam" And $s_Misura_Comune = "km" Then
$r_E = $s_E / 100
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf

If $s_Misura = "hm" And $s_Misura_Comune = "km" Then
$r_E = $s_E / 10
If $Quadrato = 1 Then
$s_Misura = $s_Misura & "²"
$s_Misura_Comune = $s_Misura_Comune & "²"
EndIf
_GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
Global $s_E = $r_E
EndIf
EndIf
EndFunc

How can I fix it?

Thank you all in advance :unsure:.

Edited by Sym98

Share this post


Link to post
Share on other sites



For not to post the entire code of the program, I shrunk it:

I see some room to schrink it more ^^

To fix your error:

;replace all these lines:
Global $s_E = $r_E
;with this:
$s_E = $r_E

You can use Ctrl+h to do the replacement.

Share this post


Link to post
Share on other sites

Yes, but the variable must also be used outside the function ...

Share this post


Link to post
Share on other sites

You should only be declaring the variable once at the top of the script, after that you can set its value anywhere in the script and it will be accessible from anywhere. What you're doing is redeclaring it 42 times in your script, that's not going to work.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Thanks, now works :unsure:

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Here is a suggestions to schrink your _Equivalenza() function. I think I left the functionality intact, but I have no time to test now.

;Script Created By Sym98
#include <GUIConstants.au3>
#include <GUIEdit.au3>
#include<array.au3>

Global $asUnits = StringSplit("mm,cm,dm,m,dam,hm,km", ",")
Global $s_E, $s_Misura_Comune
;Variabili
Global $FlagArea = 0
Global $FlagPerimetro = 0
Global $FlagC1 = 0
Global $FlagC2 = 0
Global $FlagIpotenusa = 0
Global $FlagHP = 0
Global $Flag2Area = 0
Global $Flag2Perimetro = 0
Global $Flag2C1 = 0
Global $Flag2C2 = 0
Global $Flag2Ipotenusa = 0
Global $Flag2HP = 0
Global $FlagDisableArea = 1
Global $FlagDisablePerimetro = 1
Global $FlagDisableC1T = 1
Global $FlagDisableC2T = 1
Global $FlagDisableC1 = 1
Global $FlagDisableC2 = 1
Global $FlagDisableIpotenusa = 1
Global $FlagDisableHP = 1
Global $FlagEquivalenzaArea = 0
Global $FlagEquivalenzaPerimetro = 0
Global $FlagEquivalenzaC1 = 0
Global $FlagEquivalenzaC2 = 0
Global $FlagEquivalenzaIpotenusa = 0
Global $FlagEquivalenzaHP = 0
Global $Area, $Label2, $A_Incognita, $Label3, $Perimetro, $DUEP_Incognita, _
        $Label5, $C2, $C2_Incognita, $Altezza, $h_Incognita, $Label5, $LabelBase, _
        $Base, $B_Incognita, $On_off_A, $Misura_A, $Misura_B, $On_off_B, $Misura_h, $On_off_h, $Misura_2P, $On_off_2P, $Label, $Label6, $Misura_Comune
Global $Flag1 = 1
Global $Flag2 = 0
Global $Flag3 = 0
Global $Flag4 = 0
Global $Flag5 = 0
Global $FlagMisura = "mm"



;GUI
Global $GUI = GUICreate("SGP - Solve Geometric Problems By Sym98", 625, 522)
GUISetFont(10, 800, 0, "Comic Sans MS")
Global $Group1 = GUICtrlCreateGroup("Figura", 366, 53, 244, 242)
Global $Figura = GUICtrlCreatePic("Images\Triangolo Rettangolo.jpg", 371, 73, 235, 217)
GUICtrlSetData(-1, "Figura")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Tipe = GUICtrlCreateCombo("Triangolo Rettangolo", 366, 28, 243, 25)
GUICtrlSetData(-1, "Triangolo Isoscele|Triangolo Equilatero|Triangolo Scaleno")
Global $Label1 = GUICtrlCreateLabel("Solve Geometric Problems", 9, 3, 305, 39)
GUICtrlSetFont(-1, 18, 800, 0, "Comic Sans MS")
$Calcola = GUICtrlCreateButton("Calcola", 17, 262, 325, 50, 0)
$Group2 = GUICtrlCreateGroup("Dati", 10, 42, 345, 219)
$Area = GUICtrlCreateInput("", 54, 61, 106, 27)
$Label2 = GUICtrlCreateLabel("Area:", 12, 63, 40, 23)
$A_Incognita = GUICtrlCreateButton("Incognita", 257, 56, 94, 32, 0)
$Label3 = GUICtrlCreateLabel("Perimetro:", 12, 202, 70, 23)
$Perimetro = GUICtrlCreateInput("", 81, 198, 79, 27)
$DUEP_Incognita = GUICtrlCreateButton("Incognita", 263, 196, 90, 32, 0)
$Label5 = GUICtrlCreateLabel("C2:", 16, 137, 26, 23)
$C2 = GUICtrlCreateInput("", 54, 133, 105, 27)
$C2_Incognita = GUICtrlCreateButton("Incognita", 258, 130, 94, 32, 0)
$Label = GUICtrlCreateLabel("C1:", 13, 101, 26, 23)
$C1 = GUICtrlCreateInput("", 55, 97, 106, 27)
$C1_Incognita = GUICtrlCreateButton("Incognita", 258, 94, 94, 32, 0)
$On_off_A = GUICtrlCreateButton("-", 214, 58, 42, 29, 0)
$Misura_A = GUICtrlCreateCombo("mm²", 164, 61, 49, 25)
GUICtrlSetData(-1, "cm²|dm²|m²|dam²|hm²|km²")
$Misura_C1 = GUICtrlCreateCombo("mm", 165, 95, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$On_off_C1 = GUICtrlCreateButton("-", 215, 95, 42, 29, 0)
$Misura_C2 = GUICtrlCreateCombo("mm", 166, 132, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$On_off_C2 = GUICtrlCreateButton("-", 216, 131, 42, 29, 0)
$Misura_2P = GUICtrlCreateCombo("mm", 167, 199, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$On_off_2P = GUICtrlCreateButton("-", 220, 198, 42, 29, 0)
$Label4 = GUICtrlCreateLabel("I:", 14, 166, 17, 23)
$Ipotenusa = GUICtrlCreateInput("", 53, 164, 105, 27)
$Misura_Ipotenusa = GUICtrlCreateCombo("mm", 166, 163, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$On_off_Ipotenusa = GUICtrlCreateButton("-", 218, 164, 42, 29, 0)
$I_Incognita = GUICtrlCreateButton("Incognita", 259, 162, 94, 32, 0)
$Labelx = GUICtrlCreateLabel("Altezza(I):", 13, 230, 68, 20)
GUICtrlSetFont(-1, 9, 800, 0, "Comic Sans MS")
$HP = GUICtrlCreateInput("", 85, 227, 75, 27)
$Misura_HP = GUICtrlCreateCombo("mm", 167, 229, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$On_off_HP = GUICtrlCreateButton("-", 221, 227, 42, 29, 0)
$HP_Incognita = GUICtrlCreateButton("Incognita", 262, 228, 90, 29, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group3 = GUICtrlCreateGroup("Procedimento", 291, 319, 322, 125)
Global $Edit_Procedimento = GUICtrlCreateEdit("", 291, 336, 321, 107)
GUICtrlSetData(-1, "")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("Incognite", 16, 311, 261, 132)
$Edit_Incognite = GUICtrlCreateEdit("", 19, 331, 255, 113)
GUICtrlSetData(-1, "")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Label7 = GUICtrlCreateLabel("Created By Sym98", 391, 457, 222, 39)
GUICtrlSetFont(-1, 18, 800, 0, "Comic Sans MS")
Global $Azzera = GUICtrlCreateButton("Azzera", 15, 452, 366, 45, 0)
$Misura_Comune = GUICtrlCreateCombo("mm", 539, 295, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$Label6 = GUICtrlCreateLabel("Unità di misura comune:", 372, 297, 159, 23)
GUISetState(@SW_SHOW)

;While
_Main()
Func _Main()
    While 1
        Global $s_Area = GUICtrlRead($Area)
        Global $s_C1 = GUICtrlRead($C1)
        Global $s_C2 = GUICtrlRead($C2)
        Global $s_Ipotenusa = GUICtrlRead($Ipotenusa)
        Global $s_Perimetro = GUICtrlRead($Perimetro)
        Global $s_HP = GUICtrlRead($HP)
        Global $s_Tipe = GUICtrlRead($Tipe)
        Global $s_Misura_Comune = GUICtrlRead($Misura_Comune)
        If $s_Tipe = "Triangolo Rettangolo" And $Flag1 = 0 Then
            ;Rettangolo
            GUICtrlDelete($Group2)
            GUICtrlDelete($Area)
            GUICtrlDelete($Label2)
            GUICtrlDelete($A_Incognita)
            GUICtrlDelete($Label3)
            GUICtrlDelete($Perimetro)
            GUICtrlDelete($DUEP_Incognita)
            GUICtrlDelete($Label5)
            GUICtrlDelete($C2)
            GUICtrlDelete($C2_Incognita)
            GUICtrlDelete($Label)
            GUICtrlDelete($C1)
            GUICtrlDelete($C1_Incognita)
            GUICtrlDelete($On_off_A)
            GUICtrlDelete($Misura_A)
            GUICtrlDelete($Misura_C1)
            GUICtrlDelete($On_off_C1)
            GUICtrlDelete($Misura_C2)
            GUICtrlDelete($On_off_C2)
            GUICtrlDelete($Misura_2P)
            GUICtrlDelete($On_off_2P)
            GUICtrlDelete($Label4)
            GUICtrlDelete($Ipotenusa)
            GUICtrlDelete($Misura_Ipotenusa)
            GUICtrlDelete($On_off_Ipotenusa)
            GUICtrlDelete($I_Incognita)
            GUICtrlDelete($Labelx)
            GUICtrlDelete($HP)
            GUICtrlDelete($Misura_HP)
            GUICtrlDelete($On_off_HP)
            GUICtrlDelete($HP_Incognita)
            ;Isoscele ecc...
            GUICtrlDelete($Group2)
            GUICtrlDelete($Area)
            GUICtrlDelete($Label2)
            GUICtrlDelete($A_Incognita)
            GUICtrlDelete($Label3)
            GUICtrlDelete($Perimetro)
            GUICtrlDelete($DUEP_Incognita)
            GUICtrlDelete($Label5)
            GUICtrlDelete($Altezza)
            GUICtrlDelete($h_Incognita)
            GUICtrlDelete($LabelBase)
            GUICtrlDelete($Base)
            GUICtrlDelete($B_Incognita)
            GUICtrlDelete($On_off_A)
            GUICtrlDelete($Misura_A)
            GUICtrlDelete($Misura_B)
            GUICtrlDelete($On_off_B)
            GUICtrlDelete($Misura_h)
            GUICtrlDelete($On_off_h)
            GUICtrlDelete($Misura_2P)
            GUICtrlDelete($On_off_2P)
            $Group2 = GUICtrlCreateGroup("Dati", 10, 42, 345, 219)
            $Area = GUICtrlCreateInput("", 54, 61, 106, 27)
            $Label2 = GUICtrlCreateLabel("Area:", 12, 63, 40, 23)
            $A_Incognita = GUICtrlCreateButton("Incognita", 257, 56, 94, 32, 0)
            $Label3 = GUICtrlCreateLabel("Perimetro:", 12, 202, 70, 23)
            $Perimetro = GUICtrlCreateInput("", 81, 198, 79, 27)
            $DUEP_Incognita = GUICtrlCreateButton("Incognita", 263, 196, 90, 32, 0)
            $Label5 = GUICtrlCreateLabel("C2:", 16, 137, 26, 23)
            $C2 = GUICtrlCreateInput("", 54, 133, 105, 27)
            $C2_Incognita = GUICtrlCreateButton("Incognita", 258, 130, 94, 32, 0)
            $Label = GUICtrlCreateLabel("C1:", 13, 101, 26, 23)
            $C1 = GUICtrlCreateInput("", 55, 97, 106, 27)
            $C1_Incognita = GUICtrlCreateButton("Incognita", 258, 94, 94, 32, 0)
            $On_off_A = GUICtrlCreateButton("-", 214, 58, 42, 29, 0)
            $Misura_A = GUICtrlCreateCombo("mm²", 164, 61, 49, 25)
            GUICtrlSetData(-1, "cm²|dm²|m²|dam²|hm²|km²")
            $Misura_C1 = GUICtrlCreateCombo("mm", 165, 95, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            $On_off_C1 = GUICtrlCreateButton("-", 215, 95, 42, 29, 0)
            $Misura_C2 = GUICtrlCreateCombo("mm", 166, 132, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            $On_off_C2 = GUICtrlCreateButton("-", 216, 131, 42, 29, 0)
            $Misura_2P = GUICtrlCreateCombo("mm", 167, 199, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            $On_off_2P = GUICtrlCreateButton("-", 220, 198, 42, 29, 0)
            $Label4 = GUICtrlCreateLabel("I:", 14, 166, 17, 23)
            $Ipotenusa = GUICtrlCreateInput("", 53, 164, 105, 27)
            $Misura_Ipotenusa = GUICtrlCreateCombo("mm", 166, 163, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            $On_off_Ipotenusa = GUICtrlCreateButton("-", 218, 164, 42, 29, 0)
            $I_Incognita = GUICtrlCreateButton("Incognita", 259, 162, 94, 32, 0)
            $Labelx = GUICtrlCreateLabel("Altezza(I):", 13, 230, 68, 20)
            GUICtrlSetFont(-1, 9, 800, 0, "Comic Sans MS")
            $HP = GUICtrlCreateInput("", 85, 227, 75, 27)
            $Misura_HP = GUICtrlCreateCombo("mm", 167, 229, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            $On_off_HP = GUICtrlCreateButton("-", 221, 227, 42, 29, 0)
            $HP_Incognita = GUICtrlCreateButton("Incognita", 262, 228, 90, 29, 0)
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            GUICtrlDelete($Calcola)
            Global $Calcola = GUICtrlCreateButton("Calcola", 17, 262, 325, 50, 0)
            GUICtrlDelete($Figura)
            $Figura = GUICtrlCreatePic("Images\Triangolo Rettangolo.jpg", 371, 75, 235, 217)
            ;GUICtrlSetData(-1, "Figura")
            $Flag1 = 1
            $Flag2 = 0
            $Flag3 = 0
            $Flag4 = 0
            $Flag5 = 0
        EndIf
        If $s_Tipe = "Triangolo Isoscele" And $Flag2 = 0 Then
            ;Rettangolo
            GUICtrlDelete($Group2)
            GUICtrlDelete($Area)
            GUICtrlDelete($Label2)
            GUICtrlDelete($A_Incognita)
            GUICtrlDelete($Label3)
            GUICtrlDelete($Perimetro)
            GUICtrlDelete($DUEP_Incognita)
            GUICtrlDelete($Label5)
            GUICtrlDelete($C2)
            GUICtrlDelete($C2_Incognita)
            GUICtrlDelete($Label)
            GUICtrlDelete($C1)
            GUICtrlDelete($C1_Incognita)
            GUICtrlDelete($On_off_A)
            GUICtrlDelete($Misura_A)
            GUICtrlDelete($Misura_C1)
            GUICtrlDelete($On_off_C1)
            GUICtrlDelete($Misura_C2)
            GUICtrlDelete($On_off_C2)
            GUICtrlDelete($Misura_2P)
            GUICtrlDelete($On_off_2P)
            GUICtrlDelete($Label4)
            GUICtrlDelete($Ipotenusa)
            GUICtrlDelete($Misura_Ipotenusa)
            GUICtrlDelete($On_off_Ipotenusa)
            GUICtrlDelete($I_Incognita)
            GUICtrlDelete($Labelx)
            GUICtrlDelete($HP)
            GUICtrlDelete($Misura_HP)
            GUICtrlDelete($On_off_HP)
            GUICtrlDelete($HP_Incognita)
            ;Isoscele ecc...
            GUICtrlDelete($Group2)
            GUICtrlDelete($Area)
            GUICtrlDelete($Label2)
            GUICtrlDelete($A_Incognita)
            GUICtrlDelete($Label3)
            GUICtrlDelete($Perimetro)
            GUICtrlDelete($DUEP_Incognita)
            GUICtrlDelete($Label5)
            GUICtrlDelete($Altezza)
            GUICtrlDelete($h_Incognita)
            GUICtrlDelete($LabelBase)
            GUICtrlDelete($Base)
            GUICtrlDelete($B_Incognita)
            GUICtrlDelete($On_off_A)
            GUICtrlDelete($Misura_A)
            GUICtrlDelete($Misura_B)
            GUICtrlDelete($On_off_B)
            GUICtrlDelete($Misura_h)
            GUICtrlDelete($On_off_h)
            GUICtrlDelete($Misura_2P)
            GUICtrlDelete($On_off_2P)
            Global $Group2 = GUICtrlCreateGroup("Dati", 10, 42, 345, 173)
            Global $Area = GUICtrlCreateInput("", 54, 61, 106, 27)
            Global $Label2 = GUICtrlCreateLabel("Area:", 12, 63, 40, 23)
            Global $A_Incognita = GUICtrlCreateButton("Incognita", 257, 56, 94, 32, 0)
            Global $Label3 = GUICtrlCreateLabel("Perimetro:", 13, 174, 70, 23)
            Global $Perimetro = GUICtrlCreateInput("", 86, 168, 79, 27)
            Global $DUEP_Incognita = GUICtrlCreateButton("Incognita", 262, 164, 90, 32, 0)
            Global $Label5 = GUICtrlCreateLabel("Altezza:", 16, 137, 58, 23)
            Global $Altezza = GUICtrlCreateInput("", 78, 133, 85, 27)
            Global $h_Incognita = GUICtrlCreateButton("Incognita", 258, 130, 94, 32, 0)
            Global $LabelBase = GUICtrlCreateLabel("Base:", 13, 101, 38, 23)
            Global $Base = GUICtrlCreateInput("", 55, 97, 106, 27)
            Global $B_Incognita = GUICtrlCreateButton("Incognita", 256, 95, 94, 32, 0)
            Global $On_off_A = GUICtrlCreateButton("-", 214, 58, 42, 29, 0)
            Global $Misura_A = GUICtrlCreateCombo("mm²", 164, 61, 49, 25)
            GUICtrlSetData(-1, "cm²|dm²|m²|dam²|hm²|km²")
            Global $Misura_B = GUICtrlCreateCombo("mm", 165, 95, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            Global $On_off_B = GUICtrlCreateButton("-", 215, 95, 42, 29, 0)
            Global $Misura_h = GUICtrlCreateCombo("mm", 166, 132, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            Global $On_off_h = GUICtrlCreateButton("-", 216, 131, 42, 29, 0)
            Global $Misura_2P = GUICtrlCreateCombo("mm", 168, 168, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            Global $On_off_2P = GUICtrlCreateButton("-", 218, 167, 42, 29, 0)
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            GUICtrlDelete($Calcola)
            $Calcola = GUICtrlCreateButton("Calcola", 18, 233, 325, 50, 0)
            GUICtrlDelete($Figura)
            $Figura = GUICtrlCreatePic("Images\Triangolo Isoscele.jpg", 371, 75, 235, 217)
            $Flag1 = 0
            $Flag2 = 1
            $Flag3 = 0
            $Flag4 = 0
            $Flag5 = 0
        EndIf
        If $s_Tipe = "Triangolo Equilatero" And $Flag3 = 0 Then
            ;Rettangolo
            GUICtrlDelete($Group2)
            GUICtrlDelete($Area)
            GUICtrlDelete($Label2)
            GUICtrlDelete($A_Incognita)
            GUICtrlDelete($Label3)
            GUICtrlDelete($Perimetro)
            GUICtrlDelete($DUEP_Incognita)
            GUICtrlDelete($Label5)
            GUICtrlDelete($C2)
            GUICtrlDelete($C2_Incognita)
            GUICtrlDelete($Label)
            GUICtrlDelete($C1)
            GUICtrlDelete($C1_Incognita)
            GUICtrlDelete($On_off_A)
            GUICtrlDelete($Misura_A)
            GUICtrlDelete($Misura_C1)
            GUICtrlDelete($On_off_C1)
            GUICtrlDelete($Misura_C2)
            GUICtrlDelete($On_off_C2)
            GUICtrlDelete($Misura_2P)
            GUICtrlDelete($On_off_2P)
            GUICtrlDelete($Label4)
            GUICtrlDelete($Ipotenusa)
            GUICtrlDelete($Misura_Ipotenusa)
            GUICtrlDelete($On_off_Ipotenusa)
            GUICtrlDelete($I_Incognita)
            GUICtrlDelete($Labelx)
            GUICtrlDelete($HP)
            GUICtrlDelete($Misura_HP)
            GUICtrlDelete($On_off_HP)
            GUICtrlDelete($HP_Incognita)
            ;Isoscele ecc...
            GUICtrlDelete($Group2)
            GUICtrlDelete($Area)
            GUICtrlDelete($Label2)
            GUICtrlDelete($A_Incognita)
            GUICtrlDelete($Label3)
            GUICtrlDelete($Perimetro)
            GUICtrlDelete($DUEP_Incognita)
            GUICtrlDelete($Label5)
            GUICtrlDelete($Altezza)
            GUICtrlDelete($h_Incognita)
            GUICtrlDelete($LabelBase)
            GUICtrlDelete($Base)
            GUICtrlDelete($B_Incognita)
            GUICtrlDelete($On_off_A)
            GUICtrlDelete($Misura_A)
            GUICtrlDelete($Misura_B)
            GUICtrlDelete($On_off_B)
            GUICtrlDelete($Misura_h)
            GUICtrlDelete($On_off_h)
            GUICtrlDelete($Misura_2P)
            GUICtrlDelete($On_off_2P)
            Global $Group2 = GUICtrlCreateGroup("Dati", 10, 42, 345, 173)
            Global $Area = GUICtrlCreateInput("", 54, 61, 106, 27)
            Global $Label2 = GUICtrlCreateLabel("Area:", 12, 63, 40, 23)
            Global $A_Incognita = GUICtrlCreateButton("Incognita", 257, 56, 94, 32, 0)
            Global $Label3 = GUICtrlCreateLabel("Perimetro:", 13, 174, 70, 23)
            Global $Perimetro = GUICtrlCreateInput("", 86, 168, 79, 27)
            Global $DUEP_Incognita = GUICtrlCreateButton("Incognita", 262, 164, 90, 32, 0)
            Global $Label5 = GUICtrlCreateLabel("Altezza:", 16, 137, 58, 23)
            Global $Altezza = GUICtrlCreateInput("", 78, 133, 85, 27)
            Global $h_Incognita = GUICtrlCreateButton("Incognita", 258, 130, 94, 32, 0)
            Global $LabelBase = GUICtrlCreateLabel("Base:", 13, 101, 38, 23)
            Global $Base = GUICtrlCreateInput("", 55, 97, 106, 27)
            Global $B_Incognita = GUICtrlCreateButton("Incognita", 256, 95, 94, 32, 0)
            Global $On_off_A = GUICtrlCreateButton("-", 214, 58, 42, 29, 0)
            Global $Misura_A = GUICtrlCreateCombo("mm²", 164, 61, 49, 25)
            GUICtrlSetData(-1, "cm²|dm²|m²|dam²|hm²|km²")
            Global $Misura_B = GUICtrlCreateCombo("mm", 165, 95, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            Global $On_off_B = GUICtrlCreateButton("-", 215, 95, 42, 29, 0)
            Global $Misura_h = GUICtrlCreateCombo("mm", 166, 132, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            Global $On_off_h = GUICtrlCreateButton("-", 216, 131, 42, 29, 0)
            Global $Misura_2P = GUICtrlCreateCombo("mm", 168, 168, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            Global $On_off_2P = GUICtrlCreateButton("-", 218, 167, 42, 29, 0)
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            GUICtrlDelete($Calcola)
            $Calcola = GUICtrlCreateButton("Calcola", 18, 233, 325, 50, 0)
            GUICtrlDelete($Figura)
            $Figura = GUICtrlCreatePic("Images\Triangolo Equilatero.jpg", 371, 75, 235, 217)
            $Flag1 = 0
            $Flag2 = 0
            $Flag3 = 1
            $Flag4 = 0
            $Flag5 = 0
        EndIf
        If $s_Tipe = "Triangolo Scaleno" And $Flag4 = 0 Then
            ;Rettangolo
            GUICtrlDelete($Group2)
            GUICtrlDelete($Area)
            GUICtrlDelete($Label2)
            GUICtrlDelete($A_Incognita)
            GUICtrlDelete($Label3)
            GUICtrlDelete($Perimetro)
            GUICtrlDelete($DUEP_Incognita)
            GUICtrlDelete($Label5)
            GUICtrlDelete($C2)
            GUICtrlDelete($C2_Incognita)
            GUICtrlDelete($Label)
            GUICtrlDelete($C1)
            GUICtrlDelete($C1_Incognita)
            GUICtrlDelete($On_off_A)
            GUICtrlDelete($Misura_A)
            GUICtrlDelete($Misura_C1)
            GUICtrlDelete($On_off_C1)
            GUICtrlDelete($Misura_C2)
            GUICtrlDelete($On_off_C2)
            GUICtrlDelete($Misura_2P)
            GUICtrlDelete($On_off_2P)
            GUICtrlDelete($Label4)
            GUICtrlDelete($Ipotenusa)
            GUICtrlDelete($Misura_Ipotenusa)
            GUICtrlDelete($On_off_Ipotenusa)
            GUICtrlDelete($I_Incognita)
            GUICtrlDelete($Labelx)
            GUICtrlDelete($HP)
            GUICtrlDelete($Misura_HP)
            GUICtrlDelete($On_off_HP)
            GUICtrlDelete($HP_Incognita)
            ;Isoscele ecc...
            GUICtrlDelete($Group2)
            GUICtrlDelete($Area)
            GUICtrlDelete($Label2)
            GUICtrlDelete($A_Incognita)
            GUICtrlDelete($Label3)
            GUICtrlDelete($Perimetro)
            GUICtrlDelete($DUEP_Incognita)
            GUICtrlDelete($Label5)
            GUICtrlDelete($Altezza)
            GUICtrlDelete($h_Incognita)
            GUICtrlDelete($LabelBase)
            GUICtrlDelete($Base)
            GUICtrlDelete($B_Incognita)
            GUICtrlDelete($On_off_A)
            GUICtrlDelete($Misura_A)
            GUICtrlDelete($Misura_B)
            GUICtrlDelete($On_off_B)
            GUICtrlDelete($Misura_h)
            GUICtrlDelete($On_off_h)
            GUICtrlDelete($Misura_2P)
            GUICtrlDelete($On_off_2P)
            Global $Group2 = GUICtrlCreateGroup("Dati", 10, 42, 345, 173)
            Global $Area = GUICtrlCreateInput("", 54, 61, 106, 27)
            Global $Label2 = GUICtrlCreateLabel("Area:", 12, 63, 40, 23)
            Global $A_Incognita = GUICtrlCreateButton("Incognita", 257, 56, 94, 32, 0)
            Global $Label3 = GUICtrlCreateLabel("Perimetro:", 13, 174, 70, 23)
            Global $Perimetro = GUICtrlCreateInput("", 86, 168, 79, 27)
            Global $DUEP_Incognita = GUICtrlCreateButton("Incognita", 262, 164, 90, 32, 0)
            Global $Label5 = GUICtrlCreateLabel("Altezza:", 16, 137, 58, 23)
            Global $Altezza = GUICtrlCreateInput("", 78, 133, 85, 27)
            Global $h_Incognita = GUICtrlCreateButton("Incognita", 258, 130, 94, 32, 0)
            Global $LabelBase = GUICtrlCreateLabel("Base:", 13, 101, 38, 23)
            Global $Base = GUICtrlCreateInput("", 55, 97, 106, 27)
            Global $B_Incognita = GUICtrlCreateButton("Incognita", 256, 95, 94, 32, 0)
            Global $On_off_A = GUICtrlCreateButton("-", 214, 58, 42, 29, 0)
            Global $Misura_A = GUICtrlCreateCombo("mm²", 164, 61, 49, 25)
            GUICtrlSetData(-1, "cm²|dm²|m²|dam²|hm²|km²")
            Global $Misura_B = GUICtrlCreateCombo("mm", 165, 95, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            Global $On_off_B = GUICtrlCreateButton("-", 215, 95, 42, 29, 0)
            Global $Misura_h = GUICtrlCreateCombo("mm", 166, 132, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            Global $On_off_h = GUICtrlCreateButton("-", 216, 131, 42, 29, 0)
            Global $Misura_2P = GUICtrlCreateCombo("mm", 168, 168, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            Global $On_off_2P = GUICtrlCreateButton("-", 218, 167, 42, 29, 0)
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            GUICtrlDelete($Calcola)
            $Calcola = GUICtrlCreateButton("Calcola", 18, 233, 325, 50, 0)
            GUICtrlDelete($Figura)
            $Figura = GUICtrlCreatePic("Images\Triangolo Scaleno.jpg", 371, 75, 235, 217)
            $Flag1 = 0
            $Flag2 = 0
            $Flag3 = 0
            $Flag4 = 1
            $Flag5 = 0
        EndIf
        If $Flag1 = 1 Then
            $nMsg = GUIGetMsg()
            Switch $nMsg
                Case $GUI_EVENT_CLOSE
                    Exit
                    ;Incognite
                Case $A_Incognita
                    GUICtrlSetData($Area, "?")
                Case $DUEP_Incognita
                    GUICtrlSetData($Perimetro, "?")
                Case $C1_Incognita
                    GUICtrlSetData($C1, "?")
                Case $C2_Incognita
                    GUICtrlSetData($C2, "?")
                Case $I_Incognita
                    GUICtrlSetData($Ipotenusa, "?")
                Case $HP_Incognita
                    GUICtrlSetData($HP, "?")
                    ;Disabilita
                Case $On_off_A
                    If $FlagArea <> 3 Then
                        GUICtrlSetData($Area, "-")
                        GUICtrlSetData($On_off_A, "+")
                        GUICtrlSetState($Area, $GUI_Disable)
                        $FlagArea = 3
                    Else
                        GUICtrlSetData($Area, "")
                        GUICtrlSetState($Area, $GUI_Enable)
                        GUICtrlSetData($On_off_A, "-")
                        $FlagArea = 0
                    EndIf
                Case $On_off_2P
                    If $FlagPerimetro <> 3 Then
                        GUICtrlSetData($Perimetro, "-")
                        GUICtrlSetData($On_off_2P, "+")
                        GUICtrlSetState($Perimetro, $GUI_Disable)
                        $FlagPerimetro = 3
                    Else
                        GUICtrlSetData($Perimetro, "")
                        GUICtrlSetState($Perimetro, $GUI_Enable)
                        GUICtrlSetData($On_off_2P, "-")
                        $FlagPerimetro = 0
                    EndIf
                Case $On_off_C1
                    If $FlagC1 <> 3 Then
                        GUICtrlSetData($C1, "-")
                        GUICtrlSetData($On_off_C1, "+")
                        GUICtrlSetState($C1, $GUI_Disable)
                        $FlagC1 = 3
                    Else
                        GUICtrlSetData($C1, "")
                        GUICtrlSetState($C1, $GUI_Enable)
                        GUICtrlSetData($On_off_C1, "-")
                        $FlagC1 = 0
                    EndIf
                Case $On_off_C2
                    If $FlagC2 <> 3 Then
                        GUICtrlSetData($C2, "-")
                        GUICtrlSetData($On_off_C2, "+")
                        GUICtrlSetState($C2, $GUI_Disable)
                        $FlagC2 = 3
                    Else
                        GUICtrlSetData($C2, "")
                        GUICtrlSetState($C2, $GUI_Enable)
                        GUICtrlSetData($On_off_C2, "-")
                        $FlagC2 = 0
                    EndIf
                Case $On_off_Ipotenusa
                    If $FlagIpotenusa <> 3 Then
                        GUICtrlSetData($Ipotenusa, "-")
                        GUICtrlSetData($On_off_Ipotenusa, "+")
                        GUICtrlSetState($Ipotenusa, $GUI_Disable)
                        $FlagIpotenusa = 3
                    Else
                        GUICtrlSetData($Ipotenusa, "")
                        GUICtrlSetState($Ipotenusa, $GUI_Enable)
                        GUICtrlSetData($On_off_Ipotenusa, "-")
                        $FlagIpotenusa = 0
                    EndIf
                Case $On_off_HP
                    If $FlagHP <> 3 Then
                        GUICtrlSetData($HP, "-")
                        GUICtrlSetData($On_off_HP, "+")
                        GUICtrlSetState($HP, $GUI_Disable)
                        $FlagHP = 3
                    Else
                        GUICtrlSetData($HP, "")
                        GUICtrlSetState($HP, $GUI_Enable)
                        GUICtrlSetData($On_off_HP, "-")
                        $FlagHP = 0
                    EndIf
                    ;Azzera
                Case $Azzera
                    GUICtrlSetData($Area, "")
                    GUICtrlSetData($Perimetro, "")
                    GUICtrlSetData($C1, "")
                    GUICtrlSetData($C2, "")
                    GUICtrlSetData($Ipotenusa, "")
                    GUICtrlSetData($HP, "")
                    GUICtrlSetData($Edit_Incognite, "")
                    GUICtrlSetData($Edit_Procedimento, "")
                    GUICtrlSetState($Area, $GUI_Enable)
                    GUICtrlSetState($Perimetro, $GUI_Enable)
                    GUICtrlSetState($C1, $GUI_Enable)
                    GUICtrlSetState($C2, $GUI_Enable)
                    GUICtrlSetState($Ipotenusa, $GUI_Enable)
                    GUICtrlSetState($HP, $GUI_Enable)
                    GUICtrlSetData($Edit_Incognite, "")
                    GUICtrlSetData($Edit_Procedimento, "")
                    Global $FlagArea = 0
                    Global $FlagPerimetro = 0
                    Global $FlagC1 = 0
                    Global $FlagC2 = 0
                    Global $FlagIpotenusa = 0
                    Global $FlagHP = 0
                    Global $Flag2Area = 0
                    Global $Flag2Perimetro = 0
                    Global $Flag2C1 = 0
                    Global $Flag2C2 = 0
                    Global $Flag2Ipotenusa = 0
                    Global $Flag2HP = 0
                    GUICtrlSetData($On_off_A, "-")
                    GUICtrlSetData($On_off_2P, "-")
                    GUICtrlSetData($On_off_C1, "-")
                    GUICtrlSetData($On_off_C2, "-")
                    GUICtrlSetData($On_off_Ipotenusa, "-")
                    GUICtrlSetData($On_off_HP, "-")
                    ;Calcola
                Case $Calcola
                    Global $s_Misura_Comune = "dm"
                    Global $s_Misura_Ipotenusa = "cm"
                    Global $s_Ipotenusa = "136"
                    Global $s_C1 = 12
                    Global $s_Area = "?"
                    Global $s_C2 = "-"
                    Global $s_2P = "-"
                    Global $s_HP = "-"
                    _Equivalenza($s_Misura_Ipotenusa, "I", 0)
            EndSwitch
        EndIf
        If $Flag2 = 1 Then
            $nMsg = GUIGetMsg()
            Switch $nMsg
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $A_Incognita
                    GUICtrlSetData($Area, "?")
                Case $DUEP_Incognita
                    GUICtrlSetData($Perimetro, "?")
                Case $B_Incognita
                    GUICtrlSetData($Base, "?")
                Case $h_Incognita
                    GUICtrlSetData($Altezza, "?")
            EndSwitch
        EndIf
        If $Flag3 = 1 Then
            $nMsg = GUIGetMsg()
            Switch $nMsg
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $A_Incognita
                    GUICtrlSetData($Area, "?")
                Case $DUEP_Incognita
                    GUICtrlSetData($Perimetro, "?")
                Case $B_Incognita
                    GUICtrlSetData($Base, "?")
                Case $h_Incognita
                    GUICtrlSetData($Altezza, "?")
            EndSwitch
        EndIf
        If $Flag4 = 1 Then
            $nMsg = GUIGetMsg()
            Switch $nMsg
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $A_Incognita
                    GUICtrlSetData($Area, "?")
                Case $DUEP_Incognita
                    GUICtrlSetData($Perimetro, "?")
                Case $B_Incognita
                    GUICtrlSetData($Base, "?")
                Case $h_Incognita
                    GUICtrlSetData($Altezza, "?")
            EndSwitch
        EndIf
    WEnd
EndFunc   ;==>_Main

Func _Equivalenza($s_Misura, $Simbolo, $Quadrato)
    If $s_Misura <> $s_Misura_Comune Then
        $r_E = $s_E * (10 ^ (_ArraySearch($asUnits, $s_Misura, 1) - _ArraySearch($asUnits, $s_Misura_Comune, 1)))
        If $Quadrato = 1 Then
            $s_Misura &= "²"
            $s_Misura_Comune &= "²"
        EndIf
    EndIf
    _GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
    $s_E = $r_E
EndFunc   ;==>_Equivalenza
Edited by Tvern

Share this post


Link to post
Share on other sites

No, now is not working :unsure:

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Yeah I wasn't setting $s_E

;Script Created By Sym98
#include <GUIConstants.au3>
#include <GUIEdit.au3>
#include<array.au3>

Global $asUnits = StringSplit("mm,cm,dm,m,dam,hm,km", ",")
Global $s_E, $s_Misura_Comune, $s_Ipotenusa
;Variabili
Global $FlagArea = 0
Global $FlagPerimetro = 0
Global $FlagC1 = 0
Global $FlagC2 = 0
Global $FlagIpotenusa = 0
Global $FlagHP = 0
Global $Flag2Area = 0
Global $Flag2Perimetro = 0
Global $Flag2C1 = 0
Global $Flag2C2 = 0
Global $Flag2Ipotenusa = 0
Global $Flag2HP = 0
Global $FlagDisableArea = 1
Global $FlagDisablePerimetro = 1
Global $FlagDisableC1T = 1
Global $FlagDisableC2T = 1
Global $FlagDisableC1 = 1
Global $FlagDisableC2 = 1
Global $FlagDisableIpotenusa = 1
Global $FlagDisableHP = 1
Global $FlagEquivalenzaArea = 0
Global $FlagEquivalenzaPerimetro = 0
Global $FlagEquivalenzaC1 = 0
Global $FlagEquivalenzaC2 = 0
Global $FlagEquivalenzaIpotenusa = 0
Global $FlagEquivalenzaHP = 0
Global $Area, $Label2, $A_Incognita, $Label3, $Perimetro, $DUEP_Incognita, _
        $Label5, $C2, $C2_Incognita, $Altezza, $h_Incognita, $Label5, $LabelBase, _
        $Base, $B_Incognita, $On_off_A, $Misura_A, $Misura_B, $On_off_B, $Misura_h, $On_off_h, $Misura_2P, $On_off_2P, $Label, $Label6, $Misura_Comune
Global $Flag1 = 1
Global $Flag2 = 0
Global $Flag3 = 0
Global $Flag4 = 0
Global $Flag5 = 0
Global $FlagMisura = "mm"



;GUI
Global $GUI = GUICreate("SGP - Solve Geometric Problems By Sym98", 625, 522)
GUISetFont(10, 800, 0, "Comic Sans MS")
Global $Group1 = GUICtrlCreateGroup("Figura", 366, 53, 244, 242)
Global $Figura = GUICtrlCreatePic("Images\Triangolo Rettangolo.jpg", 371, 73, 235, 217)
GUICtrlSetData(-1, "Figura")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Tipe = GUICtrlCreateCombo("Triangolo Rettangolo", 366, 28, 243, 25)
GUICtrlSetData(-1, "Triangolo Isoscele|Triangolo Equilatero|Triangolo Scaleno")
Global $Label1 = GUICtrlCreateLabel("Solve Geometric Problems", 9, 3, 305, 39)
GUICtrlSetFont(-1, 18, 800, 0, "Comic Sans MS")
$Calcola = GUICtrlCreateButton("Calcola", 17, 262, 325, 50, 0)
$Group2 = GUICtrlCreateGroup("Dati", 10, 42, 345, 219)
$Area = GUICtrlCreateInput("", 54, 61, 106, 27)
$Label2 = GUICtrlCreateLabel("Area:", 12, 63, 40, 23)
$A_Incognita = GUICtrlCreateButton("Incognita", 257, 56, 94, 32, 0)
$Label3 = GUICtrlCreateLabel("Perimetro:", 12, 202, 70, 23)
$Perimetro = GUICtrlCreateInput("", 81, 198, 79, 27)
$DUEP_Incognita = GUICtrlCreateButton("Incognita", 263, 196, 90, 32, 0)
$Label5 = GUICtrlCreateLabel("C2:", 16, 137, 26, 23)
$C2 = GUICtrlCreateInput("", 54, 133, 105, 27)
$C2_Incognita = GUICtrlCreateButton("Incognita", 258, 130, 94, 32, 0)
$Label = GUICtrlCreateLabel("C1:", 13, 101, 26, 23)
$C1 = GUICtrlCreateInput("", 55, 97, 106, 27)
$C1_Incognita = GUICtrlCreateButton("Incognita", 258, 94, 94, 32, 0)
$On_off_A = GUICtrlCreateButton("-", 214, 58, 42, 29, 0)
$Misura_A = GUICtrlCreateCombo("mm²", 164, 61, 49, 25)
GUICtrlSetData(-1, "cm²|dm²|m²|dam²|hm²|km²")
$Misura_C1 = GUICtrlCreateCombo("mm", 165, 95, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$On_off_C1 = GUICtrlCreateButton("-", 215, 95, 42, 29, 0)
$Misura_C2 = GUICtrlCreateCombo("mm", 166, 132, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$On_off_C2 = GUICtrlCreateButton("-", 216, 131, 42, 29, 0)
$Misura_2P = GUICtrlCreateCombo("mm", 167, 199, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$On_off_2P = GUICtrlCreateButton("-", 220, 198, 42, 29, 0)
$Label4 = GUICtrlCreateLabel("I:", 14, 166, 17, 23)
$Ipotenusa = GUICtrlCreateInput("", 53, 164, 105, 27)
$Misura_Ipotenusa = GUICtrlCreateCombo("mm", 166, 163, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$On_off_Ipotenusa = GUICtrlCreateButton("-", 218, 164, 42, 29, 0)
$I_Incognita = GUICtrlCreateButton("Incognita", 259, 162, 94, 32, 0)
$Labelx = GUICtrlCreateLabel("Altezza(I):", 13, 230, 68, 20)
GUICtrlSetFont(-1, 9, 800, 0, "Comic Sans MS")
$HP = GUICtrlCreateInput("", 85, 227, 75, 27)
$Misura_HP = GUICtrlCreateCombo("mm", 167, 229, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$On_off_HP = GUICtrlCreateButton("-", 221, 227, 42, 29, 0)
$HP_Incognita = GUICtrlCreateButton("Incognita", 262, 228, 90, 29, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group3 = GUICtrlCreateGroup("Procedimento", 291, 319, 322, 125)
Global $Edit_Procedimento = GUICtrlCreateEdit("", 291, 336, 321, 107)
GUICtrlSetData(-1, "")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("Incognite", 16, 311, 261, 132)
$Edit_Incognite = GUICtrlCreateEdit("", 19, 331, 255, 113)
GUICtrlSetData(-1, "")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Label7 = GUICtrlCreateLabel("Created By Sym98", 391, 457, 222, 39)
GUICtrlSetFont(-1, 18, 800, 0, "Comic Sans MS")
Global $Azzera = GUICtrlCreateButton("Azzera", 15, 452, 366, 45, 0)
$Misura_Comune = GUICtrlCreateCombo("mm", 539, 295, 49, 27)
GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
$Label6 = GUICtrlCreateLabel("Unità di misura comune:", 372, 297, 159, 23)
GUISetState(@SW_SHOW)

;While
_Main()
Func _Main()
    While 1
        Global $s_Area = GUICtrlRead($Area)
        Global $s_C1 = GUICtrlRead($C1)
        Global $s_C2 = GUICtrlRead($C2)
         $s_Ipotenusa = GUICtrlRead($Ipotenusa)
        Global $s_Perimetro = GUICtrlRead($Perimetro)
        Global $s_HP = GUICtrlRead($HP)
        Global $s_Tipe = GUICtrlRead($Tipe)
        Global $s_Misura_Comune = GUICtrlRead($Misura_Comune)
        If $s_Tipe = "Triangolo Rettangolo" And $Flag1 = 0 Then
            ;Rettangolo
            GUICtrlDelete($Group2)
            GUICtrlDelete($Area)
            GUICtrlDelete($Label2)
            GUICtrlDelete($A_Incognita)
            GUICtrlDelete($Label3)
            GUICtrlDelete($Perimetro)
            GUICtrlDelete($DUEP_Incognita)
            GUICtrlDelete($Label5)
            GUICtrlDelete($C2)
            GUICtrlDelete($C2_Incognita)
            GUICtrlDelete($Label)
            GUICtrlDelete($C1)
            GUICtrlDelete($C1_Incognita)
            GUICtrlDelete($On_off_A)
            GUICtrlDelete($Misura_A)
            GUICtrlDelete($Misura_C1)
            GUICtrlDelete($On_off_C1)
            GUICtrlDelete($Misura_C2)
            GUICtrlDelete($On_off_C2)
            GUICtrlDelete($Misura_2P)
            GUICtrlDelete($On_off_2P)
            GUICtrlDelete($Label4)
            GUICtrlDelete($Ipotenusa)
            GUICtrlDelete($Misura_Ipotenusa)
            GUICtrlDelete($On_off_Ipotenusa)
            GUICtrlDelete($I_Incognita)
            GUICtrlDelete($Labelx)
            GUICtrlDelete($HP)
            GUICtrlDelete($Misura_HP)
            GUICtrlDelete($On_off_HP)
            GUICtrlDelete($HP_Incognita)
            ;Isoscele ecc...
            GUICtrlDelete($Group2)
            GUICtrlDelete($Area)
            GUICtrlDelete($Label2)
            GUICtrlDelete($A_Incognita)
            GUICtrlDelete($Label3)
            GUICtrlDelete($Perimetro)
            GUICtrlDelete($DUEP_Incognita)
            GUICtrlDelete($Label5)
            GUICtrlDelete($Altezza)
            GUICtrlDelete($h_Incognita)
            GUICtrlDelete($LabelBase)
            GUICtrlDelete($Base)
            GUICtrlDelete($B_Incognita)
            GUICtrlDelete($On_off_A)
            GUICtrlDelete($Misura_A)
            GUICtrlDelete($Misura_B)
            GUICtrlDelete($On_off_B)
            GUICtrlDelete($Misura_h)
            GUICtrlDelete($On_off_h)
            GUICtrlDelete($Misura_2P)
            GUICtrlDelete($On_off_2P)
            $Group2 = GUICtrlCreateGroup("Dati", 10, 42, 345, 219)
            $Area = GUICtrlCreateInput("", 54, 61, 106, 27)
            $Label2 = GUICtrlCreateLabel("Area:", 12, 63, 40, 23)
            $A_Incognita = GUICtrlCreateButton("Incognita", 257, 56, 94, 32, 0)
            $Label3 = GUICtrlCreateLabel("Perimetro:", 12, 202, 70, 23)
            $Perimetro = GUICtrlCreateInput("", 81, 198, 79, 27)
            $DUEP_Incognita = GUICtrlCreateButton("Incognita", 263, 196, 90, 32, 0)
            $Label5 = GUICtrlCreateLabel("C2:", 16, 137, 26, 23)
            $C2 = GUICtrlCreateInput("", 54, 133, 105, 27)
            $C2_Incognita = GUICtrlCreateButton("Incognita", 258, 130, 94, 32, 0)
            $Label = GUICtrlCreateLabel("C1:", 13, 101, 26, 23)
            $C1 = GUICtrlCreateInput("", 55, 97, 106, 27)
            $C1_Incognita = GUICtrlCreateButton("Incognita", 258, 94, 94, 32, 0)
            $On_off_A = GUICtrlCreateButton("-", 214, 58, 42, 29, 0)
            $Misura_A = GUICtrlCreateCombo("mm²", 164, 61, 49, 25)
            GUICtrlSetData(-1, "cm²|dm²|m²|dam²|hm²|km²")
            $Misura_C1 = GUICtrlCreateCombo("mm", 165, 95, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            $On_off_C1 = GUICtrlCreateButton("-", 215, 95, 42, 29, 0)
            $Misura_C2 = GUICtrlCreateCombo("mm", 166, 132, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            $On_off_C2 = GUICtrlCreateButton("-", 216, 131, 42, 29, 0)
            $Misura_2P = GUICtrlCreateCombo("mm", 167, 199, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            $On_off_2P = GUICtrlCreateButton("-", 220, 198, 42, 29, 0)
            $Label4 = GUICtrlCreateLabel("I:", 14, 166, 17, 23)
            $Ipotenusa = GUICtrlCreateInput("", 53, 164, 105, 27)
            $Misura_Ipotenusa = GUICtrlCreateCombo("mm", 166, 163, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            $On_off_Ipotenusa = GUICtrlCreateButton("-", 218, 164, 42, 29, 0)
            $I_Incognita = GUICtrlCreateButton("Incognita", 259, 162, 94, 32, 0)
            $Labelx = GUICtrlCreateLabel("Altezza(I):", 13, 230, 68, 20)
            GUICtrlSetFont(-1, 9, 800, 0, "Comic Sans MS")
            $HP = GUICtrlCreateInput("", 85, 227, 75, 27)
            $Misura_HP = GUICtrlCreateCombo("mm", 167, 229, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            $On_off_HP = GUICtrlCreateButton("-", 221, 227, 42, 29, 0)
            $HP_Incognita = GUICtrlCreateButton("Incognita", 262, 228, 90, 29, 0)
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            GUICtrlDelete($Calcola)
            Global $Calcola = GUICtrlCreateButton("Calcola", 17, 262, 325, 50, 0)
            GUICtrlDelete($Figura)
            $Figura = GUICtrlCreatePic("Images\Triangolo Rettangolo.jpg", 371, 75, 235, 217)
            ;GUICtrlSetData(-1, "Figura")
            $Flag1 = 1
            $Flag2 = 0
            $Flag3 = 0
            $Flag4 = 0
            $Flag5 = 0
        EndIf
        If $s_Tipe = "Triangolo Isoscele" And $Flag2 = 0 Then
            ;Rettangolo
            GUICtrlDelete($Group2)
            GUICtrlDelete($Area)
            GUICtrlDelete($Label2)
            GUICtrlDelete($A_Incognita)
            GUICtrlDelete($Label3)
            GUICtrlDelete($Perimetro)
            GUICtrlDelete($DUEP_Incognita)
            GUICtrlDelete($Label5)
            GUICtrlDelete($C2)
            GUICtrlDelete($C2_Incognita)
            GUICtrlDelete($Label)
            GUICtrlDelete($C1)
            GUICtrlDelete($C1_Incognita)
            GUICtrlDelete($On_off_A)
            GUICtrlDelete($Misura_A)
            GUICtrlDelete($Misura_C1)
            GUICtrlDelete($On_off_C1)
            GUICtrlDelete($Misura_C2)
            GUICtrlDelete($On_off_C2)
            GUICtrlDelete($Misura_2P)
            GUICtrlDelete($On_off_2P)
            GUICtrlDelete($Label4)
            GUICtrlDelete($Ipotenusa)
            GUICtrlDelete($Misura_Ipotenusa)
            GUICtrlDelete($On_off_Ipotenusa)
            GUICtrlDelete($I_Incognita)
            GUICtrlDelete($Labelx)
            GUICtrlDelete($HP)
            GUICtrlDelete($Misura_HP)
            GUICtrlDelete($On_off_HP)
            GUICtrlDelete($HP_Incognita)
            ;Isoscele ecc...
            GUICtrlDelete($Group2)
            GUICtrlDelete($Area)
            GUICtrlDelete($Label2)
            GUICtrlDelete($A_Incognita)
            GUICtrlDelete($Label3)
            GUICtrlDelete($Perimetro)
            GUICtrlDelete($DUEP_Incognita)
            GUICtrlDelete($Label5)
            GUICtrlDelete($Altezza)
            GUICtrlDelete($h_Incognita)
            GUICtrlDelete($LabelBase)
            GUICtrlDelete($Base)
            GUICtrlDelete($B_Incognita)
            GUICtrlDelete($On_off_A)
            GUICtrlDelete($Misura_A)
            GUICtrlDelete($Misura_B)
            GUICtrlDelete($On_off_B)
            GUICtrlDelete($Misura_h)
            GUICtrlDelete($On_off_h)
            GUICtrlDelete($Misura_2P)
            GUICtrlDelete($On_off_2P)
            Global $Group2 = GUICtrlCreateGroup("Dati", 10, 42, 345, 173)
            Global $Area = GUICtrlCreateInput("", 54, 61, 106, 27)
            Global $Label2 = GUICtrlCreateLabel("Area:", 12, 63, 40, 23)
            Global $A_Incognita = GUICtrlCreateButton("Incognita", 257, 56, 94, 32, 0)
            Global $Label3 = GUICtrlCreateLabel("Perimetro:", 13, 174, 70, 23)
            Global $Perimetro = GUICtrlCreateInput("", 86, 168, 79, 27)
            Global $DUEP_Incognita = GUICtrlCreateButton("Incognita", 262, 164, 90, 32, 0)
            Global $Label5 = GUICtrlCreateLabel("Altezza:", 16, 137, 58, 23)
            Global $Altezza = GUICtrlCreateInput("", 78, 133, 85, 27)
            Global $h_Incognita = GUICtrlCreateButton("Incognita", 258, 130, 94, 32, 0)
            Global $LabelBase = GUICtrlCreateLabel("Base:", 13, 101, 38, 23)
            Global $Base = GUICtrlCreateInput("", 55, 97, 106, 27)
            Global $B_Incognita = GUICtrlCreateButton("Incognita", 256, 95, 94, 32, 0)
            Global $On_off_A = GUICtrlCreateButton("-", 214, 58, 42, 29, 0)
            Global $Misura_A = GUICtrlCreateCombo("mm²", 164, 61, 49, 25)
            GUICtrlSetData(-1, "cm²|dm²|m²|dam²|hm²|km²")
            Global $Misura_B = GUICtrlCreateCombo("mm", 165, 95, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            Global $On_off_B = GUICtrlCreateButton("-", 215, 95, 42, 29, 0)
            Global $Misura_h = GUICtrlCreateCombo("mm", 166, 132, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            Global $On_off_h = GUICtrlCreateButton("-", 216, 131, 42, 29, 0)
            Global $Misura_2P = GUICtrlCreateCombo("mm", 168, 168, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            Global $On_off_2P = GUICtrlCreateButton("-", 218, 167, 42, 29, 0)
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            GUICtrlDelete($Calcola)
            $Calcola = GUICtrlCreateButton("Calcola", 18, 233, 325, 50, 0)
            GUICtrlDelete($Figura)
            $Figura = GUICtrlCreatePic("Images\Triangolo Isoscele.jpg", 371, 75, 235, 217)
            $Flag1 = 0
            $Flag2 = 1
            $Flag3 = 0
            $Flag4 = 0
            $Flag5 = 0
        EndIf
        If $s_Tipe = "Triangolo Equilatero" And $Flag3 = 0 Then
            ;Rettangolo
            GUICtrlDelete($Group2)
            GUICtrlDelete($Area)
            GUICtrlDelete($Label2)
            GUICtrlDelete($A_Incognita)
            GUICtrlDelete($Label3)
            GUICtrlDelete($Perimetro)
            GUICtrlDelete($DUEP_Incognita)
            GUICtrlDelete($Label5)
            GUICtrlDelete($C2)
            GUICtrlDelete($C2_Incognita)
            GUICtrlDelete($Label)
            GUICtrlDelete($C1)
            GUICtrlDelete($C1_Incognita)
            GUICtrlDelete($On_off_A)
            GUICtrlDelete($Misura_A)
            GUICtrlDelete($Misura_C1)
            GUICtrlDelete($On_off_C1)
            GUICtrlDelete($Misura_C2)
            GUICtrlDelete($On_off_C2)
            GUICtrlDelete($Misura_2P)
            GUICtrlDelete($On_off_2P)
            GUICtrlDelete($Label4)
            GUICtrlDelete($Ipotenusa)
            GUICtrlDelete($Misura_Ipotenusa)
            GUICtrlDelete($On_off_Ipotenusa)
            GUICtrlDelete($I_Incognita)
            GUICtrlDelete($Labelx)
            GUICtrlDelete($HP)
            GUICtrlDelete($Misura_HP)
            GUICtrlDelete($On_off_HP)
            GUICtrlDelete($HP_Incognita)
            ;Isoscele ecc...
            GUICtrlDelete($Group2)
            GUICtrlDelete($Area)
            GUICtrlDelete($Label2)
            GUICtrlDelete($A_Incognita)
            GUICtrlDelete($Label3)
            GUICtrlDelete($Perimetro)
            GUICtrlDelete($DUEP_Incognita)
            GUICtrlDelete($Label5)
            GUICtrlDelete($Altezza)
            GUICtrlDelete($h_Incognita)
            GUICtrlDelete($LabelBase)
            GUICtrlDelete($Base)
            GUICtrlDelete($B_Incognita)
            GUICtrlDelete($On_off_A)
            GUICtrlDelete($Misura_A)
            GUICtrlDelete($Misura_B)
            GUICtrlDelete($On_off_B)
            GUICtrlDelete($Misura_h)
            GUICtrlDelete($On_off_h)
            GUICtrlDelete($Misura_2P)
            GUICtrlDelete($On_off_2P)
            Global $Group2 = GUICtrlCreateGroup("Dati", 10, 42, 345, 173)
            Global $Area = GUICtrlCreateInput("", 54, 61, 106, 27)
            Global $Label2 = GUICtrlCreateLabel("Area:", 12, 63, 40, 23)
            Global $A_Incognita = GUICtrlCreateButton("Incognita", 257, 56, 94, 32, 0)
            Global $Label3 = GUICtrlCreateLabel("Perimetro:", 13, 174, 70, 23)
            Global $Perimetro = GUICtrlCreateInput("", 86, 168, 79, 27)
            Global $DUEP_Incognita = GUICtrlCreateButton("Incognita", 262, 164, 90, 32, 0)
            Global $Label5 = GUICtrlCreateLabel("Altezza:", 16, 137, 58, 23)
            Global $Altezza = GUICtrlCreateInput("", 78, 133, 85, 27)
            Global $h_Incognita = GUICtrlCreateButton("Incognita", 258, 130, 94, 32, 0)
            Global $LabelBase = GUICtrlCreateLabel("Base:", 13, 101, 38, 23)
            Global $Base = GUICtrlCreateInput("", 55, 97, 106, 27)
            Global $B_Incognita = GUICtrlCreateButton("Incognita", 256, 95, 94, 32, 0)
            Global $On_off_A = GUICtrlCreateButton("-", 214, 58, 42, 29, 0)
            Global $Misura_A = GUICtrlCreateCombo("mm²", 164, 61, 49, 25)
            GUICtrlSetData(-1, "cm²|dm²|m²|dam²|hm²|km²")
            Global $Misura_B = GUICtrlCreateCombo("mm", 165, 95, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            Global $On_off_B = GUICtrlCreateButton("-", 215, 95, 42, 29, 0)
            Global $Misura_h = GUICtrlCreateCombo("mm", 166, 132, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            Global $On_off_h = GUICtrlCreateButton("-", 216, 131, 42, 29, 0)
            Global $Misura_2P = GUICtrlCreateCombo("mm", 168, 168, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            Global $On_off_2P = GUICtrlCreateButton("-", 218, 167, 42, 29, 0)
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            GUICtrlDelete($Calcola)
            $Calcola = GUICtrlCreateButton("Calcola", 18, 233, 325, 50, 0)
            GUICtrlDelete($Figura)
            $Figura = GUICtrlCreatePic("Images\Triangolo Equilatero.jpg", 371, 75, 235, 217)
            $Flag1 = 0
            $Flag2 = 0
            $Flag3 = 1
            $Flag4 = 0
            $Flag5 = 0
        EndIf
        If $s_Tipe = "Triangolo Scaleno" And $Flag4 = 0 Then
            ;Rettangolo
            GUICtrlDelete($Group2)
            GUICtrlDelete($Area)
            GUICtrlDelete($Label2)
            GUICtrlDelete($A_Incognita)
            GUICtrlDelete($Label3)
            GUICtrlDelete($Perimetro)
            GUICtrlDelete($DUEP_Incognita)
            GUICtrlDelete($Label5)
            GUICtrlDelete($C2)
            GUICtrlDelete($C2_Incognita)
            GUICtrlDelete($Label)
            GUICtrlDelete($C1)
            GUICtrlDelete($C1_Incognita)
            GUICtrlDelete($On_off_A)
            GUICtrlDelete($Misura_A)
            GUICtrlDelete($Misura_C1)
            GUICtrlDelete($On_off_C1)
            GUICtrlDelete($Misura_C2)
            GUICtrlDelete($On_off_C2)
            GUICtrlDelete($Misura_2P)
            GUICtrlDelete($On_off_2P)
            GUICtrlDelete($Label4)
            GUICtrlDelete($Ipotenusa)
            GUICtrlDelete($Misura_Ipotenusa)
            GUICtrlDelete($On_off_Ipotenusa)
            GUICtrlDelete($I_Incognita)
            GUICtrlDelete($Labelx)
            GUICtrlDelete($HP)
            GUICtrlDelete($Misura_HP)
            GUICtrlDelete($On_off_HP)
            GUICtrlDelete($HP_Incognita)
            ;Isoscele ecc...
            GUICtrlDelete($Group2)
            GUICtrlDelete($Area)
            GUICtrlDelete($Label2)
            GUICtrlDelete($A_Incognita)
            GUICtrlDelete($Label3)
            GUICtrlDelete($Perimetro)
            GUICtrlDelete($DUEP_Incognita)
            GUICtrlDelete($Label5)
            GUICtrlDelete($Altezza)
            GUICtrlDelete($h_Incognita)
            GUICtrlDelete($LabelBase)
            GUICtrlDelete($Base)
            GUICtrlDelete($B_Incognita)
            GUICtrlDelete($On_off_A)
            GUICtrlDelete($Misura_A)
            GUICtrlDelete($Misura_B)
            GUICtrlDelete($On_off_B)
            GUICtrlDelete($Misura_h)
            GUICtrlDelete($On_off_h)
            GUICtrlDelete($Misura_2P)
            GUICtrlDelete($On_off_2P)
            Global $Group2 = GUICtrlCreateGroup("Dati", 10, 42, 345, 173)
            Global $Area = GUICtrlCreateInput("", 54, 61, 106, 27)
            Global $Label2 = GUICtrlCreateLabel("Area:", 12, 63, 40, 23)
            Global $A_Incognita = GUICtrlCreateButton("Incognita", 257, 56, 94, 32, 0)
            Global $Label3 = GUICtrlCreateLabel("Perimetro:", 13, 174, 70, 23)
            Global $Perimetro = GUICtrlCreateInput("", 86, 168, 79, 27)
            Global $DUEP_Incognita = GUICtrlCreateButton("Incognita", 262, 164, 90, 32, 0)
            Global $Label5 = GUICtrlCreateLabel("Altezza:", 16, 137, 58, 23)
            Global $Altezza = GUICtrlCreateInput("", 78, 133, 85, 27)
            Global $h_Incognita = GUICtrlCreateButton("Incognita", 258, 130, 94, 32, 0)
            Global $LabelBase = GUICtrlCreateLabel("Base:", 13, 101, 38, 23)
            Global $Base = GUICtrlCreateInput("", 55, 97, 106, 27)
            Global $B_Incognita = GUICtrlCreateButton("Incognita", 256, 95, 94, 32, 0)
            Global $On_off_A = GUICtrlCreateButton("-", 214, 58, 42, 29, 0)
            Global $Misura_A = GUICtrlCreateCombo("mm²", 164, 61, 49, 25)
            GUICtrlSetData(-1, "cm²|dm²|m²|dam²|hm²|km²")
            Global $Misura_B = GUICtrlCreateCombo("mm", 165, 95, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            Global $On_off_B = GUICtrlCreateButton("-", 215, 95, 42, 29, 0)
            Global $Misura_h = GUICtrlCreateCombo("mm", 166, 132, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            Global $On_off_h = GUICtrlCreateButton("-", 216, 131, 42, 29, 0)
            Global $Misura_2P = GUICtrlCreateCombo("mm", 168, 168, 49, 27)
            GUICtrlSetData(-1, "cm|dm|m|dam|hm|km")
            Global $On_off_2P = GUICtrlCreateButton("-", 218, 167, 42, 29, 0)
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            GUICtrlDelete($Calcola)
            $Calcola = GUICtrlCreateButton("Calcola", 18, 233, 325, 50, 0)
            GUICtrlDelete($Figura)
            $Figura = GUICtrlCreatePic("Images\Triangolo Scaleno.jpg", 371, 75, 235, 217)
            $Flag1 = 0
            $Flag2 = 0
            $Flag3 = 0
            $Flag4 = 1
            $Flag5 = 0
        EndIf
        If $Flag1 = 1 Then
            $nMsg = GUIGetMsg()
            Switch $nMsg
                Case $GUI_EVENT_CLOSE
                    Exit
                    ;Incognite
                Case $A_Incognita
                    GUICtrlSetData($Area, "?")
                Case $DUEP_Incognita
                    GUICtrlSetData($Perimetro, "?")
                Case $C1_Incognita
                    GUICtrlSetData($C1, "?")
                Case $C2_Incognita
                    GUICtrlSetData($C2, "?")
                Case $I_Incognita
                    GUICtrlSetData($Ipotenusa, "?")
                Case $HP_Incognita
                    GUICtrlSetData($HP, "?")
                    ;Disabilita
                Case $On_off_A
                    If $FlagArea <> 3 Then
                        GUICtrlSetData($Area, "-")
                        GUICtrlSetData($On_off_A, "+")
                        GUICtrlSetState($Area, $GUI_Disable)
                        $FlagArea = 3
                    Else
                        GUICtrlSetData($Area, "")
                        GUICtrlSetState($Area, $GUI_Enable)
                        GUICtrlSetData($On_off_A, "-")
                        $FlagArea = 0
                    EndIf
                Case $On_off_2P
                    If $FlagPerimetro <> 3 Then
                        GUICtrlSetData($Perimetro, "-")
                        GUICtrlSetData($On_off_2P, "+")
                        GUICtrlSetState($Perimetro, $GUI_Disable)
                        $FlagPerimetro = 3
                    Else
                        GUICtrlSetData($Perimetro, "")
                        GUICtrlSetState($Perimetro, $GUI_Enable)
                        GUICtrlSetData($On_off_2P, "-")
                        $FlagPerimetro = 0
                    EndIf
                Case $On_off_C1
                    If $FlagC1 <> 3 Then
                        GUICtrlSetData($C1, "-")
                        GUICtrlSetData($On_off_C1, "+")
                        GUICtrlSetState($C1, $GUI_Disable)
                        $FlagC1 = 3
                    Else
                        GUICtrlSetData($C1, "")
                        GUICtrlSetState($C1, $GUI_Enable)
                        GUICtrlSetData($On_off_C1, "-")
                        $FlagC1 = 0
                    EndIf
                Case $On_off_C2
                    If $FlagC2 <> 3 Then
                        GUICtrlSetData($C2, "-")
                        GUICtrlSetData($On_off_C2, "+")
                        GUICtrlSetState($C2, $GUI_Disable)
                        $FlagC2 = 3
                    Else
                        GUICtrlSetData($C2, "")
                        GUICtrlSetState($C2, $GUI_Enable)
                        GUICtrlSetData($On_off_C2, "-")
                        $FlagC2 = 0
                    EndIf
                Case $On_off_Ipotenusa
                    If $FlagIpotenusa <> 3 Then
                        GUICtrlSetData($Ipotenusa, "-")
                        GUICtrlSetData($On_off_Ipotenusa, "+")
                        GUICtrlSetState($Ipotenusa, $GUI_Disable)
                        $FlagIpotenusa = 3
                    Else
                        GUICtrlSetData($Ipotenusa, "")
                        GUICtrlSetState($Ipotenusa, $GUI_Enable)
                        GUICtrlSetData($On_off_Ipotenusa, "-")
                        $FlagIpotenusa = 0
                    EndIf
                Case $On_off_HP
                    If $FlagHP <> 3 Then
                        GUICtrlSetData($HP, "-")
                        GUICtrlSetData($On_off_HP, "+")
                        GUICtrlSetState($HP, $GUI_Disable)
                        $FlagHP = 3
                    Else
                        GUICtrlSetData($HP, "")
                        GUICtrlSetState($HP, $GUI_Enable)
                        GUICtrlSetData($On_off_HP, "-")
                        $FlagHP = 0
                    EndIf
                    ;Azzera
                Case $Azzera
                    GUICtrlSetData($Area, "")
                    GUICtrlSetData($Perimetro, "")
                    GUICtrlSetData($C1, "")
                    GUICtrlSetData($C2, "")
                    GUICtrlSetData($Ipotenusa, "")
                    GUICtrlSetData($HP, "")
                    GUICtrlSetData($Edit_Incognite, "")
                    GUICtrlSetData($Edit_Procedimento, "")
                    GUICtrlSetState($Area, $GUI_Enable)
                    GUICtrlSetState($Perimetro, $GUI_Enable)
                    GUICtrlSetState($C1, $GUI_Enable)
                    GUICtrlSetState($C2, $GUI_Enable)
                    GUICtrlSetState($Ipotenusa, $GUI_Enable)
                    GUICtrlSetState($HP, $GUI_Enable)
                    GUICtrlSetData($Edit_Incognite, "")
                    GUICtrlSetData($Edit_Procedimento, "")
                    Global $FlagArea = 0
                    Global $FlagPerimetro = 0
                    Global $FlagC1 = 0
                    Global $FlagC2 = 0
                    Global $FlagIpotenusa = 0
                    Global $FlagHP = 0
                    Global $Flag2Area = 0
                    Global $Flag2Perimetro = 0
                    Global $Flag2C1 = 0
                    Global $Flag2C2 = 0
                    Global $Flag2Ipotenusa = 0
                    Global $Flag2HP = 0
                    GUICtrlSetData($On_off_A, "-")
                    GUICtrlSetData($On_off_2P, "-")
                    GUICtrlSetData($On_off_C1, "-")
                    GUICtrlSetData($On_off_C2, "-")
                    GUICtrlSetData($On_off_Ipotenusa, "-")
                    GUICtrlSetData($On_off_HP, "-")
                    ;Calcola
                Case $Calcola
                    Global $s_Misura_Comune = "dm"
                    Global $s_Misura_Ipotenusa = "cm"
                     $s_Ipotenusa = "136"
                    Global $s_C1 = 12
                    Global $s_Area = "?"
                    Global $s_C2 = "-"
                    Global $s_2P = "-"
                    Global $s_HP = "-"
                    _Equivalenza($s_Misura_Ipotenusa, "I", 0)
            EndSwitch
        EndIf
        If $Flag2 = 1 Then
            $nMsg = GUIGetMsg()
            Switch $nMsg
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $A_Incognita
                    GUICtrlSetData($Area, "?")
                Case $DUEP_Incognita
                    GUICtrlSetData($Perimetro, "?")
                Case $B_Incognita
                    GUICtrlSetData($Base, "?")
                Case $h_Incognita
                    GUICtrlSetData($Altezza, "?")
            EndSwitch
        EndIf
        If $Flag3 = 1 Then
            $nMsg = GUIGetMsg()
            Switch $nMsg
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $A_Incognita
                    GUICtrlSetData($Area, "?")
                Case $DUEP_Incognita
                    GUICtrlSetData($Perimetro, "?")
                Case $B_Incognita
                    GUICtrlSetData($Base, "?")
                Case $h_Incognita
                    GUICtrlSetData($Altezza, "?")
            EndSwitch
        EndIf
        If $Flag4 = 1 Then
            $nMsg = GUIGetMsg()
            Switch $nMsg
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $A_Incognita
                    GUICtrlSetData($Area, "?")
                Case $DUEP_Incognita
                    GUICtrlSetData($Perimetro, "?")
                Case $B_Incognita
                    GUICtrlSetData($Base, "?")
                Case $h_Incognita
                    GUICtrlSetData($Altezza, "?")
            EndSwitch
        EndIf
    WEnd
EndFunc   ;==>_Main


Func _Equivalenza($s_Misura, $Simbolo, $Quadrato)
    $s_E = $s_Ipotenusa
    If $s_Misura <> $s_Misura_Comune Then
        $r_E = $s_E * (10 ^ (_ArraySearch($asUnits, $s_Misura, 1) - _ArraySearch($asUnits, $s_Misura_Comune, 1)))
        If $Quadrato = 1 Then
            $s_Misura = $s_Misura & "²"
            $s_Misura_Comune = $s_Misura_Comune & "²"
        EndIf
        _GUICtrlEdit_AppendText($Edit_Procedimento, $Simbolo & " = " & $s_E & " " & $s_Misura & " = " & $r_E & " " & $s_Misura_Comune & @CRLF)
        $s_E = $r_E
    EndIf
EndFunc   ;==>_Equivalenza
This does the same as your script I think, but the whole global variable situation is still a mess in _Main()

Try to declare all global variables at the top of the script. (you can leave them empty, just declare them outside a function though)

Variables that are only used inside a function are best declared at the top of that function. (again, you can leave them empty at first)

Lastly avoid declaring any variable twice. (this includes using a function parameter with the same name as a global variable)

Edited by Tvern

Share this post


Link to post
Share on other sites

Ok, thank you very much :unsure:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0