Jump to content

Find a number in an array


Recommended Posts

Just loop through it and keep track of the lower number you have encountered till now. I don't think there is a more efficient way to do it without the array being sorted.

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

Look at _ArrayMin()

EDIT: Sorry I overlooked needed condition for zero/negative numbers, so as TheDCoder said ...

 

here example from helpfile:

#include <Array.au3>

Local $avArray = StringSplit("4,2,06,8,12,5", ",")

MsgBox(0,'Min String value', _ArrayMin($avArray, 0, 1))
MsgBox(0,'Min Numeric value', _ArrayMin($avArray, 1, 0))

 

Edited by Zedna
Link to comment
Share on other sites

Thank you so much! It works for me with this code:

local $FindGreaterO =_ArrayExtract($new,-1,-1,4,4)
For $i = 0 To UBound($FindGreaterO)-1 Step 1
    $FindGreaterO[$i] = StringReplace($FindGreaterO[$i],",",".")
    $FindGreaterO[$i] = Number($FindGreaterO[$i])
Next

For $i = UBound($FindGreaterO) -1 to 0 step -1
    If $FindGreaterO[$i] <= 0.01 Then _ArrayDelete($FindGreaterO, $i)
Next
$FindNull=StringReplace(_ArrayMin($FindGreaterO),".",",")
ConsoleWrite($FindGreaterO)

 

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...