Page 1 of 1

batch file wont write %Q% to a text file

Posted: 26 Sep 2011 12:22
by BatMaster
the batch file wont write the variable Q to a text file

Code: Select all

@echo off
:start
set "Q"="1"
:start2
set "Q"="Q + 1"
>>text.txt echo set /p line%Q%=
goto start2
pause

please help

Re: batch file wont write %Q% to a text file

Posted: 26 Sep 2011 13:14
by Exouxas
When using math with the 'set' command, you do 'set /a'
and remove all the " thingys
Also, why do you have the :start when you dont use it?

Re: batch file wont write %Q% to a text file

Posted: 26 Sep 2011 15:50
by Ranguna173
BatMaster wrote:

Code: Select all

>>text.txt echo set /p line%Q%=


That is a weird code...
For you case, here is the one I use:

%Q%>>text.txt

BatMaster wrote:

Code: Select all

:start2
set "Q"="Q + 1"
>>text.txt echo set /p line%Q%=
goto start2
pause



Why did you put the "pause" at the end?

It's a loop "goto start2"