Page 1 of 1

ASCAN on 2 colums

Posted: Mon Dec 09, 2019 7:38 pm
by Marc Vanzegbroeck
Hi,

Is it possible to do a array-search where for example the first column = 'TEST' and the seconds column = 'TEST1'?
I also want to search on the upper-case, but the problem is that sometimes the value = nil, so I get an error with upper.
The array is comming from an excel-file read with

Code: Select all

  oRange   := oSheet:UsedRange
arr = ArrTranspose( oRange:Value) 

Re: ASCAN on 2 colums

Posted: Mon Dec 09, 2019 8:47 pm
by Jimmy
hi,
Marc Vanzegbroeck wrote: Is it possible to do a array-search where for example the first column = 'TEST' and the seconds column = 'TEST1'?
I also want to search on the upper-case, but the problem is that sometimes the value = nil, so I get an error with upper.
The array is comming from an excel-file read with

Code: Select all

  oRange   := oSheet:UsedRange
arr = ArrTranspose( oRange:Value) 
just a Idea to use a function, not tested

Code: Select all

   cSeek := "ABC"
   nElement := AScan( aArray, ;  
                      {|a,i| Test(a,i,cSeek) },;
                      nStart ) 

FUNCTION Test(a,i,cSeek)
LOCAL nPosi := 0
   IF EMPTY(a[1])
      RETURN -1
   ENDIF
   IF EMPTY(a[2])
      RETURN -1
   ENDIF
   // compare as you need
   IF cSeek $ a[1] .OR. cSeek $ a[2]
      nPosi := i
   ENDIF
RETURN nPosi
 

Re: ASCAN on 2 colums

Posted: Tue Dec 10, 2019 3:34 am
by nageswaragunupudi

Code: Select all

nAt := AScan( arr, { |a| Upper( IfNil( a[ 1 ], "" ) ) = "TEST" .and. ;
                         Upper( IfNil( a[ 2 ], "" ) ) = "TEST1" } )