Compare two arrays

Compare two arrays

Postby Silvio.Falconi » Wed Jun 05, 2019 11:59 am

can you compare two arrays to see if there are equal elements?

for example:

in an array I have

"AAAAA","BBBBB","CCCCC"
"AAAAA","BBBBB","CCCCC"
"BBBBB","BBBBB","BBBBBB"

on another I have

"AAAAA","BBBBB","CCCCC"
"AAAAA","BBBBB","CCCCC"
"AAAAA","BBBBB","CCCCC"


is there a function that lets you know that the line "AAAAA", "BBBBB", "CCCCC" is present in the other array?


I need this operation because at the time the beach structure is built, the program automatically recognizes the areas where the umbrellas are located and creates a base rate: it could happen that the operator has already entered some tariffs for the same sector or has entered some tariffs for a sector that in the modification structure does not exist or there is no given element

the user could cancel all the tariffs and insert new ones from scratch or the procedure could make a check and see if there are records that have some equal fields
IDLISTINO | IDELEMENTO | FIELD | DAYS

for a sample

Image

on up there is a new array calculated
down there is the array with oldest tariffs

the check must be made by idlistino,idelemento, giorni,idsettore

How I can resolve it ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
Silvio.Falconi
 
Posts: 7055
Joined: Thu Oct 18, 2012 7:17 pm

Re: Compare two arrays

Postby ukoenig » Wed Jun 05, 2019 12:15 pm

Silvio,

the new release FWH 19.05 offers new functions

Additional features:

cSearch can be a string or array of strings. In case of array, the earliest occurance
is reported.

If lWholeWord is .t., only whole words are matched.
Eg: FW_ATI( "EAR", "Years Hear Ear", nil, nil, .T. ) --> 12, but not 2.

If lSkipQuotes is .t., the search skips any text inside quotes, "...", '...' or [...]
Eg: FW_ATI( "NEAR", 'He said "it is near" but it is not near', nil, nil, nil, .t. )
--> 36 but not 16

If @cFound is specified as 7th parameter by reference, the exact match found in the
string is returned. Eg: In the above case it returns "near".

If cReplace is specified as 8th parameter and cString is by reference, cFound is
replaced by cReplace.

It the 9th parameter lAll is set to .T., all matches are returned as Array. In case of
cReplace, all occurances are replaced by cReplace.

- New function FW_STRICMP(): Compares the two strings ignoring the case.
Respect SET EXACT off/on setting, subject to override

Usage1: FW_StrICmp( cStr1, cStr2, [lExact] ) --> -1,0,+1 for less than,
equal or greater than. 3rd parameter, if specified, overrides SET EXACT
setting

Usage2: FW_StrICmp( cStr1, cCompOperator, cStr2, [lExact] ) --> .f. / .t.
Eg: FW_StrICmp( c1, ">=", c2, [nil,.t.,.f.] ) --> .t./.f.
Operator "==" forces exact comparison. In other cases 4th paramter specifies
if comparision is exact and if omitted, default setting is used.


regards
Uwe :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Compare two arrays

Postby nageswaragunupudi » Wed Jun 05, 2019 2:39 pm

Code: Select all  Expand view
function SearchArray( aSearch, aArray )

   local n

   for n := 1 to Len ( aArray )
      if aSearch[ 1 ] == aArray[ n, 1 ] .and. ;
         aSearch[ 2 ] == aArray[ n, 2 ] .and. ;
         aSearch[ 3 ] == aArray[ n, 3 ]

         return n
      endif
   next

return 0
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Compare two arrays

Postby Silvio.Falconi » Thu Jun 06, 2019 6:46 am

nice
make some test
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
Silvio.Falconi
 
Posts: 7055
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Marc Venken, Silvio.Falconi and 123 guests