amirc Posted December 24, 2005 Share Posted December 24, 2005 (edited) ok i did a fucntion: func get_id($code,$list) local $i,$result $result = -1; return -1 at error for $i = 0 to Ubound($list)-1 if $list[$i][1] = $code then $result = $i exitloop endif next return $result endfunc is ther any better way to do it? Edited December 24, 2005 by amirc Link to comment Share on other sites More sharing options...
Developers Jos Posted December 24, 2005 Developers Share Posted December 24, 2005 ok i did a fucntion: func get_id($code,$list) local $i,$result $result = -1; return -1 at error for $i = 0 to Ubound($list)-1 if $list[$i][1] = $code then $result = $i exitloop endif next return $result endfunc is ther any better way to do it?Depends if it is sorted,. because if it is you can use _ArrayBinarySearch(). 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...
Moderators SmOke_N Posted December 24, 2005 Moderators Share Posted December 24, 2005 for $i = 0 to Ubound($list)-1Does the '0' store a needed variable for you? If not you could replace it with '1' which is normally the case with Ubound()-1 in my experience.There's no other information provided other than the loop really, so... I'd have to say 'Who Knows' if there is a better way without seeing what it is your sending to the function. If it works, then it looks good Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
amirc Posted December 24, 2005 Author Share Posted December 24, 2005 i will give you exmple of what in side the array $list[0][0] = 'black lotus' ; card name $list[0][1] = 12342355155 ; pixlechecksum of the card $list[0][2] = 1 ; buying prise $list[0][3] = 2 ; selling prise ther are lots(100-200) of cards names with diffrent buy\sell prises and diffrent pixlechecksum. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 24, 2005 Developers Share Posted December 24, 2005 i will give you exmple of what in side the array $list[0][0] = 'black lotus' ; card name $list[0][1] = 12342355155 ; pixlechecksum of the card $list[0][2] = 1 ; buying prise $list[0][3] = 2 ; selling prise ther are lots(100-200) of cards names with diffrent buy\sell prises and diffrent pixlechecksum.Well, as said ... if the whole array is sorted in alphabetical order, the binary search is the fastest method. 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...
amirc Posted December 24, 2005 Author Share Posted December 24, 2005 witch one need to be alphabetical? the card name? or the PixleCheckSum? Link to comment Share on other sites More sharing options...
Developers Jos Posted December 24, 2005 Developers Share Posted December 24, 2005 witch one need to be alphabetical?the card name?or the PixleCheckSum?The key you are searching for... 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...
amirc Posted December 24, 2005 Author Share Posted December 24, 2005 how can i sort it? what to write as a parameter at: _ArraySort() _ArraySort($list[][1]) ? Link to comment Share on other sites More sharing options...
Developers Jos Posted December 24, 2005 Developers Share Posted December 24, 2005 how can i sort it? what to write as a parameter at: _ArraySort() _ArraySort($list[][1]) ?_ArraySort ( ByRef $a_Array, [$i_Descending[, $i_Base=0[, $i_Ubound=0[, $i_Dim=1[, $i_SortIndex=0]]]]] ) so I would say: _ArraySort ( $list, 0, 0, 0, 2, 1) 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