mIRC Home    About    Download    Register    News    Help

Print Thread
Removing variables. #180435 09/07/07 07:07 PM
Joined: Jan 2004
Posts: 509
L
LostShadow Offline OP
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.

Re: Removing variables. [Re: LostShadow] #180437 09/07/07 07:16 PM
Joined: Dec 2002
Posts: 2,013
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,013
$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

Re: Removing variables. [Re: LostShadow] #180438 09/07/07 07:24 PM
Joined: Dec 2002
Posts: 2,013
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,013
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

Re: Removing variables. [Re: RoCk] #180439 09/07/07 07:46 PM
Joined: Jan 2004
Posts: 509
L
LostShadow Offline OP
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 ..

Re: Removing variables. [Re: LostShadow] #180440 09/07/07 07:53 PM
Joined: Dec 2002
Posts: 2,013
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,013
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

Re: Removing variables. [Re: RoCk] #180443 09/07/07 08:58 PM
Joined: Jan 2004
Posts: 509
L
LostShadow Offline OP
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.

Re: Removing variables. [Re: LostShadow] #180573 11/07/07 03:53 PM
Joined: Jan 2004
Posts: 509
L
LostShadow Offline OP
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?

Re: Removing variables. [Re: LostShadow] #180574 11/07/07 04:11 PM
Joined: Dec 2002
Posts: 2,013
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,013
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

Re: Removing variables. [Re: LostShadow] #180578 11/07/07 05:01 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
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

Re: Removing variables. [Re: Horstl] #180581 11/07/07 05:45 PM
Joined: Dec 2002
Posts: 2,013
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,013
//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

Re: Removing variables. [Re: RoCk] #180583 11/07/07 06:17 PM
Joined: Jan 2004
Posts: 509
L
LostShadow Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Oh wow, thank you guys. Didn't thought about [ ].

Re: Removing variables. [Re: RoCk] #180587 11/07/07 06:41 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
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
Re: Removing variables. [Re: qwerty] #180595 11/07/07 09:00 PM
Joined: Dec 2002
Posts: 2,013
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,013
Very interesting reading, thanks.