mIRC Home    About    Download    Register    News    Help

Print Thread
#203207 09/08/08 03:43 AM
Joined: Aug 2006
Posts: 182
T
Thrull Offline OP
Vogon poet
OP Offline
Vogon poet
T
Joined: Aug 2006
Posts: 182
I'm not sure if this is intended behavior or not, so someone correct me if it is please. I'm using Mirc 6.34 on Windows XP SP 2.

Code:
var %i = 1,100
echo -a $Rand($eval(%i,1))


I get the following error: * Too few parameters: $rand

However, the code below works as expected.

Code:
var %i = 1,100
echo -a $Rand( [ %i ] )


For some reason $eval isn't properly evaluating %i.

Thanks for your time.

Last edited by Thrull; 09/08/08 03:46 AM.
Joined: Feb 2004
Posts: 206
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Feb 2004
Posts: 206
If I were to guess (and I don't have mIRC up at the moment to check), I would say that the "," in %i is causing difficulties via $eval.

$eval($i,1) --> $eval(1,100,1) which would evaluate to a scalar (possibly "1", but I would have to test this in mIRC).

Thus, only one parameter is being passed to $rand when you use $eval.

When you are using [ %i ], "1,100" is also being evaluated, but there are no expectations of "," notation - so there is no confusion over the placement of the "," and thus no ambiguity on the result.

As I said, these are my first thoughts and I have not tested this.

Cheers,

DK

Joined: Jan 2003
Posts: 2,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
It's not a bug. Evaluation brackets are very different from $eval(), in that only the former control the order of evaluation ($eval merely controls the depth). Anything inside [] is pre-evaluated, ie is evaluated before the normal evaluation of identifiers/variables. This isn't the case with $eval.

$rand($eval(%i,1)) means "call $rand with one parameter that is evaluated once".

$rand( [ %i ] ) (roughly) means "evaluate %i before even determining the number of parameters in $rand"

Joined: Aug 2006
Posts: 182
T
Thrull Offline OP
Vogon poet
OP Offline
Vogon poet
T
Joined: Aug 2006
Posts: 182
Ahh, I see. I had assumed that using the brackets and $eval were the same thing. Apparently, they are not.

Thanks for the help.


Link Copied to Clipboard