mIRC Home    About    Download    Register    News    Help

Print Thread
Trying to /unset %variable but can't. #180777 13/07/07 07:00 PM
Joined: Jan 2004
Posts: 509
L
LostShadow Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
The variable is %bnick*

I have %bnickword %bnickword2 etc.

Code:
  var %i = 1
  while (%i < $var(%bnick*,0)) {
    inc %i
    if ($identifier == $var(%bnick*,%i).value) {
      if statement { 
          do stuff | /unset $var(%bnick*,%i)
        }
      }
      /unset $var(%bnick*,%i)
    }
  }


I just added all the /unset $var(%bnick*,%i) as I can, but I believe only 1 is enough..

After checking for the value of te %variable, I then want to /unset after the end of the while loop. Also unsetted it after using it. But no, the variable still exists..

I didn't /unset the $var().value of the variable because I want the variable completely gone.

Thanks.

-Neal.

Re: Trying to /unset %variable but can't. [Re: LostShadow] #180781 13/07/07 07:17 PM
Joined: Dec 2002
Posts: 2,013
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,013
No need for a loop when you can just do /unset %bnick*
If you want to use the loop, don't inc %i, just keep unsetting $var(%bnick*,1) and it will keep unsetting the first matching variable until no more are found.

Code:
alias vartest {
  var -s %i = 1
  while (%i < 10) {
    set -s $+(%,test.,%i) $true
    inc %i
  }
  while ($var(%test.*,1)) unset -s $v1
}

Re: Trying to /unset %variable but can't. [Re: RoCk] #180813 13/07/07 11:19 PM
Joined: Jan 2004
Posts: 509
L
LostShadow Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Well, that script was an unban event.

Everytime a person gets banned, a variable starts as

%bnickNick $banmask

The $identifier was $banmask. It while loops $var(%bnick*,0) until the variable finds the matching bansmask.

Then, once the ban is removed..

I want to unset the variable %bnicknick but it still stays..

I've tried this now..

Modified script for paste.

Code:
  var %i = 1
  while (%i < $var(%bnick*,0)) {
    inc %i
    if ($banmask == $var(%bnick*,%i).value) {
      if ($remove($var(%bnick*,%i),$chr(37),bnick) !ison $chan) { 
        if ($comchan($remove($var(%bnick*,%i),$chr(37),bnick),1)) { 
           /msg blah blah [Script] $remove($var(%bnick*,%i),$chr(37),bnick) you have been unbanned in $chan ( $+ $nick sets mode: -b $banmask $+ ) | /unset $var(%bnick*,%i)
        }
        if (!$comchan($remove($var(%bnick*,%i),$chr(37),bnick),1),44) {
          /notice $remove($var(%bnick*,%i),$chr(37),bnick) [Script] You have been unbanned in $chan ( $+ $nick sets mode: -b $banmask $+ ) | /unset $var(%bnick*,%i)
        }
        /unset $var(%bnick*,%i)
      }
      /unset $var(%bnick*,%i)
    }
    /unset $var(%bnick*,%i)
  }


Hopefully the %bnickNick variables will be unset...

I don't want to /unset $var(%bnick*,0) but I did when it reached over 600.

Re: Trying to /unset %variable but can't. [Re: LostShadow] #180824 14/07/07 08:24 AM
Joined: Feb 2006
Posts: 546
J
jaytea Offline
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
try this, one possible fix:

Code:
 unset $var(%bnick*,$(%i))



"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Re: Trying to /unset %variable but can't. [Re: jaytea] #180827 14/07/07 09:46 AM
Joined: Jan 2004
Posts: 509
L
LostShadow Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
O thanka jaytea <3 baby.

Re: Trying to /unset %variable but can't. [Re: LostShadow] #180830 14/07/07 01:02 PM
Joined: Dec 2002
Posts: 2,013
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,013
Why don't you paste the entire event or alias of which this is a part of?