AsLY Posted July 25, 2006 Share Posted July 25, 2006 func CalcProdM() don't return the correct value from the array. the value are 61235 for $lvlMmp[1] = 25 please help other question, i want to refresh the label after having had data in input box (with button $calc) expandcollapse popup$lvlMmp[$iCount] = GUICtrlCreateInput ($lvlMmp[$iCount], 180 + ($iCount * 80), 170, 25, 21, $SS_CENTER) $PourcMmp[$iCount] = GUICtrlCreateCombo ("", 205 + ($iCount * 80), 170, 55) GUICtrlSetData ($PourcMmp[$iCount], "100%|90%|80%|70%|60%|50%|40%|30%|20%|10%|0%", "100%") $a[6] =GuiCtrlCreateLabel (CalcProdM( 30, $lvlMmp[$iCount], GUICtrlRead ($PourcMmp[$iCount])), 180 + ($iCount * 80), 330, 80, 20, $SS_CENTER+ $SS_SUNKEN) $save = GuiCtrlCreateButton ("Sauver", 490, 720, 100, 30) $calc = GuiCtrlCreateButton ("calc", 590, 720, 100, 30) GuiSetState () While 1 $Msg = GuiGetMsg() ;------------------------------------------------------------- ; Sauvegarde des données ;------------------------------------------------------------- If $msg = $save Then For $iCount = 1 To 9 iniWrite ( "DB.ini", "planète" & $iCount, "namep", GUICtrlRead ($namep[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "nbcasep", GUICtrlRead ($nbcasep[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "Tmaxp", GUICtrlRead ($Tmaxp[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "lvlMmp", GUICtrlRead ($lvlMmp[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "lvlMcp", GUICtrlRead ($lvlMcp[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "lvlSdp", GUICtrlRead ($lvlSdp[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "lvlHmp", GUICtrlRead ($lvlHmp[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "lvlHcp", GUICtrlRead ($lvlHcp[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "lvlRdp", GUICtrlRead ($lvlRdp[$iCount])) Next endif If $msg = $calc Then For $iCount = 1 To 9 ;------------------------------------------------------------- ; calculs ;------------------------------------------------------------- ;{ #cs Local $coeff[$iCount] = GUICtrlRead ($PourcMmp[$iCount]) select case $coeff[$iCount] = "100%" $coeff[$iCount] = 1 case $coeff[$iCount] = "90%" $coeff[$iCount] = 0.9 case $coeff[$iCount] = "80%" $coeff[$iCount] = 0.8 case $coeff[$iCount] = "70%" $coeff[$iCount] = 0.7 case $coeff[$iCount] = "60%" $coeff[$iCount] = 0.6 case $coeff[$iCount] = "50%" $coeff[$iCount] = 0.5 case $coeff[$iCount] = "40%" $coeff[$iCount] = 0.4 case $coeff[$iCount] = "30%" $coeff[$iCount] = 0.3 case $coeff[$iCount] = "20%" $coeff[$iCount] = 0.2 case $coeff[$iCount] = "10%" $coeff[$iCount] = 0.1 case $coeff[$iCount] = "0%" $coeff[$iCount] = 0 EndSelect ;$ProdMmp[$iCount] = int( $lvlMmp[$iCount] * 1.1 ^ $lvlMmp[$iCount]) #ce ;} Next endif ;Until $msg = $GUI_EVENT_CLOSE; Continue loop untill window is closed select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd func CalcProdM( $v, $lvl, $coeff) ;Local $p = $coeff select case $coeff = "100%" $p = 1 case $coeff = "90%" $p = 0.9 case $coeff = "80%" $p = 0.8 case $coeff = "70%" $p = 0.7 case $coeff = "60%" $p = 0.6 case $coeff = "50%" $p = 0.5 case $coeff = "40%" $p = 0.4 case $coeff = "30%" $p = 0.3 case $coeff = "20%" $p = 0.2 case $coeff = "10%" $p = 0.1 case $coeff = "0%" $p = 0 EndSelect if $v * $lvl <> 0 Then return int( $v * $lvl * 1.1 ^ $lvl ) * $p ;return = $ProdM endif EndFunc Link to comment Share on other sites More sharing options...
rbhkamal Posted July 25, 2006 Share Posted July 25, 2006 If you posted the complete script it would've helped more. I modified your function, TEST IT: ConsoleWrite('-- Result = ' & CalcProdM( 2, 1, 55 ) & @lf) ;### Debug Console Func CalcProdM( $v, $lvl, $coeff) Local $L_Value = $coeff Local $L_v = Int($v) Local $L_lvl = Int($lvl) If IsString( $L_Value ) Then $L_Value = StringReplace( $L_Value , "%" , '' ) $L_Value = StringStripWS( $L_Value , 8 ) $L_Value = Int($L_Value) EndIf $L_p = $L_Value / 100 If $v * $lvl <> 0 Then return int( $v * $lvl * 1.1 ^ $lvl ) * $L_p ;return = $ProdM endif EndFunc "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
rbhkamal Posted July 25, 2006 Share Posted July 25, 2006 other question, i want to refresh the label after having had data in input box (with button $calc)Search the help file for AdlibEnable() and use it with this function: Func Refresh_lable() GUICtrlSetData( $a[6] , GUICtrlRead( "Fill this in" ) ) EndFunc "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
AsLY Posted July 26, 2006 Author Share Posted July 26, 2006 the complete script expandcollapse popup#Include <GuiConstants.au3> #Include <File.au3> #Include <date.au3> ;#NoTrayIcon ;$Window_Color = 0x00e0ff ;GUISetBkColor ($Window_Color) ;$bk = GuiCtrlSetBkColor (-1, 0x08345E) ;GUICtrlSetColor (-1, 0xffffff) ; ;GuiCtrlCreateTab (10, 0, 1000, 360) ;GuiCtrlCreateTabItem ("two") ;------------------------------------------------------------- ; variables ;------------------------------------------------------------- ;{ Global $namep[10], $nbcasep[10], $Tmaxp[10], $lvlMmp[10], $lvlMcp[10], $lvlSdp[10], $PourcMmp[10], $PourcMcp[10], $PourcSdp[10], $Econsop[10], $ProdMmp[10], $ProdMcp[10], $ProdSdp[10], $nbtransp[10], $lvlHmp[10], $lvlHcp[10], $lvlRdp[10], $CapaHmp[10], $CapaHcp[10], $CapaRdp[10], $TCapaHmp[10], $TCapaHcp[10], $TCapaRdp[10] Global $nplanete[10], $l[100], $a[100] $ProdMmG = 0 $ProdMcG = 0 $ProdSdG = 0 $nbtransT = 0 $CapaHmT = 0 $CapaHcT = 0 $CapaRdT = 0 ;} ;------------------------------------------------------------- ; Charge les données ;------------------------------------------------------------- ;{ For $iCount = 1 To 9 $namep[$iCount] = IniRead ( "DB.ini", "planète" & $iCount, "namep", "") $nbcasep[$iCount] = IniRead ( "DB.ini", "planète" & $iCount, "nbcasep", "") $Tmaxp[$iCount] = IniRead ( "DB.ini", "planète" & $iCount, "Tmaxp", "") $lvlMmp[$iCount] = IniRead ( "DB.ini", "planète" & $iCount, "lvlMmp", "") $lvlMcp[$iCount] = IniRead ( "DB.ini", "planète" & $iCount, "lvlMcp", "") $lvlSdp[$iCount] = IniRead ( "DB.ini", "planète" & $iCount, "lvlSdp", "") $lvlHmp[$iCount] = IniRead ( "DB.ini", "planète" & $iCount, "lvlHmp", "") $lvlHcp[$iCount] = IniRead ( "DB.ini", "planète" & $iCount, "lvlHcp", "") $lvlRdp[$iCount] = IniRead ( "DB.ini", "planète" & $iCount, "lvlRdp", "") Next ;} ;------------------------------------------------------------- ; fenetre principal et premier onglet ;------------------------------------------------------------- ;{ GuiCreate ("Autoit - O v beta 0.1", 1000, 800, (@DesktopWidth-1000)/2, (@DesktopHeight-800)/2 ,$WS_EX_WINDOWEDGE + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_SYSMENU + $WS_MINIMIZEBOX) GuiCtrlCreateTab (0, 0, 1000, 800,$WS_VISIBLE + $WS_CLIPSIBLINGS) GuiCtrlCreateTabItem ("Empire page 1") ;} ;------------------------------------------------------------- ; titre ligne ;------------------------------------------------------------- ;{ $l[1] = GuiCtrlCreateLabel ("Planètes", 260, 30, 720, 20, $SS_CENTER + $SS_SUNKEN) $l[2] = GuiCtrlCreateLabel ("Nom de la planète", 10, 50, 160, 20, $SS_CENTER + $SS_SUNKEN) $l[3] = GuiCtrlCreateLabel ("Nombre de Case", 10, 70, 160, 20, $SS_CENTER + $SS_SUNKEN) $l[4] = GuiCtrlCreateLabel ("Température Max", 10, 90, 160, 20, $SS_CENTER + $SS_SUNKEN) $l[5] = GuiCtrlCreateLabel ("Production Minière", 10, 130, 160, 20, $SS_CENTER + $SS_SUNKEN) $l[6] = GuiCtrlCreateLabel ("Niveau/Taux d'utilisation", 260, 150, 720, 20, $SS_CENTER + $SS_SUNKEN) $l[7] = GuiCtrlCreateLabel ("Mine de métal", 10, 170, 160, 21, $SS_CENTER + $SS_SUNKEN) $l[8] = GuiCtrlCreateLabel ("Mine de cristal", 10, 191, 160, 21, $SS_CENTER + $SS_SUNKEN) $l[9] = GuiCtrlCreateLabel ("Synthétiseur de deutérium", 10, 212, 160, 21, $SS_CENTER + $SS_SUNKEN) $l[10] = GuiCtrlCreateLabel ("Energie Consommée", 10, 233, 160, 20, $SS_CENTER + $SS_SUNKEN) $l[11] = GuiCtrlCreateLabel ("Bilan des extractions de ressources", 10, 270, 160, 40, $SS_CENTER + $SS_SUNKEN) $l[12] = GuiCtrlCreateLabel ("Métal", 10, 330, 160, 20, $SS_CENTER + $SS_SUNKEN) $l[13] = GuiCtrlCreateLabel ("Cristal", 10, 350, 160, 20, $SS_CENTER + $SS_SUNKEN) $l[14] = GuiCtrlCreateLabel ("Deutérium", 10, 370, 160, 20, $SS_CENTER + $SS_SUNKEN) $l[15] = GuiCtrlCreateLabel ("Global", 180, 310, 80, 20, $SS_CENTER + $SS_SUNKEN) $l[16] = GuiCtrlCreateLabel ("Locale", 260, 310, 720, 20, $SS_CENTER + $SS_SUNKEN) $l[17] = GuiCtrlCreateLabel ("Rappatriement des resources", 10, 410, 160, 20, $SS_CENTER + $SS_SUNKEN) $l[18] = GuiCtrlCreateLabel ("Nombre de ", 10, 430, 90, 20, $SS_RIGHT + $SS_SUNKEN) $l[19] = GuiCtrlCreateLabel ("Rappatriement des resources", 10, 410, 160, 20, $SS_CENTER + $SS_SUNKEN) $l[20] = GuiCtrlCreateLabel ("Batiments de stockage", 10, 470, 160, 20, $SS_CENTER + $SS_SUNKEN) $l[21] = GuiCtrlCreateLabel ("Unité ", 10, 490, 90, 20, $SS_RIGHT + $SS_SUNKEN) $l[22] = GuiCtrlCreateLabel ("ModePM (?)", 180, 490, 80, 20, $SS_CENTER + $SS_SUNKEN) GUICtrlSetTip(-1,"AIDE" & @CRLF & @CRLF & "Ce monde vous permet de définir une planète mère qui stock la totalité de vos ressources" & @CRLF & @CRLF & "Ceci vous permet donc de voir combien de temps il faut à votre planète mère avant d'être " & @CRLF & "en dépassement de capacité en suivant ce schémat que peut-être certains d'entres vous " & @CRLF & "utilisent...") $l[23] = GuiCtrlCreateLabel ("Total", 180, 510, 80, 20, $SS_CENTER + $SS_SUNKEN) $l[24] = GuiCtrlCreateLabel ("Niveau", 260, 510, 720, 20, $SS_CENTER + $SS_SUNKEN) $l[25] = GuiCtrlCreateLabel ("Hangar de métal", 10, 530, 160, 20, $SS_CENTER + $SS_SUNKEN) $l[26] = GuiCtrlCreateLabel ("Hangar de cristal", 10, 590, 160, 20, $SS_CENTER + $SS_SUNKEN) $l[27] = GuiCtrlCreateLabel ("Réservoir de deutérium", 10, 650, 160, 20, $SS_CENTER + $SS_SUNKEN) For $d = 1 To 3 $l[29] = GuiCtrlCreateLabel ("Capacité de Stocage", 10, 490 + ($d * 60), 160, 20, $SS_CENTER + $SS_SUNKEN) GuiCtrlSetBkColor ( -1, 0xB0C5E0) $l[29] = GuiCtrlCreateLabel ("Apparition Surplus", 10, 510 + ($d * 60), 160, 20, $SS_CENTER + $SS_SUNKEN) GuiCtrlSetBkColor ( -1, 0xB0C5E0) next ;} ;------------------------------------------------------------- ; input ;------------------------------------------------------------- For $iCount = 1 To 9 ;------------------------------------------------------------- ; planètes ;------------------------------------------------------------- ;{ $namep[$iCount] = GUICtrlCreateInput ($namep[$iCount], 180 + ($iCount * 80), 50, 80, 20, $SS_CENTER) $nbcasep[$iCount] = GUICtrlCreateInput ($nbcasep[$iCount], 180 + ($iCount * 80), 70, 80, 20, $SS_CENTER) $Tmaxp[$iCount] = GUICtrlCreateInput ($Tmaxp[$iCount], 180 + ($iCount * 80), 90, 80, 20, $SS_CENTER) ;} ;------------------------------------------------------------- ; Production Minière ;------------------------------------------------------------- ;{ $lvlMmp[$iCount] = GUICtrlCreateInput ($lvlMmp[$iCount], 180 + ($iCount * 80), 170, 25, 21, $SS_CENTER) $PourcMmp[$iCount] = GUICtrlCreateCombo ("", 205 + ($iCount * 80), 170, 55) GUICtrlSetData ($PourcMmp[$iCount], "100%|90%|80%|70%|60%|50%|40%|30%|20%|10%|0%", "100%") $lvlMcp[$iCount] = GUICtrlCreateInput ($lvlMcp[$iCount], 180 + ($iCount * 80), 191, 25, 21, $SS_CENTER) $PourcMcp[$iCount] = GUICtrlCreateCombo ("", 205 + ($iCount * 80), 191, 55) GUICtrlSetData ($PourcMcp[$iCount], "100%|90%|80%|70%|60%|50%|40%|30%|20%|10%|0%", "100%") $lvlSdp[$iCount] = GUICtrlCreateInput ($lvlSdp[$iCount], 180 + ($iCount * 80), 212, 25, 21, $SS_CENTER) $PourcSdp[$iCount] = GUICtrlCreateCombo ("", 205 + ($iCount * 80), 212, 55) GUICtrlSetData ($PourcSdp[$iCount], "100%|90%|80%|70%|60%|50%|40%|30%|20%|10%|0%", "100%") $a[1] = GuiCtrlCreateLabel ($Econsop[$iCount], 180 + ($iCount * 80), 233, 80, 20, $SS_CENTER + $SS_SUNKEN) GuiCtrlSetBkColor ( -1, 0xB0C5E0) ;} ;------------------------------------------------------------- ; Bilan des extractions de ressources ;------------------------------------------------------------- ;{ $a[2] = GuiCtrlCreateLabel ("Période", 490, 270, 80, 20, $SS_CENTER + $SS_SUNKEN) $Prodperiod = GUICtrlCreateCombo ("1H", 570, 270, 50) GUICtrlSetData (-1 ,"24H|48H|72H|7J|14J|30J") $a[3] = GuiCtrlCreateLabel ( $ProdMmG, 180, 330, 80, 20, $SS_CENTER + $SS_SUNKEN) $a[4] = GuiCtrlCreateLabel ( $ProdMcG, 180, 350, 80, 20, $SS_CENTER + $SS_SUNKEN) $a[5] = GuiCtrlCreateLabel ( $ProdSdG, 180, 370, 80, 20, $SS_CENTER + $SS_SUNKEN) $a[6] =GuiCtrlCreateLabel (CalcProdM( 30, $lvlMmp[$iCount], GUICtrlRead ($PourcMmp[$iCount])), 180 + ($iCount * 80), 330, 80, 20, $SS_CENTER+ $SS_SUNKEN) GuiCtrlSetBkColor ( -1, 0xB0C5E0) $a[7] =GuiCtrlCreateLabel ($ProdMcp[$iCount], 180 + ($iCount * 80), 350, 80, 20, $SS_CENTER + $SS_SUNKEN) GuiCtrlSetBkColor ( -1, 0xB0C5E0) $a[8] =GuiCtrlCreateLabel ($ProdSdp[$iCount], 180 + ($iCount * 80), 370, 80, 20, $SS_CENTER + $SS_SUNKEN) GuiCtrlSetBkColor ( -1, 0xB0C5E0) ;} ;------------------------------------------------------------- ; Rappatriement des resources ;------------------------------------------------------------- ;{ GUICtrlCreateCombo ("", 100, 430, 55, "") GUICtrlSetData (-1, "Gt|Pt") $a[9] = GuiCtrlCreateLabel ($nbtransT, 180, 430, 80, 20, $SS_CENTER + $SS_SUNKEN) GuiCtrlSetBkColor ( -1, 0xB0C5E0) $a[10] = GuiCtrlCreateLabel ($nbtransp[$iCount], 180 + ($iCount * 80), 430, 80, 20, $SS_CENTER + $SS_SUNKEN) GuiCtrlSetBkColor ( -1, 0xB0C5E0) ;} ;------------------------------------------------------------- ; Batiments de stockage ;------------------------------------------------------------- ;{ GUICtrlCreateCombo ("", 100, 490, 55, "") GUICtrlSetData (-1, "Kilo|Mega") GUICtrlCreateRadio ("", 220 + ($iCount * 80), 490, 80, 20) $lvlHmp[$iCount] = GUICtrlCreateInput ($lvlHmp[$iCount] , 180 + ($iCount * 80), 530, 80, 20, $SS_CENTER) $lvlHcp[$iCount] = GUICtrlCreateInput ($lvlHcp[$iCount] , 180 + ($iCount * 80), 590, 80, 20, $SS_CENTER) $lvlRdp[$iCount] = GUICtrlCreateInput ($lvlRdp[$iCount] , 180 + ($iCount * 80), 650, 80, 20, $SS_CENTER) $a[11] = GuiCtrlCreateLabel ($CapaHmT, 180, 550, 80, 20, $SS_CENTER + $SS_SUNKEN) GuiCtrlSetBkColor ( -1, 0xB0C5E0) $a[12] = GuiCtrlCreateLabel ($CapaHmp[$iCount], 180 + ($iCount * 80), 550, 80, 20, $SS_CENTER + $SS_SUNKEN) GuiCtrlSetBkColor ( -1, 0xB0C5E0) $a[13] = GuiCtrlCreateLabel ($CapaHcT, 180, 610, 80, 20, $SS_CENTER + $SS_SUNKEN) GuiCtrlSetBkColor ( -1, 0xB0C5E0) $a[14] = GuiCtrlCreateLabel ($CapaHcp[$iCount], 180 + ($iCount * 80), 610, 80, 20, $SS_CENTER + $SS_SUNKEN) GuiCtrlSetBkColor ( -1, 0xB0C5E0) $a[15] = GuiCtrlCreateLabel ($CapaRdT, 180, 670, 80, 20, $SS_CENTER + $SS_SUNKEN) GuiCtrlSetBkColor ( -1, 0xB0C5E0) $a[16] = GuiCtrlCreateLabel ($CapaRdp[$iCount], 180 + ($iCount * 80), 670, 80, 20, $SS_CENTER + $SS_SUNKEN) GuiCtrlSetBkColor ( -1, 0xB0C5E0) $a[17] = GuiCtrlCreateLabel ($TCapaHmp[$iCount], 180 + ($iCount * 80), 570, 80, 20, $SS_CENTER + $SS_SUNKEN) GuiCtrlSetBkColor ( -1, 0xB0C5E0) $a[18] = GuiCtrlCreateLabel ($TCapaHcp[$iCount], 180 + ($iCount * 80), 630, 80, 20, $SS_CENTER + $SS_SUNKEN) GuiCtrlSetBkColor ( -1, 0xB0C5E0) $a[19] = GuiCtrlCreateLabel ($TCapaRdp[$iCount], 180 + ($iCount * 80), 690, 80, 20, $SS_CENTER + $SS_SUNKEN) GuiCtrlSetBkColor ( -1, 0xB0C5E0) ;} Next ;------------------------------------------------------------- ; deuxieme onglet ;------------------------------------------------------------- For $c = 0 To 40 GuiCtrlSetBkColor ($l[$c], 0xB0C5E0) GuiCtrlSetBkColor ($a[$c], 0xB0C5E0) Next $save = GuiCtrlCreateButton ("Sauver", 490, 720, 100, 30) $calc = GuiCtrlCreateButton ("calc", 590, 720, 100, 30) GuiSetState () While 1 $Msg = GuiGetMsg() ;------------------------------------------------------------- ; Sauvegarde des données ;------------------------------------------------------------- If $msg = $save Then For $iCount = 1 To 9 iniWrite ( "DB.ini", "planète" & $iCount, "namep", GUICtrlRead ($namep[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "nbcasep", GUICtrlRead ($nbcasep[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "Tmaxp", GUICtrlRead ($Tmaxp[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "lvlMmp", GUICtrlRead ($lvlMmp[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "lvlMcp", GUICtrlRead ($lvlMcp[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "lvlSdp", GUICtrlRead ($lvlSdp[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "lvlHmp", GUICtrlRead ($lvlHmp[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "lvlHcp", GUICtrlRead ($lvlHcp[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "lvlRdp", GUICtrlRead ($lvlRdp[$iCount])) Next endif If $msg = $calc Then For $iCount = 1 To 9 ;------------------------------------------------------------- ; calculs ;------------------------------------------------------------- ;{ #cs Local $coeff[$iCount] = GUICtrlRead ($PourcMmp[$iCount]) select case $coeff[$iCount] = "100%" $coeff[$iCount] = 1 case $coeff[$iCount] = "90%" $coeff[$iCount] = 0.9 case $coeff[$iCount] = "80%" $coeff[$iCount] = 0.8 case $coeff[$iCount] = "70%" $coeff[$iCount] = 0.7 case $coeff[$iCount] = "60%" $coeff[$iCount] = 0.6 case $coeff[$iCount] = "50%" $coeff[$iCount] = 0.5 case $coeff[$iCount] = "40%" $coeff[$iCount] = 0.4 case $coeff[$iCount] = "30%" $coeff[$iCount] = 0.3 case $coeff[$iCount] = "20%" $coeff[$iCount] = 0.2 case $coeff[$iCount] = "10%" $coeff[$iCount] = 0.1 case $coeff[$iCount] = "0%" $coeff[$iCount] = 0 EndSelect ;$ProdMmp[$iCount] = int( $lvlMmp[$iCount] * 1.1 ^ $lvlMmp[$iCount]) #ce ;} Next endif ;Until $msg = $GUI_EVENT_CLOSE; Continue loop untill window is closed select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd func CalcProdM( $v, $lvl, $coeff) ;Local $p = $coeff select case $coeff = "100%" $p = 1 case $coeff = "90%" $p = 0.9 case $coeff = "80%" $p = 0.8 case $coeff = "70%" $p = 0.7 case $coeff = "60%" $p = 0.6 case $coeff = "50%" $p = 0.5 case $coeff = "40%" $p = 0.4 case $coeff = "30%" $p = 0.3 case $coeff = "20%" $p = 0.2 case $coeff = "10%" $p = 0.1 case $coeff = "0%" $p = 0 EndSelect if $v * $lvl <> 0 Then return int( $v * $lvl * 1.1 ^ $lvl ) * $p ;return = $ProdM endif EndFunc Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 26, 2006 Share Posted July 26, 2006 func CalcProdM() don't return the correct value from the array. the value are 61235 for $lvlMmp[1] = 25 please help other question, i want to refresh the label after having had data in input box (with button $calc) CODE $lvlMmp[$iCount] = GUICtrlCreateInput ($lvlMmp[$iCount], 180 + ($iCount * 80), 170, 25, 21, $SS_CENTER) $PourcMmp[$iCount] = GUICtrlCreateCombo ("", 205 + ($iCount * 80), 170, 55) GUICtrlSetData ($PourcMmp[$iCount], "100%|90%|80%|70%|60%|50%|40%|30%|20%|10%|0%", "100%") $a[6] =GuiCtrlCreateLabel (CalcProdM( 30, $lvlMmp[$iCount], GUICtrlRead ($PourcMmp[$iCount])), 180 + ($iCount * 80), 330, 80, 20, $SS_CENTER+ $SS_SUNKEN) $save = GuiCtrlCreateButton ("Sauver", 490, 720, 100, 30) $calc = GuiCtrlCreateButton ("calc", 590, 720, 100, 30) GuiSetState () While 1 $Msg = GuiGetMsg() ;------------------------------------------------------------- ; Sauvegarde des données ;------------------------------------------------------------- If $msg = $save Then For $iCount = 1 To 9 iniWrite ( "DB.ini", "planète" & $iCount, "namep", GUICtrlRead ($namep[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "nbcasep", GUICtrlRead ($nbcasep[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "Tmaxp", GUICtrlRead ($Tmaxp[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "lvlMmp", GUICtrlRead ($lvlMmp[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "lvlMcp", GUICtrlRead ($lvlMcp[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "lvlSdp", GUICtrlRead ($lvlSdp[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "lvlHmp", GUICtrlRead ($lvlHmp[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "lvlHcp", GUICtrlRead ($lvlHcp[$iCount])) iniWrite ( "DB.ini", "planète" & $iCount, "lvlRdp", GUICtrlRead ($lvlRdp[$iCount])) Next endif If $msg = $calc Then For $iCount = 1 To 9 ;------------------------------------------------------------- ; calculs ;------------------------------------------------------------- ;{ #cs Local $coeff[$iCount] = GUICtrlRead ($PourcMmp[$iCount]) select case $coeff[$iCount] = "100%" $coeff[$iCount] = 1 case $coeff[$iCount] = "90%" $coeff[$iCount] = 0.9 case $coeff[$iCount] = "80%" $coeff[$iCount] = 0.8 case $coeff[$iCount] = "70%" $coeff[$iCount] = 0.7 case $coeff[$iCount] = "60%" $coeff[$iCount] = 0.6 case $coeff[$iCount] = "50%" $coeff[$iCount] = 0.5 case $coeff[$iCount] = "40%" $coeff[$iCount] = 0.4 case $coeff[$iCount] = "30%" $coeff[$iCount] = 0.3 case $coeff[$iCount] = "20%" $coeff[$iCount] = 0.2 case $coeff[$iCount] = "10%" $coeff[$iCount] = 0.1 case $coeff[$iCount] = "0%" $coeff[$iCount] = 0 EndSelect ;$ProdMmp[$iCount] = int( $lvlMmp[$iCount] * 1.1 ^ $lvlMmp[$iCount]) #ce ;} Next endif ;Until $msg = $GUI_EVENT_CLOSE; Continue loop untill window is closed select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd func CalcProdM( $v, $lvl, $coeff) ;Local $p = $coeff select case $coeff = "100%" $p = 1 case $coeff = "90%" $p = 0.9 case $coeff = "80%" $p = 0.8 case $coeff = "70%" $p = 0.7 case $coeff = "60%" $p = 0.6 case $coeff = "50%" $p = 0.5 case $coeff = "40%" $p = 0.4 case $coeff = "30%" $p = 0.3 case $coeff = "20%" $p = 0.2 case $coeff = "10%" $p = 0.1 case $coeff = "0%" $p = 0 EndSelect if $v * $lvl <> 0 Then return int( $v * $lvl * 1.1 ^ $lvl ) * $p ;return = $ProdM endif EndFunc It is generally bad form to re-use a variable name in your function declaration. Functions should have unique local variables for passing data that are not used in the global scope... on the other hand, that whole block of code that is also using $coeff is commented out with #cs/#ce? Put a debug MsgBox() at the top of the function to make sure you are getting the inputs you wanted: func CalcProdM( $v, $lvl, $coeff) MsgBox(64, "Debug", "Inputs to CalcProdM():" & @CRLF & _ @Tab & "$v = " & $v & @CRLF & _ @Tab & "$lvv = " & $lvl & @CRLF & _ @Tab & "$coeff = " & $coeff) select case $coeff = "100%" $p = 1 case $coeff = "90%" $p = 0.9 case $coeff = "80%" $p = 0.8 case $coeff = "70%" $p = 0.7 case $coeff = "60%" $p = 0.6 case $coeff = "50%" $p = 0.5 case $coeff = "40%" $p = 0.4 case $coeff = "30%" $p = 0.3 case $coeff = "20%" $p = 0.2 case $coeff = "10%" $p = 0.1 case $coeff = "0%" $p = 0 EndSelect if $v * $lvl <> 0 Then return int( $v * $lvl * 1.1 ^ $lvl ) * $p endif EndFunc If the correct inputs are arriving at the function, do the math in steps to see where it breaks down. Instead of using: int( $v * $lvl * 1.1 ^ $lvl ) * $p Try: $Rtn = 1.1 ^ $lvl MsgBox(64, "Debug", "1.1 ^ $lvl = " & $Rtn) $Rtn = $Rtn * $lvl MsgBox(64, "Debug", "$lvl * 1.1 ^ $lvl = " & $Rtn) $Rtn = $Rtn * $v MsgBox(64, "Debug", "$v * $lvl * 1.1 ^ $lvl = " & $Rtn) $Rtn = Int($Rtn) MsgBox(64, "Debug", "Int($v * $lvl * 1.1 ^ $lvl) = " & $Rtn) $Rtn = $Rtn * p MsgBox(64, "Debug", "Int($v * $lvl * 1.1 ^ $lvl) * p = " & $Rtn) Doing it step by step will allow you to see what doesn't work as expected. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
AsLY Posted July 26, 2006 Author Share Posted July 26, 2006 Thank for helping, i have forget a GuiCtrlread in my code i am so noob hum in fact how to make sum of the label $a[6] to show it in $a[3] [autoit]#Include <GuiConstants.au3> #Include <File.au3> #Include <date.au3> #NoTrayIcon ;$Window_Color = 0x00e0ff ;GUISetBkColor ($Window_Color) ;$bk = GuiCtrlSetBkColor (-1, 0x08345E) ;GUICtrlSetColor (-1, 0xffffff) ; ;GuiCtrlCreateTab (10, 0, 1000, 360) ;GuiCtrlCreateTabItem ("two") ;------------------------------------------------------------- ; variables ;------------------------------------------------------------- ;{ Global $namep[10], $nbcasep[10], $Tmaxp[10], $lvlMmp[10], $lvlMcp[10], $lvlSdp[10], $PourcMmp[10], $PourcMcp[10], $PourcSdp[10], $Econsop[10], $ProdMmp[10], $ProdMcp[10], $ProdSdp[10], $nbtransp[10], $lvlHmp[10], $lvlHcp[10], $lvlRdp[10], $CapaHmp[10], $CapaHcp[10], $CapaRdp[10], $TCapaHmp[10], $TCapaHcp[10], $TCapaRdp[10] Global $nplanete[10], $l[100], $a[100] $ProdMmG = 0 $ProdMcG = 0 $ProdSdG = 0 $nbtransT = 0 $CapaHmT = 0 $CapaHcT = 0 $CapaRdT = 0 ;} ;------------------------------------------------------------- ; fenetre principal et premier onglet ;------------------------------------------------------------- ;{ GuiCreate ("Autoit - O v beta 0.1", 1000, 800, (@DesktopWidth-1000)/2, (@DesktopHeight-800)/2 ,$WS_EX_WINDOWEDGE + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_SYSMENU + $WS_MINIMIZEBOX) GuiCtrlCreateTab (0, 0, 1000, 800,$WS_VISIBLE + $WS_CLIPSIBLINGS) GuiCtrlCreateTabItem ("Empire page 1") ;} ;------------------------------------------------------------- ; titre ligne ;------------------------------------------------------------- ;{ $l[1] = GuiCtrlCreateLabel ("Plan Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 26, 2006 Share Posted July 26, 2006 (edited) Thank for helping, i have forget a GuiCtrlread in my code i am so noob hum in fact how to make sum of the label $a[6] to show it in $a[3] I'm not at all sure what you mean. Labels are static text (though AutoIT makes translations between stings of numeric characters and actual numeric values). When you create a label with GuiCreateLabel(), it returns the ControlID of the label, not the text from it. So what does it mean to take the "sum of the label"? The contents of $a[1] through $a[19] from the code below is a list of the ContolIDs for the labels, not the text or any numbers from the data in the label. If you want to set the text in the label whose ContolID is stored at $a[3], then use GuiCtrlSetData(): GuiCtrlSetData($a[3], "This is my new text") To copy the value from data from the controlID at $[6] to the data in the ControlID at $a[3]: ; On one line: GuiCtrlSetData($a[3], GuiCtrlRead($a[6])) ; In two lines for clarity: $LabelData = GuiCtrlRead($a[6]) GuiCtrlSetData($a[3], $LabelData) To add the data from the label specified by $a[6] to the one specified by $a[3]: GuiCtrlSetData($a[3], GuiCtrlRead($a[6]) + GuiCtrlRead($a[3])) Since you didn't provide the .ini file that goes with this it shows me an empty GUI. I therefor have no idea what you are trying to do. Edited July 26, 2006 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
AsLY Posted July 26, 2006 Author Share Posted July 26, 2006 I understood but in my script one lable create 9 out with 9 data, the probleme is to extract the data during the loop. i want to make the sum of CalcProdMC( 30, 20,GUICtrlRead ($lvlMmp[$iCount]), GUICtrlRead ($PourcMmp[$iCount]), GUICtrlRead ($Prodperiod)) from $iCount = 1 to 9 and send the result in label $a[3]. For the ini file it is create auto when you clik on save button with iniWrite, i don't make the ini it's automaticly create. Link to comment Share on other sites More sharing options...
rbhkamal Posted July 27, 2006 Share Posted July 27, 2006 Since you didn't provide the .ini file that goes with this it shows me an empty GUI. I therefor have no idea what you are trying to do.Don't use Autoit Beta on his script. "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
AsLY Posted July 27, 2006 Author Share Posted July 27, 2006 Yes i don't use the beta... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now