mIRC Home    About    Download    Register    News    Help

Print Thread
Automatic calculation/evaluation in tokens. #266841 20/02/20 01:00 AM
Joined: Dec 2003
Posts: 48
N
NrWarren Offline OP
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Dec 2003
Posts: 48
Not sure if you know about this, or whether you consider it a bug.

When using /var to assign a value, the evaluation of 1-1 does not take place, but when spaced out, 1 - 1 it seems to automatically perform the calculation.

I was creating a calculator for mIRC, so that all of my calculations would be recorded and could be referenced later, and i encountered this little bug. I worked around it.

Last edited by Khaled; 20/02/20 12:33 PM.
Re: Automatic calculation/evaluation in tokens. [Re: NrWarren] #266843 20/02/20 12:24 PM
Joined: Dec 2002
Posts: 4,841
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,841
Thanks for your bug report. That is indeed how variable assignment has always worked.

Re: Automatic calculation/evaluation in tokens. [Re: NrWarren] #266846 20/02/20 12:33 PM
Joined: Aug 2003
Posts: 284
P
Protopia Offline
Fjord artisan
Offline
Fjord artisan
P
Joined: Aug 2003
Posts: 284
Check out the $calc identifier.

Re: Automatic calculation/evaluation in tokens. [Re: NrWarren] #266849 20/02/20 04:58 PM
Joined: Apr 2004
Posts: 853
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 853
For what it is worth: you can prevent this from happening by using either the -n or the (as yet undocumented) -p switch to /var. For example, the following code excerpt:

Code
var -n %test = 1 - 1
echo -ag %test

..will echo "1 - 1". The exact same applies in cases where the input is not literal (e.g. when assigning one variable to another, with such a "formula" as contents).


Saturn, QuakeNet staff