bat - ECHO is off in the txt files
:obje7
set gn=%random%
if /i %gn% l开发者_C百科ss 1 goto obje%go%
if /i %gn% gtr 5 goto obje%go%
set goal%gn%="test"
echo hi > goal%go%.txt
echo hi > g2.txt
goto go
that sets test in goal%random_number%, right?
(
echo %goal1%
echo %goal2%
echo %goal3%
echo %goal4%
echo %goal5%
) >> mcbingo.txt
and the result i get is:
ECHO is off.
test
ECHO is off.
test
test
and all the :objeX are the same code, but changed X and the g2.txt is g1.txt for example.
anyone have any idea whats wrong?
Some of your goal
variables remain uninitialised. When you are outputting them, the uninitialised variables evaluate to empty strings, and the corresponding echo
commands simply look like this:
echo
Without parameters, echo
displays the status of echoing batch commands to the console (when ON
, they are displayed, when OFF
, which is more typical in batches, they aren't).
To avoid this behaviour and display empty strings instead, add delimiters between echo
s and %goal…%
s. There's a number of delimiters you can use in that position, but, as follows from this answer, (
seems most appropriate:
(
echo(%goal1%
echo(%goal2%
echo(%goal3%
echo(%goal4%
echo(%goal5%
) >> mcbingo.txt
精彩评论