lol98 Posted December 20, 2005 Share Posted December 20, 2005 (edited) hate to ask but ive got some code im trying to get to work and cant seem to get a working counter of any sort first i tried Func winzadd() Global $Winz[1] Dim $oldwinz[1] $Newwinz = ( $oldwinz[0] + 1 ) $Winz[0] = ( $oldwinz[0] + ($Newwinz - $oldwinz[0]) ) $oldwinz[0] = ( $Newwinz - 1 ) IF $Winz[0] = $Newwinz Then $Winz[0] = $oldwinz[0] Return $oldwinz ElseIf $Winz[0] = $oldwinz[0] Then $Winz[0] = $Newwinz Return $Winz Endif Endfunc Returns 0 also ive tried While(1) winzadd() MsgBox(0, "test", $winz ) Wend Func winzadd() Global $Winz[1] $Winz = _ArrayCreate("0") ;$Winz[0] = ( $Winz[0] + 1 ) IF $Winz[0] = $Winz[0] Then $Winz = ( $Winz[0] + 1 ) Return $Winz Endif Endfunc but its not counting up! help? please Can anyone help me making a counter. usually simple code works but since im calling it in another func i have to get it to return it globally heres wut i need it to do start with value 0 aftr first call to the func make it 1 then again after 2nd make it 2 etc If at all posible id like to use a 1 spot array. to keep from haing to use a gui because its just a snippit of code ive packed into a 12kb bot ;/ i just wanted to make a counter for amount of wins to spam it out in my advertisements up untill the 3.1.1 upgrade something like If $x = $x Then $x = ( $x + 1 ) would have worked because ive used such code before. but why wont it now? Edited December 20, 2005 by lol98 Link to comment Share on other sites More sharing options...
Shin Posted December 20, 2005 Share Posted December 20, 2005 hi! Maybe you can try to use a .INI files, in which you will write something like [counter] count=0 Then if the condition you expect arrive, you can say to your script to add +1 to the count...and make it appears as a msgbox... Link to comment Share on other sites More sharing options...
lol98 Posted December 20, 2005 Author Share Posted December 20, 2005 never used an ini before. hmm seems like a good idea but how am i going to get my app to write the proper value for it if counttowritetofile = (count+1) but +1 seems to be not working. Link to comment Share on other sites More sharing options...
MrSpacely Posted December 20, 2005 Share Posted December 20, 2005 (edited) uhm you used arrays and global vars counters are simple $counter=0 while 1 $counter += 1 sleep(100) msgbox(64,"Counter",$counter) wend and then you say If $x = $x Then $x = ( $x + 1 )really useless if statement $x=$x is always true so just $x = $x +1 or shorter $x += 1 (the += is from beta but I tested beta its more stable then 3.1.1.0) and shin he just wants a counter only he made a really weird big way to try it donot use global vars func countmeup($inputvar) return $inputvar + 1 endfunc Edited December 20, 2005 by MrSpacely Link to comment Share on other sites More sharing options...
lol98 Posted December 20, 2005 Author Share Posted December 20, 2005 well im kinda gonna be calling it from many parts of my script so yea i used global. Link to comment Share on other sites More sharing options...
MrSpacely Posted December 20, 2005 Share Posted December 20, 2005 well im kinda gonna be calling it from many parts of my script so yea i used global.Global means outside of the function. (in autoit at least)Always use the function return function is better and saver.Explain what you actually need you used so much if statements wich didn't do anything.it makes the code really big and its not needed here. Link to comment Share on other sites More sharing options...
lol98 Posted December 20, 2005 Author Share Posted December 20, 2005 (edited) well i wanted a function that would return a value which should start @ 0 and be easy to call by lets say send($var) in ANOTHER function. or two i code autoit in weird ways if u seen my bot script ud be like omfg no way that crap works!!!1!1! lol Edited December 20, 2005 by lol98 Link to comment Share on other sites More sharing options...
CyberSlug Posted December 20, 2005 Share Posted December 20, 2005 (edited) You CANNOT print your array with the lineMsgBox(0, "test", $winz ) You would need something like:Dim $output = "" For $i = 0 to UBound($winz)-1 $output = $output & $winz[$i] Next MsgBox(0,"test",$output) edit: forgot code tags Edited December 20, 2005 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
MrSpacely Posted December 20, 2005 Share Posted December 20, 2005 Func winzadd() Global $Winz[1] Dim $oldwinz[1] $Newwinz = ( $oldwinz[0] + 1 ) $Winz[0] = ( $oldwinz[0] + ($Newwinz - $oldwinz[0]) ) $oldwinz[0] = ( $Newwinz - 1 ) IF $Winz[0] = $Newwinz Then $Winz[0] = $oldwinz[0] Return $oldwinz ElseIf $Winz[0] = $oldwinz[0] Then $Winz[0] = $Newwinz Return $Winz Endif Endfunc this code has no input variable I also donot understand the use of [0] wich is a array Link to comment Share on other sites More sharing options...
MrSpacely Posted December 20, 2005 Share Posted December 20, 2005 (edited) well i wanted a function that would return a value which should start @ 0 and be easy to call by lets say send($var) in ANOTHER function. or two i code autoit in weird ways if u seen my bot script ud be like omfg no way that crap works!!!1!1! lol hmm simply $counter = 0 while 1 send(countmeup($counter)) sleep(1000) wend Func countmeup(byref $inputvar) $inputvar = $inputvar + 1 return $inputvar endfunc this code sends a numder counting up every second the function countmeup uses the input parameter variable and adds up 1 number and also returns it so $counter gets changed and you get a return value this is done using the byref parameter Any if statement you use wich is like $x = $x can be removed because the always is true if 1 = 1 then msgbox(0,"","hmm 1 is 1 how weird") would be same as msgbox(0,"","hmm 1 is 1 how weird") Edited December 20, 2005 by MrSpacely Link to comment Share on other sites More sharing options...
lol98 Posted December 20, 2005 Author Share Posted December 20, 2005 (edited) hmm ur code is weird it errors parsing your call with param. ahh i c need extra ) Edited December 20, 2005 by lol98 Link to comment Share on other sites More sharing options...
MrSpacely Posted December 20, 2005 Share Posted December 20, 2005 hmm ur code is weird it errors parsing your call with param. ahh i c need extra )Yes I see i forgot one bracket 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