JohnOne Posted December 9, 2009 Share Posted December 9, 2009 (edited) Im trying to find if a value occurs twice after a given in an array But I cant get it right, probably multiple mistakes here I cant test it cause my PC with autoit is down. Local $ablah[9] = [y,y,d,f,y,s,y,d,k] _function($ablah) Func _function($ablah) If $ablah[0] = $ablah[1] Then For $i = 2 To 8 If $ablah[$i] = $ablah[0] Then $x = $i For $z = $x To 8 If $ablah[$z] = $ablah[0] Then $bool = True EndIf Next EndIf Next EndIf Return $bool EndFunc Appreciate any help with my useless logic. EDIT: not much Edited December 9, 2009 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 9, 2009 Developers Share Posted December 9, 2009 exactly 2 times or 2 and more ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
JohnOne Posted December 9, 2009 Author Share Posted December 9, 2009 (edited) $ablah[0] and $ablah[1] will always be the same Im trying a function to see if two others between [2] to [9] are equal to [0] EDIT: sorry, it could be ubound($ablah) Edited December 9, 2009 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 9, 2009 Developers Share Posted December 9, 2009 $ablah[0] and $ablah[1] will always be the same Im trying a function to see if two others between [2] to [9] are equal to [0] Ok, but what about if it are 3 others? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 9, 2009 Developers Share Posted December 9, 2009 (edited) Just update the if to >= if its 2 or more: Local $ablah[9] = ["y","y","d","f","y","","y","dx","k"] If _function($ablah) then ConsoleWrite("there are 2 or more equal values in the array" & @CR) EndIf Func _function($ablah) $count = 0 For $i = 2 To 8 If $ablah[0] == $ablah[$i] Then $count += 1 Next If $count = 2 then Return True Return False EndFunc Edited December 9, 2009 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
JohnOne Posted December 9, 2009 Author Share Posted December 9, 2009 2 others or more should male $bool = True AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 9, 2009 Developers Share Posted December 9, 2009 Local $ablah[9] = ["y","y","d","f","y","","y","dx","k"] If _function($ablah) then ConsoleWrite("there are 2 or more equal values in the array" & @CR) EndIf Func _function($ablah) $count = 0 For $i = 2 To 8 If $ablah[0] == $ablah[$i] Then $count += 1 If $count = 2 then Return True Next Return False EndFunc SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
JohnOne Posted December 9, 2009 Author Share Posted December 9, 2009 Thanks Jos, Appreciated If you can be bothered, I have not been able to discover why/if == and = are diferent and mean diferent things, I have looked tons of times but cannot grast it. Any link to an explaination ? Thanks again. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 9, 2009 Developers Share Posted December 9, 2009 Thanks Jos, Appreciated If you can be bothered, I have not been able to discover why/if == and = are diferent and mean diferent things, I have looked tons of times but cannot grast it. Any link to an explaination ? Thanks again. From the helpfile: = Tests if two values are equal (case insensitive if used with strings). e.g. If $var= 5 Then (true if $var equals 5) == Tests if two values are equal (case sensitive if used with strings) So: If "a" = "A" then ; is true If "a" == "A" then ; is false SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
JohnOne Posted December 9, 2009 Author Share Posted December 9, 2009 Thanks once again, lesson complete. I do remember reading about that before I even started to try autoit3 but could never find it again Thanks for you help and time. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 9, 2009 Developers Share Posted December 9, 2009 Thanks once again, lesson complete.I do remember reading about that before I even started to try autoit3 but could never find it againThanks for you help and time.Its in:"Language reference"/Operators SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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