mIRC Home    About    Download    Register    News    Help

Print Thread
#180435 09/07/07 07:07 PM
Joined: Jan 2004
Posts: 509
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Say I have 2 variables, %LocalNicks and %GlobalNicks, and the are words separated by commas.

%GlobalNicks will have everything %LocalNicks has and more.

How do I remove everything in %LocalNicks from %GlobalNicks?

I've been suggested $deltok() and $remtok().

Well, I tried $remove().

$remove(%GlobalNicks,%LocalNicks) doesn't remove %LocalNicks.

My current attempted and failed code is:

$remove( $mid(%globalunbannick,3) , $($+($mid(%,localunbannick,3))) )

I've also tried $eval(<thing>,2).

Thanks.

-Neal.

Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031
$remtok

Code:
alias remnicks {
  var %i = 1
  while ($gettok(%LocalNicks,%i,44) != $null) {
    var %t = $v1
    if ($istok(%GlobalNicks,%t,44)) {
      set %GlobalNicks $remtok(%GlobalNicks,%t,1,44)
      inc %i
    }
  }
}


/set -s %GlobalNicks nick1,nick2,nick3,nick4,nick5,nick6,nick7,nick8,nick9,nick10
/set -s %LocalNicks nick1,nick2,nick4,nick5,nick7
/remnicks
//echo -a %GlobalNicks

Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031
Actually you don't even need if ($istok

Code:
alias remnicks {
  var %i = 1
  while ($gettok(%LocalNicks,%i,44) != $null) {
    set %GlobalNicks $remtok(%GlobalNicks,$v1,1,44)
    inc %i
  }
}


/set -s %GlobalNicks nick1,nick2,nick3,nick4,nick5,nick6,nick7,nick8,nick9,nick10
/set -s %LocalNicks nick1,nick2,nick4,nick5,nick7
/remnicks
//echo -a %GlobalNicks

Joined: Jan 2004
Posts: 509
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Code:
  var %i = 1
  while ($gettok(%unbannick,%i,44) != $null) {
    set %otherunban $remtok(%globalunbannick,$v1,1,44)
    inc %i
  }
  /echo $chan %unbannick
  /echo $chan %globalunbannick
  /echo $chan %otherunban


%globalunbannick is still the same as %otherunban ..

Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031
It's remaining the same because you're not modifying it..

Code:
  var %i = 1
  while ($gettok(%unbannick,%i,44) != $null) {
    set %globalunbannick $remtok(%globalunbannick,$v1,1,44)
    inc %i
  }
  /echo $chan %unbannick
  /echo $chan %globalunbannick

Joined: Jan 2004
Posts: 509
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Oh, I didn't want to change %globalunbannick. I wanted to $remove(%globalunbannick,%unbannick), so setting another variable as that is fine.

Joined: Jan 2004
Posts: 509
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Well, this works.

[July 11 2007 Wednesday 02:49:18 AM] <Neal`> //var %a = a b c d | var %b = a b c | echo -a $remove(%a,%b)

d

[July 11 2007 Wednesday 02:49:22 AM] <Neal`> D.
[July 11 2007 Wednesday 02:49:28 AM] <Neal`> That works.
[July 11 2007 Wednesday 02:49:49 AM] <myndzi> that's because the string "a b c" is in the string "a b c d"
[July 11 2007 Wednesday 02:50:00 AM] <myndzi> try //var %a = d c b a | var %b = a b c | echo -a $remove(%a, %b)

d c b a

So now $remove() won't work because of the order for my particular case. I need to simple bring out the evaluation of the %variables and treat them as plain text in the $remove(), no?

Anyone got any clues on what to do?

Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031
I'll be damned if I can get it to work. I tried it with a custom identifier and it didn't work.

alias testing return a,b,c
//var -s %a = a b c d | echo -a $remove(%a,$testing)

I also tried it using /tokenize and still nothing.
//var -s %a = a b c d | tokenize 32 a,b,c | echo -a $remove(%a,$1)

And with the varables, still nothing.
//var -s %a = d c b a | var -s %b = a,b,c | echo -a $remove(%a,%b)

I would think all three of these methods should work, but they don't. confused

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Code:
alias return1 { return a,b,c }
alias test1 {
  var %a = a b c d 
  echo -a $remove(%a, [ $return1 ] )
}

alias test2 {
var -s %a = a b c d, %b = b,d 
echo -a $remove(%a, [ %b ] )
}


that works...
/help [ ] evaluation brackets

Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031
//var -s %a = d c b a | var -s %b = a,b,c | echo -a $remove(%a, [ %b ] )

Yeah that worked, although I tried using $eval. It's been so long since I've needed to use evaluation brackets, that I didn't even think of trying them. It seems to me that if evaluation brackets will work, then $eval should too. Well done. smile

Joined: Jan 2004
Posts: 509
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Oh wow, thank you guys. Didn't thought about [ ].

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Brackets are, in an important way, different from $eval. Bracket functionality is explained here in detail.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031
Very interesting reading, thanks.


Link Copied to Clipboard