#include #include #include #include #include #include #include #include #include #Region ### START Koda GUI section ### Form=D:\AutoIt\koda_1.7.3.0\Forms\E - Juice Calculator.kxf $Form1 = GUICreate("E-Juice Calculator", 329, 401, -1, -1) $Label1 = GUICtrlCreateLabel("Target Amount :", 8, 8, 80, 17) $Label2 = GUICtrlCreateLabel("Flavor Percentage :", 8, 32, 97, 17) $targetinput = GUICtrlCreateInput("", 163, 6, 121, 21) $Label3 = GUICtrlCreateLabel("ml", 289, 8, 14, 17) $Label4 = GUICtrlCreateLabel("%", 289, 32, 12, 17) $Label5 = GUICtrlCreateLabel("Nicotine Base Concentration :", 8, 56, 142, 17) $niccinput = GUICtrlCreateInput("", 163, 54, 121, 21) $Label6 = GUICtrlCreateLabel("mg/ml", 289, 56, 33, 17) $edit = GUICtrlCreateEdit("", 8, 136, 313, 233) GUICtrlSetData(-1, "") $Button1 = GUICtrlCreateButton("Calculate", 247, 372, 75, 25) $fpinput = GUICtrlCreateCombo("", 163, 30, 121, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE)) GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100", "15") $Label7 = GUICtrlCreateLabel("Nicotine Target Concentration :", 8, 80, 150, 17) $Label8 = GUICtrlCreateLabel("mg/ml", 289, 80, 33, 17) $Combo1 = GUICtrlCreateCombo("", 163, 78, 121, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE)) GUICtrlSetData(-1, "3|6|12|18|24", "3") $Label9 = GUICtrlCreateLabel("PG/VG Ratio :", 8, 104, 150, 17) $Label10 = GUICtrlCreateLabel("%", 289, 104, 33, 17) $Combo2 = GUICtrlCreateCombo("", 163, 102, 121, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE)) GUICtrlSetData(-1, "0/100|10/90|20/80|30/70|40/60|50/50|60/40|70/30|80/20|90/10|100/0", "20/80") $Button2 = GUICtrlCreateButton("Save", 7, 372, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Calculate() Case $Button2 Save() EndSwitch WEnd Func Calculate() $target = GUICtrlRead($targetinput) $nicc = GUICtrlRead($niccinput) if $target <> "" Then if $nicc <> "" Then $fpi = GUICtrlRead($fpinput) if $fpi < 10 Then $fp = ".0" & $fpi Else $fp = "." & $fpi EndIf $basesize = $target - $target * $fp $flavorsize = $target * $fp $flavorsize = Round($flavorsize, 3) $nicbc = GUICtrlRead($niccinput) $nictc = GUICtrlRead($combo1) $pgvg = GUICtrlRead($combo2) $pgvg = StringSplit($pgvg, "/") $pg = $pgvg[1] $vg = $pgvg[2] $nicamount = $target * $nictc / $nicbc $nicgram = 1.01 * $nicamount $nicgram = Round($nicgram, 3) $nicamount = Round($nicamount, 3) & " ml or " & $nicgram & " g" $basesize = $basesize - $nicamount if $pg <> 100 Then $pgdec = "." & $pg $pgamount = $basesize * $pgdec $pggram = 1.04 * $pgamount $pggram = Round($pggram, 3) $pgamount = Round($pgamount, 3) & " ml or " & $pggram & " g" Else $pgamount = $basesize $pggram = 1.04 * $pgamount $pggram = Round($pggram, 3) $pgamount = Round($pgamount, 3) & " ml or " & $pggram & " g" EndIf if $vg <> 100 Then $vgdec = "." & $vg $vgamount = $basesize * $vgdec $vggram = 1.26 * $vgamount $vggram = Round($vggram, 3) $vgamount = Round($vgamount, 3) & " ml or " & $vggram & " g" Else $vgamount = $basesize $vggram = 1.26 * $vgamount $vggram = Round($vggram, 3) $vgamount = Round($vgamount, 3) & " ml or " & $vggram & " g" EndIf GUICtrlSetData($edit, "Target Amount : " & $target & " ml" & @CRLF & "Flavor Percentage : " & $fpi & " %" & @CRLF & "Nicotine Base Concentration : " & $nicbc & " mg/ml" & @CRLF & "Nicotine Target Concentration : " & $nictc & " mg/ml" & @CRLF & "Propylene Glycol : " & $pg & " %" & @CRLF & "Vegetable Glycerin : " & $vg & " %" & @CRLF & @CRLF & "Juice Specifications : " & @CRLF & "Nicotine : " & $nicamount & @CRLF & "Propylene Glycol : " & $pgamount & @CRLF & "Vegetable Glycerin : " & $vgamount & @CRLF & "Flavor(s) Total : " & $flavorsize & " ml or " & $flavorsize & " g") GUICtrlSetData($targetinput, "") GUICtrlSetData($niccinput, "") GUICtrlSetData($fpinput, 15) GUICtrlSetData($combo1, 3) GUICtrlSetData($combo2, "20/80") EndIf EndIf EndFunc Func Save() $data = GUICtrlRead($edit) $file = FileSaveDialog("Save Dialog", @scriptdir, "Text File (*.txt)") _FileCreate($file) FileWrite($file, $data) EndFunc