mIRC Home    About    Download    Register    News    Help

Print Thread
#231933 10/05/11 06:37 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Hello,

Recently in another post we talked briefly about dynamic variables. Riamus suggested checking for a dynamic variable using $eval vs. [ ].

$($+(%,reason.,$2),2) is the example he gave and would find %reason.whatever2is and return the value.

I have tried to use this sort of method before, but the problem I had was setting the variables in the first place. They didn't always work out right.

So I was wondering, using this method to check for a variable, how would you set it? Thanks.

$($+(%,reason.,$2),2)

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Code:
//var -s %reason. $+ $2
//set -s %reason. $+ $2

Evaluation brackets control the order of evaluation, you don't need them to set a dynamic variable nor your need $eval because
%variable command have a special evaluation routine, %reason. isn't evaluated here

Last edited by Wims; 10/05/11 07:08 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yep, like Wims said (and I think it was mentioned in that post you're referring to), just use $+ when setting and use either $eval or []'s when reading the variable, whichever is your preference.

Think about setting it like this...

You know that $eval and []'s evaluate the variable, so that if %test.Riamus = 1 (Riamus being supplied by $nick), then you evaluate it and get 1. That's what you want when you're reading the variable. However, if you set it that way, you are basically doing this...

//set $($+(%,test.,$nick)) Some Value

and that becomes

//set 1 Some Value

See, you don't want to have the variable's data become the variable name.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard