0

I'm coding an RPG and and when I set a variable that I want to be a name,

when I "echo My name is %name%", which I stored the name in,

it shows as "My name is 0".

However, when I code a smaller program, it works. Can someone please help me?

2
  • You clearly set name to 0 at some point. If the variable was unset, you would see the message My name is %name%. Commented May 30, 2015 at 21:56
  • Put a setlocal command at beginning of all your programs! Commented May 30, 2015 at 22:25

1 Answer 1

2

(For some funny reason i can't comment)

You may have used the /a parameter while setting the variable previously. That would mean that the variable would be treated as if it was holding a number. This set /a name=Name should be set name=Name.

Also, as dbenham mentioned, set /a name=Name evaluates to 0, explaining your problem.

Sign up to request clarification or add additional context in comments.

1 Comment

No need to comment, this is a good answer. Also, set /a name=SomeName evaluates to 0 if there does not exist a variable named SomeName. This would explain the source of the 0 value.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.