What's new
  • Welcome to PHCorner Forums. Take a moment to Sign up and gain unlimited access and extra privileges that guests are not entitled to, such as: All that and more! Registration is quick, simple and absolutely free. Join our community today!

Help CMD Batch file

Mr. Stark

Eternal Poster
Ito basic lang, walang validation, walang nested if, walang for...
Code:
@echo off
cls
setlocal DisableDelayedExpansion EnableExtensions
set _username=qwerty
set _password=uiop
echo Enter username and password
set /p _usernameinput=Username:
set /p _passwordinput=Password:
if not %_username%==%_usernameinput% exit
if not %_password%==%_passwordinput% exit
cls
echo Loading Resources
timeout /t 5 /nobreak
cls
echo Enter a value
set /p _val1=First value:
set /p _val2=Second value:
set /a _diff=%_val1%-%_val2%
if %_val1% GTR %_val2% goto cond1
if %_val1% LSS %_val2% goto cond2
if %_val1% EQU %_val2% goto cond3
:cond1
set _eureka=
set /a _counter=%_diff%
:cond1loop
set _eureka=%_eureka%Eureka!
set /a _counter=%_counter%-1
if not %_counter%==0 goto cond1loop
echo %_eureka%
goto:eof
:cond2
set /a _abslt=%_diff%*-1
echo ^<%_abslt%
goto:eof
:cond3
echo Insert any joke
goto:eof
Bahala ka na mag-modify ng ibang parts.
 

boszken

Honorary Poster
Ito basic lang, walang validation, walang nested if, walang for...
Code:
@echo off
cls
setlocal DisableDelayedExpansion EnableExtensions
set _username=qwerty
set _password=uiop
echo Enter username and password
set /p _usernameinput=Username:
set /p _passwordinput=Password:
if not %_username%==%_usernameinput% exit
if not %_password%==%_passwordinput% exit
cls
echo Loading Resources
timeout /t 5 /nobreak
cls
echo Enter a value
set /p _val1=First value:
set /p _val2=Second value:
set /a _diff=%_val1%-%_val2%
if %_val1% GTR %_val2% goto cond1
if %_val1% LSS %_val2% goto cond2
if %_val1% EQU %_val2% goto cond3
:cond1
set _eureka=
set /a _counter=%_diff%
:cond1loop
set _eureka=%_eureka%Eureka!
set /a _counter=%_counter%-1
if not %_counter%==0 goto cond1loop
echo %_eureka%
goto:eof
:cond2
set /a _abslt=%_diff%*-1
echo ^<%_abslt%
goto:eof
:cond3
echo Insert any joke
goto:eof
Bahala ka na mag-modify ng ibang parts.
Opo freshman ako sir. Thank you try ko to bukas
 

boszken

Honorary Poster
Ito basic lang, walang validation, walang nested if, walang for...
Code:
@echo off
cls
setlocal DisableDelayedExpansion EnableExtensions
set _username=qwerty
set _password=uiop
echo Enter username and password
set /p _usernameinput=Username:
set /p _passwordinput=Password:
if not %_username%==%_usernameinput% exit
if not %_password%==%_passwordinput% exit
cls
echo Loading Resources
timeout /t 5 /nobreak
cls
echo Enter a value
set /p _val1=First value:
set /p _val2=Second value:
set /a _diff=%_val1%-%_val2%
if %_val1% GTR %_val2% goto cond1
if %_val1% LSS %_val2% goto cond2
if %_val1% EQU %_val2% goto cond3
:cond1
set _eureka=
set /a _counter=%_diff%
:cond1loop
set _eureka=%_eureka%Eureka!
set /a _counter=%_counter%-1
if not %_counter%==0 goto cond1loop
echo %_eureka%
goto:eof
:cond2
set /a _abslt=%_diff%*-1
echo ^<%_abslt%
goto:eof
:cond3
echo Insert any joke
goto:eof
Bahala ka na mag-modify ng ibang parts.
Sir ung timeout may problema (pic). Tyaka pag dun sa condition 2 sumasama ung condition 3 nasasama ung JOKE. Tapos inalis ko ung mga goto:eof kase nag coclose.
 

Attachments

Mr. Stark

Eternal Poster
Sir ung timeout may problema (pic). Tyaka pag dun sa condition 2 sumasama ung condition 3 nasasama ung JOKE. Tapos inalis ko ung mga goto:eof kase nag coclose.
Huwag mo tanggalin yung mga goto:eof, lagyan mo na lang ng pause before goto:eof line. Open ka ng command prompt tapos doon mo i-run. Copy mo na lang yang whole script sa notepad tsaka mo i-save as batch file.
 

boszken

Honorary Poster
Huwag mo tanggalin yung mga goto:eof, lagyan mo na lang ng pause before goto:eof line. Open ka ng command prompt tapos doon mo i-run. Copy mo na lang yang whole script sa notepad tsaka mo i-save as batch file.
Ok na.. Pero ung sa timeout sir hindi man nag cocountdown. Lumalabas is " 'timeout' is not recognized as an internal or external command, operable progran or batch file"
 

Online statistics

Members online
2,158
Guests online
2,101
Total visitors
4,259

Forum statistics

Threads
845,344
Messages
14,976,567
Members
1,365,686
Top