Page 1 of 1

search a number of on array

Posted: Fri May 27, 2022 8:13 pm
by Silvio.Falconi
I have an array created with

AaDd(aFrequeMax[nRuota],{massimo, &num})

then I have a number for a sample 42 and the nWheel 1

I must found the number 42 on aFrequeMax [nWheel] and return me the second element of this array

How I must make it ?

I tried with
AEval( aData, { |a| If( (a[1] = numero ), nFrequenza:=a[2] , nil ) } )

Re: search a number of on array

Posted: Fri May 27, 2022 8:43 pm
by Antonio Linares
Dear Silvio,

Please provide a drawing or something to better understand you :-)

Re: search a number of on array

Posted: Fri May 27, 2022 9:47 pm
by Silvio.Falconi
Antonio Linares wrote:Dear Silvio,

Please provide a drawing or something to better understand you :-)


sample nWheel = 1

Image


I have to find out if my number is in the first column, if it found it, return the value for the second column

For a sample my number is 66 it must return 594

Re: search a number of on array

Posted: Sat May 28, 2022 6:59 pm
by nageswaragunupudi

Code: Select all | Expand

function ArrLookUp( aArray, nSeek )

   local nAt
   
   if ( nAt := AScan( aArray, { |a| a[ 1 ] == nSeek } ) ) > 0
      return aArray[ nAt, 2 ]
   endif
   
return nil
 

Re: search a number of on array

Posted: Sat May 28, 2022 7:30 pm
by Silvio.Falconi
thanks