Solved How do I fix my variables in Batch file?

May 20, 2016 at 11:06:21
Specs: Windows 7
I have a problem with my Batch file variables. I'm making a Cookie Clicker clone and I'm trying to make it so it tests if you have enough 'cookies' to purchase a 'Grandma'
I have tried this command but it does not work :/

if %cookies%>50 set /a %Grandma%=%Grandma%+1

message edited by VexSiege

See More: How do I fix my variables in Batch file?

Report •

May 20, 2016 at 18:23:17
You will need to post more of your code than just one line. And/or better yet, debug your own code using echos and pauses. When you narrow it down, insert "set echo on". That's what I always do when I get unexpected behavior from batch. There's a million reasons your code could be failing. Spare me from guessing at the cause, esp sans context.

Report •

May 20, 2016 at 19:42:44
✔ Best Answer
Well, most obvious error is using the greater than sign, instead of GTR. Also, expanding environment variables incorrectly. I suggest you open the Command Prompt, and type:
IF /?
SET /?
Read everything before moving on.

if %cookies% gtr 50 set /a Grandma+=1

How To Ask Questions The Smart Way

Report •

May 21, 2016 at 13:10:20
Thank you Razor2.3 :D

Report •
Related Solutions

Ask Question