#73398 - 2003-02-25 08:52 PM
Re: RE: arraycomp () UDF by Darren
|
Darren_W
Hey THIS is FUN
   
Registered: 2001-10-10
Posts: 208
Loc: Bristol, England
|
Ok...
Tested the last two and they did not work correctly,
Will stick to :
code:
function arraycomp($1, $2, optional $m) dim $ for each $n in $2 if (ascan($1,$n)>-1 and $m) or (ascan($1,$n)=-1 and 0=$m) $=$+chr(1)+$n endif next $arraycomp=split(substr($,2),chr(1)) endfunction
Which works great...
Thanks for your work, lets hope it will come in useful.
_________________________
I want to share something with you - the three sentences that will get you through life. Number 1, 'cover for me.' Number 2, 'oh, good idea, boss.' Number 3, 'it was like that when I got here'.
|
Top
|
|
|
|
#73401 - 2003-02-25 10:19 PM
Re: RE: arraycomp () UDF by Darren
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
Top
|
|
|
|
#73402 - 2003-02-25 11:21 PM
Re: RE: arraycomp () UDF by Darren
|
Darren_W
Hey THIS is FUN
   
Registered: 2001-10-10
Posts: 208
Loc: Bristol, England
|
Example used:
code:
$arr1 = a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z $arr2 = 1,2,3,4,f,g,a,34,42,23,c,z,o,r
"results for arraycomp(); elements that don't match:" ? ? for each $e in arraycomp($arr1, $arr2) ":" $e ? next ? "results for arraycomp(); matching elements:" ? ? for each $e in arraycomp($arr1, $arr2, 1) ":" $e ? next
get $
Result using suggested code:
code:
results for arraycomp(); elements that don't match:
:1 :2 :3 :4 :f :g :34 :42 :23 :c :z :o :r
results for arraycomp(); matching elements:
:f :g :a :c :z :o :r
Using Present:
code:
results for arraycomp(); elements that don't match:
:1 :2 :3 :4 :34 :42 :23
results for arraycomp(); matching elements:
:f :g :a :c :z :o :r
I've tested this a few times and this is the results I get? [ 25. February 2003, 23:22: Message edited by: Darren ]
_________________________
I want to share something with you - the three sentences that will get you through life. Number 1, 'cover for me.' Number 2, 'oh, good idea, boss.' Number 3, 'it was like that when I got here'.
|
Top
|
|
|
|
#73408 - 2003-02-26 11:28 AM
Re: RE: arraycomp () UDF by Darren
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
think we have a winner :
break on
$arr1 = a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z $arr2 = 1,2,3,4,f,g,a,34,42,23,c,z,o,r
"results for arraycomp(); elements that doesn't match:" ? "----------"? for each $e in arraycomp($arr1, $arr2) $e ? next "----------" ?
? "results for arraycomp(); matching elements:" ? "----------" ? for each $e in arraycomp($arr1, $arr2, 1) $e ? next "----------"?
get $
function arraycomp($1, $2, optional $m) dim $ for each $n in $2 if (ascan($1,$n)>-1 and $m) or ascan($1,$n)+$m<0 $=$+chr(1)+$n endif next $arraycomp = split(substr($,2),chr(1)) endfunction
_________________________
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 2366 anonymous users online.
|
|
|