i'm programmer in batch , i've joined site ask 1 question...
i made program writes random numbers 1 10 , encodes/writes them file... problem is, batch file must read numbers , check if it's below 5.
the batch file generates random numbers not inputting random number file; instead, file says
echo off
which confuses other batch file, , therefore crashes.
here's code of both batch files;
the "writer" of numbers
@echo off >nul title batch arithmetic communicator :check timeout /t 1 >nul /nobreak echo %t% >>wait.rsm set /a t=%random% * 10 / 32768 + 1 goto cont :cont timeout /t 1 >nul if exist pack.rsm goto cont2 if not exist pack.rsm goto cont :cont2 set /p data=<pack.rsm del pack.rsm if %data% lss 5 goto move if %data% gtr 5 goto check receiver of numbers @echo off :a timeout /t 1 >nul if exist wait.rsm goto b if not exist wait.rsm goto :b set /p d=<wait.rsm if %d% gtr 5 goto if %d% lss 5 goto w :w echo 3>>pack.rsm goto
help?
your writer echoing %t% before it's setting it:
echo %t% >>wait.rsm set /a t=%random% * 10 / 32768 + 1
at time of first statement, %t%
set nothing it's if said:
echo >>wait.rsm
which why you're getting echo off
, see "naked" echo command.
basically, need set %t
before trying echo swap 2 statements around:
set /a t=%random% * 10 / 32768 + 1 echo %t% >>wait.rsm
Comments
Post a Comment