mIRC Home    About    Download    Register    News    Help

Print Thread
#197907 16/04/08 01:04 PM
Joined: Feb 2006
Posts: 546
J
jaytea Offline OP
Fjord artisan
OP Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
a lot of us have stumbled across problems with $eval() in the past, things like:

Code:
//var -s %a = ( | echo -a $eval(%a,2)


or:

Code:
//var -s %a = ,, | echo -a $eval(%a,2)


apparently the result of it using the auxiliary $evalnext() function at a lower level. one particular example i ran into today was:

Code:
//var -s %a = a, b, c | echo -a $eval(%a,2)


versus:

Code:
//var -s %a = a, b, cd | echo -a $eval(%a,2)


which is just plain strange :P couldn't $eval() be re-written slightly to take care of these problems, ie. have the string evaluated in the same way as code is evaluated normally, just repeated however many times?


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
jaytea #197911 16/04/08 03:45 PM
Joined: Jul 2006
Posts: 4,222
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,222
and what about $(},2) and such ?


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #197930 16/04/08 11:00 PM
Joined: Feb 2006
Posts: 546
J
jaytea Offline OP
Fjord artisan
OP Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
i suppose that's worth mentioning too, but not in that way (although that way is certainly unexpected behavior that might be worth fixing). here's where i'm not sure what we should expect:

Code:
//var -s %a = bla bla line of code $chr(123) bla | echo -a $eval(%a,2)


right now that returns the expected result, although the way i first thought the problem could be solved involved evaluating the line of code as if it was on a line of the scripts editor. but then it would be subject to the treatment lines like that usually receive, and the { in the line of code above would be treated as mirc syntax rather than plaintext

btw, although the above example works, you'll find a similar problem as with the comma if the last word is only 1 character:

Code:
//var -s %a = bla bla line of code $chr(123) b | echo -a $eval(%a,2)


if you experiment with that a bit you'll come across various other related oddities. $eval() has other quirks too, such as when you specify more than 2 parameters, but that's just a result of abusing $eval() and not really worth bringing up :P

the cases with (,){} are valid though and i really hope they're fixed. oh and surprisingly | doesn't seem to have any problems that i can find.. i would've thought it was in the same class as {} as far as general syntax goes


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde

Link Copied to Clipboard