mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jun 2003
Posts: 13
P
Pilo Offline OP
Pikka bird
OP Offline
Pikka bird
P
Joined: Jun 2003
Posts: 13
Code:
alias bug { 
  var %string = abcd efgh
  var %x = 1 | while (%x <= $len(%string)) {
    var %ascii = $asc($mid(%string,%x,1))
    if ((%ascii < 65 || %ascii > 90 && %ascii < 97 || %ascii > 122) && (%ascii != 160 && %ascii != 196 && %ascii != 214 && %ascii != 220 && %ascii != 223 && %ascii != 228 && %ascii != 246 && %ascii != 252)) {
    %words = %words $+ $chr(32) $+ $chr(%ascii) $+ $chr(32) $+ $chr(32) } 
    else { %words = %words $+ $chr(%ascii) }
  inc %x }
  var %x = 1 | while (%x <= $numtok(%words,32)) {
    echo -a %x $+ .1 word: %word
    var %word = $gettok(%words,%x,32)
    echo -a %x $+ .2 word: %word
    if ($len($remove(%word,$chr(160))) > 3) {
      var %head = $left(%word,1)
      if ($right(%word,1) == $chr(160)) { var %foot = $right(%word,2) }
      else { var %foot = $right(%word,1) }
      var %body = $mid($remove(%word,$chr(160)),2,$calc($len($remove(%word,$chr(160))) -2))
      var %oldbody = %body
      echo -a %x $+ .3 word:4 %word

      ;-> [color:red]BUG[/color] <-----------------------------------
      [color:red]unset %word[/color]
      ;-------------------------------------------
      ; [color:green]It olny works if I use 'unset %word %word'[/color]
      ;-------------------------------------------

      echo -a 3-> unset $chr(37) $+ word <-
      if (%x == 2) echo -a %x $+ .4 word:4 %word <- what's that?
      else echo -a %x $+ .4 word:4 %word
      var %y = 1 | while (%y <= $len(%body)) { %word = %word $+ $mid(%body,%y,1) $+ $chr(46) | inc %y }
      echo -a %x $+ .5 word: %word
      var %body = $left(%word,$calc($len(%word) -1))
    var %newbody = %body }
    else { echo -at %x $+ . word: ->7 $+ %word $+ <- }
    echo -a -----------------
  inc %x }
unset %word %words }


The script shows this...
Code:
1.1 word:
1.2 word: abcd
1.3 word: [color:red]abcd[/color]
[color:green]-> unset %word <-[/color]
1.4 word:
1.5 word: b.c.
-----------------
2.1 word: b.c.
2.2 word: efgh
2.3 word: [color:red]efgh[/color]
[color:green]-> unset %word <-[/color]
2.4 word: [color:red]b.c.[/color] <- what's that?
2.5 word: b.c.f.g.
-----------------

Joined: Feb 2003
Posts: 810
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
If you want to post a bug, please try to show the smallest and simplest form/script to reproduce it that you can think of..


* cold edits his posts 24/7
Joined: Jun 2003
Posts: 13
P
Pilo Offline OP
Pikka bird
OP Offline
Pikka bird
P
Joined: Jun 2003
Posts: 13
LOL ok...I'll try it...just a moment...it's tricky...

Code:
[color:red]unset %word[/color]  <- didn't work well


LOL...satisfied now...LOL smirk

Joined: Feb 2003
Posts: 810
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
Ok.. I have a solution.. here:
Code:
exit


* cold edits his posts 24/7
Joined: Feb 2003
Posts: 307
T
Fjord artisan
Offline
Fjord artisan
T
Joined: Feb 2003
Posts: 307
hello
by doing this "var %word = $gettok(%words,%x,32)"
you are creating a local var. this vars only exist in the alias here they were created, after that they are automaticly unseted. I belive you can't unset them with /unset.
to fix that problem you can make "%word = $null"
and goodbye var smile

Joined: Jun 2003
Posts: 13
P
Pilo Offline OP
Pikka bird
OP Offline
Pikka bird
P
Joined: Jun 2003
Posts: 13
Local variable???

But if I use

/unset %word %word

it works...%work is then $null

This is a really wired behavior of mIRC and I don't understand it...Who does it?


Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
local varables exist only with in the script there running in...

means you cant refrence them from anywhwre else....

Thats why there is a /SET and a /VAR command
/SET global varables
/VAR local ones

but anyway...

/testme {
var %word who what where
unset %word
echo >>> %word <<<
}

result of running /testme
>>> <<<

So i dont know what you did to your copy of mirc but it isnt running right!

Joined: Jun 2003
Posts: 242
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Jun 2003
Posts: 242
I guess I misread the bug .. is it possible that there is a global
variable named %word? And when you use /unset it checks
global variables first and if %word exists it gets unset
instead of the local named %word.

So by using /unset %word you're only unsetting the
global if it exists, but by using /unset %word %word
you would be unsetting both if both exist. Is that right?

Last edited by r0ck0; 26/09/03 03:21 PM.
Joined: Feb 2003
Posts: 810
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
Do you have any alias called 'unset'? If so, this could be the problem.


* cold edits his posts 24/7
Joined: Jun 2003
Posts: 242
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Jun 2003
Posts: 242
Code:
alias unsetvar.test {
  echo -a begin test 1
  set -s %test1 global
  var -s %test1 = local
  echo -a %test1 %test1 &lt;--
  unset -s %test1
  echo -a %test1 %test1 &lt;--
  echo -a begin test 2
  set -s %test2 global
  var -s %test2 = local
  echo -a %test2 %test2 &lt;--
  unset -s %test2 %test2
  echo -a %test2 %test2 &lt;--
}


type /unsetvar.test

Last edited by r0ck0; 26/09/03 03:34 PM.
Joined: Feb 2003
Posts: 810
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
Good guess.. it seems it really behaves like what you described..
Code:
alias whee {
  set %test global
  var %test = local
  echo -a *** %test
  unset %test
  echo -a *** %test
}

*** local
*** global

Edit: lol, posting quickly at the same time is a mess
smile

Last edited by cold; 26/09/03 03:35 PM.

* cold edits his posts 24/7
Joined: Jun 2003
Posts: 242
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Jun 2003
Posts: 242
lol yeah .. try it with the -s switch on /set & /var

Actually it seems to do it in reverse, unsetting the local first.

Plus, I noticed that the poster is using %var = blah sometimes.
Maybe that has something to do with it.
I always use either set %var blah or var %var = blah

Last edited by r0ck0; 26/09/03 03:40 PM.
Joined: Feb 2003
Posts: 810
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
Although "%var = blah" respects the variable "state" (local or global), this may confuse me a little if I used it to create one. I only use this way when I know %var was already set before in the same code..
Btw, it respects the variable state because /var has priority against /set. If you use "//var %x = 1 | set %x 2 | echo -a %x" (or "//var %x = 1 | %x = 2 | echo -a %x"), it will echo "2" but %x won't be recognized as a global variable.
But then, if you firstly set %x as a global one and then you set it again as a local one, it will be kinda "duplicated".


* cold edits his posts 24/7
Joined: Feb 2003
Posts: 810
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
Although "%var = blah" respects the variable "state" (local or global), this may confuse me a little if I use it to create one. I only use this way when I know %var was already set before in the same code..
Btw, it respects the variable state because /var has priority against /set. If you use "//var %x = 1 | set %x 2 | echo -a %x" (or "//var %x = 1 | %x = 2 | echo -a %x"), it will echo "2" but %x won't be recognized as a global variable.
But then, if you firstly set %x as a global one and then you set it again as a local one, it will be kinda "duplicated".


* cold edits his posts 24/7

Link Copied to Clipboard