Jump to content

Recommended Posts

Posted (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 by amirc
  • Developers
Posted

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.
  :)

  • Moderators
Posted

for $i = 0 to Ubound($list)-1

Does 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 :P

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.

Posted

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.

  • Developers
Posted

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.
  :)

  • Developers
Posted

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)

:P

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.
  :)

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...