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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
silent
Posts: 44
Joined: 28 Oct 2011 14:40

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

#1 Post by silent » 08 Jan 2012 12:21

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.

Squashman
Expert
Posts: 4176
Joined: 23 Dec 2011 13:59

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

#2 Post by Squashman » 08 Jan 2012 13:03

you know you can use the full path to the filename.

silent
Posts: 44
Joined: 28 Oct 2011 14:40

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

#3 Post by silent » 08 Jan 2012 13:16

Yeah,but i dont know where user of the game will put the file.
Fixed,used

Code: Select all

popd

Squashman
Expert
Posts: 4176
Joined: 23 Dec 2011 13:59

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

#4 Post by Squashman » 08 Jan 2012 13:46

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

silent
Posts: 44
Joined: 28 Oct 2011 14:40

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

#5 Post by silent » 09 Jan 2012 09:29

what do you mean by "..burn you " ? :D

Post Reply