Page 1 of 1

2 pushd one for temp and one for location where file is

Posted: 08 Jan 2012 12:21
by silent
Im continuing to make my batch game,i get how to save level and money,but i cant get to save nickname,well i know how,but i needed to use

Code: Select all

pushd "%temp%"

in file ,so it will save file with level and money to temp,here no one will search.But when i try to save nickname with

Code: Select all

echo %nickname% 1>nick.db

it saves to temp,and when i try to use

Code: Select all

set /p var= <nick.db
echo welcome back %var%!


it says it could not find file nick.db,and i need to know how to make it save to same location as bat file.

Re: 2 pushd one for temp and one for location where file is

Posted: 08 Jan 2012 13:03
by Squashman
you know you can use the full path to the filename.

Re: 2 pushd one for temp and one for location where file is

Posted: 08 Jan 2012 13:16
by silent
Yeah,but i dont know where user of the game will put the file.
Fixed,used

Code: Select all

popd

Re: 2 pushd one for temp and one for location where file is

Posted: 08 Jan 2012 13:46
by Squashman
What do you mean you won't know. You just echoed the output to whatever directory is assigned to the temp variable because you did the pushd first so use the temp variable with the set statement.
Set /p nick=<%temp%\nick.db

Word of advice to you. Make sure you close up the spaces when you are using redirects to a file. I see you do that a lot in most of your code posts. It is going to burn you one of these days.

Echo %var% >myfile.txt
Is not the same as
Echo %var%>myfile.txt

Re: 2 pushd one for temp and one for location where file is

Posted: 09 Jan 2012 09:29
by silent
what do you mean by "..burn you " ? :D