mIRC Homepage
Posted By: MattiSony A bug with varibles and identifiers - 22/02/16 08:36 AM
Hey, just found this bug, I don't know how to explain it but if you try this script you'll see that first echo will echo %var.#channel while the other echo that's on a timer will echo Hello

Code:
alias abc {
  set %var. $+ $chan Hello
  echo # 1 $+(%,var.,$chan)
  timer 1 1 echo # 2 $+(%,var.,$chan)
}


Edit: This also happens with /msg BTW.
timers evaluate the command when they expire; resulting in double evaluation; this is intended.

If you want the literal text "%var.#channel" to echo, you'll need to escape it in the /timer command.

Code:
alias safe {
  return $!decode( $+ $encode($1-,m) $+ ,m)
}

alias abc {
  .timer 1 1 echo # 2 $safe( $+(%,var.,$chan) )
}
Posted By: MattiSony Re: A bug with varibles and identifiers - 22/02/16 11:43 AM
Actually I want what's stored in the variable %var.#channel
I just put a small timer on the msg to bypass it for now.
Posted By: westor Re: A bug with varibles and identifiers - 22/02/16 01:54 PM
Btw, the $safe identifier will be into the next version, you will not need this extra alias, mIRC will have $safe by default.
To evaluate, you can use the $eval identifer:
Code:
alias abcd {
  set $+(%,var.,name) example

  ;; evaluates the literal "%" + "var." + "name"
  echo -a This isn't evaluated: $+(%, var., name)

  ;; evaluates the literal text "%" + "var." + "name"
  ;; then evaluates the resulting text again (%var.name)
  echo -a This is evaluated: $eval( $+(%, var., name) , 2)
}


--

As westor mentioned, in the upcoming version(not released yet) the $safe() alias from my post will be a native identifer; thus the custom alias will no longer be needed
© mIRC Discussion Forums