Solved Why do I keep getting Missing Operand?

October 25, 2014 at 09:50:07
Specs: Windows 8
I am trying to create a batch version of cookie clicker, I want this game to be able to save information by creating a text file and then reading that text file when the program opens up again. but it keeps saying missing operand.

P.s: I know this code is most likely massively flawed, so yeah.. don't judge too hard...

@echo off
title Cookie Clicker!
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Welcome To Cookie Clicker!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo 1) Start
echo 2) Info
echo 3) Cridits
set /P Select= Please Choose One Of The Options:

if %Select%==1 goto Game
if %Select%==2 goto Info

:Game
cls
cd C:\Users\Games\Desktop\Game_Info
set /a Cookie_Count=<Cookie_Clicker.txt
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Just Press Any Key To Start
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo.
echo You Have Baked %Cookie_Count% Cookies's!
echo.
pause
set /a Cookie_Count=%Cookie_Count%+1
del Cookie_Clicker.txt
@echo %Cookie_Count% >> Cookie_Clicker.txt
goto Game

:Store


See More: Why do I keep getting Missing Operand?

Report •

#1
October 25, 2014 at 17:47:10
http://en.wikipedia.org/wiki/Operand

I dont know DOS but I believe this: "set /a Cookie_Count=%Cookie_Count%+1" line is giving the error. Take it out and see if it functions without the error. If so then you probably aren't using the "set /a" command correctly with the "+1"

Or better yet, "set /a Cookie_Count=<Cookie_Clicker.txt" looks to be assigning "Cookie_Count" as a string type as opposed to an integer or other numerical type. If this is true then that means either there are not JUST numbers (spaces, letters, ENTERS, symbols) in your text file and since it doesn't make any sense to do (for example) "56 " then "+1" (notice the SPACE at the end of 56 converting it to a string) you'll get an error saying "what the hell is the other thing that we're doing with the +1 ?!?"


Report •

#2
October 26, 2014 at 12:01:31
✔ Best Answer
Yeah, FBI was close to the mark. This line:
set /a Cookie_Count=<Cookie_Clicker.txt

should be:
set /p Cookie_Count=<Cookie_Clicker.txt

The other "set /a" is ok, it should work.


Report •
Related Solutions


Ask Question