mIRC Home    About    Download    Register    News    Help

Print Thread
#270342 04/06/22 07:48 PM
Joined: Aug 2015
Posts: 70
Babel fish
OP Offline
Babel fish
Joined: Aug 2015
Posts: 70
ok so i have this:

//var %a = 2 + 12 + 24 | echo -a * %a

This DOESNT work!!! But, if you specify 2 numbers it does...

Am I doing something wrong?


mIRC Scripts IRC Network: irc://irc.mircscripts.info/chat
Joined: Jan 2012
Posts: 301
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 301
For mathematical calculations, you must use the identifier $calc()
Code
//var %a = $calc(2 + 12 + 24) | echo -a * %a


🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
https://en.wikichip.org/wiki/mirc/variables#Math_Operations
The math works only if there are exactly 2 terms and 1 math operator, so if you have 3 numbers to add together you need to put them inside $calc( )
If you want it to put the literal string without doing the math, you need the -p switch
If you are adding 2 variables together and need to defend against one of them being blank, you'd need to do like

var %a 0 $+ %num1 + 0 $+ %num2
In addition to the + operator, this also works with - * / % ^


Link Copied to Clipboard