ASCAN on 2 colums

Post Reply
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

ASCAN on 2 colums

Post 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) 
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
User avatar
Jimmy
Posts: 165
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: ASCAN on 2 colums

Post 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
 
greeting,
Jimmy
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: ASCAN on 2 colums

Post by nageswaragunupudi »

Code: Select all

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

G. N. Rao.
Hyderabad, India
Post Reply