mIRC Home    About    Download    Register    News    Help

Print Thread
#235597 29/12/11 05:49 PM
Joined: Jan 2004
Posts: 1,361
L
Hoopy frood
OP Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,361
I'd like to create some dynamically named variables. For testing I've used %category. Using /set I am able to create the variables, but I don't want them to be global. Using the same syntax /var is not setting the variable (not even /var -g). Can anybody shine some light on accomplishing this and what's going on here?

This attempts to set the variable, and then lists all local variables (and %category even if it's global).
Code:
alias t {
  noop $regex(hello world,(hello))
  var %key = $(%category,0)
  var %value = $($regml(1),0)

  var $(%key) = $(%value,2)
  ;set -u $(%key) $(%value,2)
  
  var %i = 1
  while (%i <= $var(*,0).local) {
    $iif($var(*,%i).local || $var(*,%i) == $(%category,0),echo -a $var(*,%i) $var(*,%i).value $($var(*,%i).value,2))
    inc %i
  }
}

Joined: Jul 2006
Posts: 4,222
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,222
/var won't do anything if the first variable name doesn't start with a '%', you need to start with a % and use $+.

Code:
var %category $+ $me = 1


Last edited by Wims; 29/12/11 06:20 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard