Компьютерный форум OSzone.net  

Компьютерный форум OSzone.net (http://forum.oszone.net/index.php)
-   Скриптовые языки администрирования Windows (http://forum.oszone.net/forumdisplay.php?f=102)
-   -   Сравнение чисел в bat (http://forum.oszone.net/showthread.php?t=250906)

binwatch@vk 08-01-2013 13:35 2061732

Сравнение чисел в bat
 
Нужно сделать bat файл чтобы если число с файле st.cfg будет 3 то будет переадресация на завершение bat .А если не равно 3 ,то будет производиться дальнейшая накрутка в файле st.cfg.
Вот примерно накидал,но не работает. :
Код:

:loop
 if not exist st.cfg goto send
set /P ment= < st.cfg
set /P ent= 3
 if %ment% == %ent% echo goto by
 :send setlocal
if not exist st.cfg 1>st.cfg echo 0
0<st.cfg set /p "st="
set /a st+=1
 1>st.cfg echo %st%
:: type st.cfg
goto loop
:by
exit

В чем ошибка?

zion87 08-01-2013 14:03 2061755

Код:

if /i %ment% EQL %ent% exit

binwatch@vk 08-01-2013 18:12 2061927

не работает!

Foreigner 08-01-2013 20:09 2062008

Код:

@echo off
setlocal

set "num=0"
set "max=3"

if not exist st.cfg 1>st.cfg echo %num%

:loop

0<st.cfg set /p "num="

if %num% geq %max% goto:eof
set /a num+=1
1>st.cfg echo %num%
type st.cfg
goto:loop


binwatch@vk 08-01-2013 21:23 2062048

Цитата:

Цитата Foreigner
@echo off
setlocal
set "num=0"
set "max=3"
if not exist st.cfg 1>st.cfg echo %num%
:loop
0<st.cfg set /p "num="
if %num% geq %max% goto:eof
set /a num+=1
1>st.cfg echo %num%
type st.cfg
goto:loop »

Спасибо большое! Все работает)


Время: 21:11.

Время: 21:11.
© OSzone.net 2001-