Scanzee Posted October 31, 2005 Share Posted October 31, 2005 $Bedrag = 13750 $Money = StringSplit($Bedrag ,"") $Gold = $Money[1] $SilverPlate = $Money[2] $Silver = $Money[3] & $Money[4] & $Money[5] $Label04ID = GUICtrlCreateLabel("Je hebt " & $gold & " Gold " & $Silverplate & " Silverplate " & $Silver &" Silver", 530, 20,300,20) --------------------------------------------------------------------------------------------------------------------------- This part of the script works until you do $Bedrag - 10000...:s When you do $Bedrag - 10 or any low value there is no problem until he has to change $Money[1] What am I doing wrong?! Scanzee Products <Scanzee@hotmail.com> Link to comment Share on other sites More sharing options...
Valuater Posted October 31, 2005 Share Posted October 31, 2005 $Bedrag = 13750 $Money = StringSplit($Bedrag ,"") gives a 6 level array and works for you r comparison $Bedrag = 13750 - 10000 $Money = StringSplit($Bedrag ,"") does not give 6 levels only 5 levels thus your array split will not work 8) Link to comment Share on other sites More sharing options...
Scanzee Posted October 31, 2005 Author Share Posted October 31, 2005 So what do I have to do?! Do you have anything for my sow it will work? Link to comment Share on other sites More sharing options...
Nuffilein805 Posted October 31, 2005 Share Posted October 31, 2005 just do ask your array how long it is: $Bedrag = 13750 $Money = stringsplit ($Bedrag, "") select case $Money[0] = 5 $Gold = $Money[1] $SilverPlate = $Money[2] $Silver = $Money[3] & $Money[4] & $Money[5] case $Money[0] = 4 $Gold = 0 $SilverPlate = $Money[1] $Silver = $Money[2] & $Money[3] & $Money[4] case $Money[0] = 3 $Gold = 0 $SilverPlate = 0 $Silver = $Money[1] & $Money[2] & $Money[3] case $Money[0] = 2 $Gold = 0 $SilverPlate = 0 $Silver = $Money[1] & $Money[2] case $Money[0] = 1 $Gold = 0 $SilverPlate = 0 $Silver = $Money[1] endselect $Label04ID = GUICtrlCreateLabel("Je hebt " & $gold & " Gold " & $Silverplate & " Silverplate " & $Silver &" Silver", 530, 20,300,20) maybe this is what you're looking for my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
Scanzee Posted October 31, 2005 Author Share Posted October 31, 2005 Thanks for that but has someone maybe a shorter way to do all this. Link to comment Share on other sites More sharing options...
Nuffilein805 Posted October 31, 2005 Share Posted October 31, 2005 #Include <String.au3> $Bedrag = 13750 $Money = stringsplit ($Bedrag, "") $a = 0 $Gold = 0 $SilverPlate = 0 $Silver = 0 for $i = $Money[0] to 1 step -1 $a = $a + 1 if $a < 4 then $Silver = $Money[$i] elseif $a = 4 then $SilverPlate = $Money[$i] elseif $a > 4 then $Gold = $Money[$i] endif next $Gold = _stringreverse($Gold) $Silver = _stringreverse($Silver) $Label04ID = GUICtrlCreateLabel("Je hebt " & $gold & " Gold " & $Silverplate & " Silverplate " & $Silver &" Silver", 530, 20,300,20) don't know if thats shorter but will still work if you got 1million and more my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
Valuater Posted October 31, 2005 Share Posted October 31, 2005 (edited) it looks long... i understand... i think just call it in a function...kinda like this idea expandcollapse popupDim $Money[8], $gold, $silver, $SilverPlate $Bedrag = 13750 Money(); call the function $Label04ID = GUICtrlCreateLabel("Je hebt " & $gold & " Gold " & $Silverplate & " Silverplate " & $Silver &" Silver", 530, 20,300,20) ; main script ; ---------------------------------- functions ------------------------------------- Func Money() $Money = stringsplit ($Bedrag, "") If $Money[0] = 5 Then $Gold = $Money[1] $SilverPlate = $Money[2] $Silver = $Money[3] & $Money[4] & $Money[5] EndIf If $Money[0] = 4 Then $Gold = 0 $SilverPlate = $Money[1] $Silver = $Money[2] & $Money[3] & $Money[4] EndIf If $Money[0] = 3 Then $Gold = 0 $SilverPlate = 0 $Silver = $Money[1] & $Money[2] & $Money[3] EndIf If $Money[0] = 2 Then $Gold = 0 $SilverPlate = 0 $Silver = $Money[1] & $Money[2] EndIf If $Money[0] = 1 Then $Gold = 0 $SilverPlate = 0 $Silver = $Money[1] EndIf EndFunc you can place either of Nuffilein805 codes in the function.... or use mine 8) Edited October 31, 2005 by Valuater Link to comment Share on other sites More sharing options...
Nuffilein805 Posted October 31, 2005 Share Posted October 31, 2005 the code is the same and if you just use it in a function your script won't become a mess (like some of mine ) my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
Scanzee Posted October 31, 2005 Author Share Posted October 31, 2005 Yeah how fast you can mess up a script.. Thanks a lot guys.. Link to comment Share on other sites More sharing options...
Valuater Posted October 31, 2005 Share Posted October 31, 2005 Yeah how fast you can mess up a script..Thanks a lot guys..?????please explain8) Link to comment Share on other sites More sharing options...
Scanzee Posted October 31, 2005 Author Share Posted October 31, 2005 #Include <String.au3> $Bedrag = 13750 $Money = stringsplit ($Bedrag, "") $a = 0 $Gold = 0 $SilverPlate = 0 $Silver = 0 for $i = $Money[0] to 1 step -1 $a = $a + 1 if $a < 4 then $Silver = $Money[$i] elseif $a = 4 then $SilverPlate = $Money[$i] elseif $a > 4 then $Gold = $Money[$i] endif next $Gold = _stringreverse($Gold) $Silver = _stringreverse($Silver) $Label04ID = GUICtrlCreateLabel("Je hebt " & $gold & " Gold " & $Silverplate & " Silverplate " & $Silver &" Silver", 530, 20,300,20)don't know if thats shorter but will still work if you got 1million and more----------------------------------------------------------------There is some problem with this script btw...With this script you see this label : 1Gold 3 Silverplate 7 Silverand it has to be 1Gold 3 Silverplate 750 SilverIs there a way you can fix it?! Link to comment Share on other sites More sharing options...
Nuffilein805 Posted October 31, 2005 Share Posted October 31, 2005 ----------------------------------------------------------------There is some problem with this script btw...With this script you see this label : 1Gold 3 Silverplate 7 Silverand it has to be 1Gold 3 Silverplate 750 SilverIs there a way you can fix it?!oooops yes there is#Include <String.au3> $Bedrag = 13750 $Money = stringsplit ($Bedrag, "") $a = 0 $Gold = "" $SilverPlate = 0 $Silver = "" for $i = $Money[0] to 1 step -1 $a = $a + 1 if $a < 4 then $Silver = $Silver & $Money[$i] elseif $a = 4 then $SilverPlate = $Money[$i] elseif $a > 4 then $Gold = $Gold & $Money[$i] endif next $Gold = _stringreverse($Gold) $Silver = _stringreverse($Silver) if $Gold = "" then $Gold = 0 if $Silver = "" then $Silver = 0 $Label04ID = GUICtrlCreateLabel("Je hebt " & $gold & " Gold " & $Silverplate & " Silverplate " & $Silver &" Silver", 530, 20,300,20)sorry haven't thought as i wrote the script my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
Scanzee Posted October 31, 2005 Author Share Posted October 31, 2005 Ok that is the one I was looking for! And please say never to anyone you are going to make some .exe just for fun... Scanzee Products.. Link to comment Share on other sites More sharing options...
Nuffilein805 Posted October 31, 2005 Share Posted October 31, 2005 Ok that is the one I was looking for!And please say never to anyone you are going to make some .exe just for fun...Scanzee Products..do i have to understand what you mean by that?omg i gotta go to bed i'm tired! 10hours in the forum is enough for today my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
Scanzee Posted October 31, 2005 Author Share Posted October 31, 2005 You don't have to understand that.. Where do you live?! Link to comment Share on other sites More sharing options...
LxP Posted November 1, 2005 Share Posted November 1, 2005 Will this work as expected? -- $Bedrag = 13750 $Gold = StringMid($Bedrag, 1, 1) $SilverPlate = StringMid($Bedrag, 2, 1) $Silver = StringMid($Bedrag, 3) $Label04ID = GUICtrlCreateLabel("Je hebt " & $gold & " Gold " & $Silverplate & " Silverplate " & $Silver &" Silver", 530, 20,300,20) Link to comment Share on other sites More sharing options...
Valuater Posted November 1, 2005 Share Posted November 1, 2005 Will this work as expected? --$Bedrag = 13750 $Gold = StringMid($Bedrag, 1, 1) $SilverPlate = StringMid($Bedrag, 2, 1) $Silver = StringMid($Bedrag, 3) $Label04ID = GUICtrlCreateLabel("Je hebt " & $gold & " Gold " & $Silverplate & " Silverplate " & $Silver &" Silver", 530, 20,300,20)seems that would work... but his would work for that statement alsothe problem was---------------------------------------------------------------------------------------------------------------------------This part of the script works until you do $Bedrag - 10000...:sWhen you do $Bedrag - 10 or any low value there is no problem until he has to change $Money[1]What am I doing wrong?!Scanzee Products <Scanzee@hotmail.com>your script gives value to the gold.. like this$Bedrag = 13750 - 10000 $Gold = StringMid($Bedrag, 1, 1) $SilverPlate = StringMid($Bedrag, 2, 1) $Silver = StringMid($Bedrag, 3) $Label04ID = GUICtrlCreateLabel("Je hebt " & $gold & " Gold " & $Silverplate & " Silverplate " & $Silver &" Silver", 530, 20,300,20) MsgBox(0,"Test", "Je hebt " & $gold & " Gold " & $Silverplate & " Silverplate " & $Silver &" Silver")caught-ya smartie.... lol8) Link to comment Share on other sites More sharing options...
LxP Posted November 1, 2005 Share Posted November 1, 2005 Oh darn! I suppose it depends on precisely how the numbers should be manipulated. We would need clarification from Scanzee to be certain. For instance:13750 -> 1G, 3S, 750SP.1375 -> 1G, 3S, 75SP or maybe 0G, 1S, 375SP?...137 -> ??123750 -> ???I would suggest storing the data differently if that's controllable -- e.g. 1-3-750 instead of 13750 because what happens if you have 13 Gold, 7 Silver and 50 SP? (How will you know the difference?) Link to comment Share on other sites More sharing options...
Valuater Posted November 1, 2005 Share Posted November 1, 2005 Oh darn! I would suggest storing the data differently if that's controllable -- e.g. 1-3-750 instead of 13750 because what happens if you have 13 Gold, 7 Silver and 50 SP? (How will you know the difference?)now that is a good one... what if he had 13 gold8) 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