4

I'm using this piece of code in my script, and each time the script gets to this part (the sets) CMD gives out missing operator (operandus, etc.) error. I wasn't able to find any answer for it, even when I spent an entire hour just googling and searching. If anyone could give me a hint, I would be damn happy!

    :start
echo Good Job everyone!
set /P /a fglobal = You won: 
set /P /a r = Rery: 
set /a global = %fglobal%+%r%
set /P /a size = MaxSize: 
set /a maxsize = %size%*100
set /a mxp = %global%/100
set /a rxp = %random%/1000
set /a xp = %mxp%+%rxp%
echo.
echo SUCCESS!
echo.
echo.
echo Gained money: %global% $ / %maxsize% $
echo Gained XP: %xp%
echo.
pause
cls
Wolf
  • 43
  • 4
  • `even when I spent an entire hour just googling and searching`... Found on this site: 1hour ago [CMD file - delayed variable expansion](http://stackoverflow.com/a/19549258/463115), [Batch File Set Variable - What the heck?](http://stackoverflow.com/q/19448522/463115) – jeb Oct 23 '13 at 20:04

2 Answers2

4

don't put spaces and don't use percents.

set /p a=you won:
set /p r=Reatry:
set /a b=a+r
echo.%b%
cure
  • 2,588
  • 1
  • 17
  • 25
3

The solution is to avoid spaces.
And don't mix options, either /P or /A but not both together.

set /P fglobal= You won: 
set /P r= Rery: 
set /a global= %fglobal%+%r%
set /P size= MaxSize: 
set /a maxsize= %size%*100
set /a mxp= %global%/100
set /a rxp= %random%/1000
set /a xp= %mxp%+%rxp%
jeb
  • 78,592
  • 17
  • 171
  • 225