search a number of on array

Post Reply
User avatar
Silvio.Falconi
Posts: 7164
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 2 times

search a number of on array

Post 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 ) } )
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Antonio Linares
Site Admin
Posts: 42597
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 40 times
Been thanked: 86 times
Contact:

Re: search a number of on array

Post by Antonio Linares »

Dear Silvio,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Silvio.Falconi
Posts: 7164
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 2 times

Re: search a number of on array

Post 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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
nageswaragunupudi
Posts: 10729
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: search a number of on array

Post 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
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
Silvio.Falconi
Posts: 7164
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 2 times

Re: search a number of on array

Post by Silvio.Falconi »

thanks
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Post Reply