0

Alright, so I know this question has been asked before, however I've not yet revived an answer that works.

So when I make variables like this

set /a HP = %END% + (%STR% * .5) * %LVL%

I get the Missing Operand Error, I've been told to remove the "%" symbols, however this not only doesn't work, but I know for a fact it's not what I'm supposed to do, without the "%" symbol the program doesn't recognize "END" as a variable.

So how do I fix it?

Jerry Stratton
  • 3,287
  • 1
  • 22
  • 30
  • 1
    `%` symbols are absolutely optional in `set /a` statements. The fact that `%END%` isn't recognized as a variable when you don't include them tells me that it isn't set. If you swear up and down that you _did_ set all three of the variables, then read this: http://stackoverflow.com/questions/9681863/windows-batch-variables-wont-set – SomethingDark Apr 26 '17 at 23:08
  • 1
    The `set /A` expression only allows _integer numbers_, so the `.5` issue the error... You may use `STR * 5 / 10` instead, but the result is integer always! – Aacini Apr 26 '17 at 23:16
  • Thank you, those both helped. –  Apr 26 '17 at 23:18
  • To add to previous hints, the new var will be `HP ` with a trailing space. The applicable [PEMDAS rules](https://en.wikipedia.org/wiki/Order_of_operations#Mnemonics) don't require parentheses. So provided the vars are set I'd use `Set /a "HP=STR * LVL / 2 + END"` –  Apr 27 '17 at 12:30
  • 1
    @LotPings: strange but true: `set /a` is immune to spaces (where a plain `set` isn't) – Stephan May 13 '17 at 09:49

0 Answers0