mIRC Homepage
Posted By: ScottK $duplicate snippet , make for me pls - 06/01/05 10:05 AM
hie
can someone make me a simple snippet for $duplicate

example i want is like $duplicate(%a,b)

%a = text1 text2 text3
%b = %text3 %text4 %text5
%c is the duplicate values in %a & %b example
%c = %text3
%d is the return of the values from both %a & %b without duplicate values , example %text1 %text2 %text3 %text4 %text5

thx for reading and happy coding
Posted By: Sigh Re: $duplicate snippet , make for me pls - 06/01/05 10:25 AM
This is a simple example, it doesn't consider repeated tokens, just attempts to match each word from the first parameter to another in the second parameter:

Code:
alias duplicate {
  var %a = $1,%b = $2,%c,%d,%e
  while ($regsub(%b,([^ ]+),,%b)) {
    %e = $regml(1)
    if ($regsub(%a,$+((^| )\Q,$replacecs(%e,\E,\E\\E\Q),\E(?= |$)),,%a)) %c = %c %e
    else %d = %d %e
  }
  %d = %d %a

  ; Commands here with %c and %d
  return %c $cr %d
} 


$duplicate(a,b)

%c is then filled with the words common to both strings, %d would consist of those uncommon to both
Posted By: ScottK Re: $duplicate snippet , make for me pls - 06/01/05 11:13 AM
hye sigh
thx for your work
but , there is something missing there (for me)

//echo -a $duplicate(text1 text2 text3,text3 text4 text5)
will return to text3 ¤ text4 text5 text1 text2
how to make the result will be like this
text3 ¤ text4 text5 text1 text2 %text3
Posted By: ScottK Re: $duplicate snippet , make for me pls - 06/01/05 09:43 PM
nevermind , %d + %e = the result i want
thx so much sigh laugh
© mIRC Discussion Forums