Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch Programs Thread.  (Read 630129 times)

0 Members and 3 Guests are viewing this topic.

Lemonilla



    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: Batch Programs Thread.
« Reply #585 on: March 08, 2014, 08:56:10 AM »
0 = Path the creeps take
. = Possible place to put a turret
T = Turret
# at the end of path = Life

If everything is working as it should, the screen should flash yellow every time a turret fires.  Reducing the number of the creep it hit by 1.  When the creep hits 0 it dies.

Also there is a bug around wave 7 if you stacking your turrets on each other where the creeps go negative hp and heal you when they get to the end.
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: Batch Programs Thread.
« Reply #586 on: March 09, 2014, 12:41:21 AM »
0 = Path the creeps take

Like my childhood bullies, eh? ;)

Quote from:
. = Possible place to put a turret

I put one where there was a creep.  Hopefully it squashed him!

Quote from:
If everything is working as it should, the screen should flash yellow every time a turret fires.

Hmm.  No colour changing here, the creep path had some numbers changing along it, but I couldn't figure out what it all means.

Lemonilla



    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: Batch Programs Thread.
« Reply #587 on: March 09, 2014, 08:28:24 AM »
So one of my friends pointed out some bugs, and I think I fixed them all.
1) Turrets now shoot at the closest target only.
2) You can no longer buy a turret at "a.b".
3) Flash of turret fire is now a little more noticeable.

Code: (def.bat) [Select]
@echo off
setlocal EnableDelayedExpansion
title Turret Defense

echo Installing. . .
if not exist def_bin md def_bin
cd def_bin
if not exist path for %%A in (-2.4\1 -1.4\2 1.4\3 2.4\4 3.4\5 4.4\6 4.3\7 4.2\8 4.1\9 5.1\10 6.1\11 7.1\12 8.1\13 8.2\14 8.3\15 8.4\16 8.5\17 8.6\18 9.6\19 10.6\20 11.6\21 12.6\22 13.6\23 14.6\24 14.5\25 14.4\26 15.4\27 16.4\28 17.4\29 18.4\30 18.3\31 19.3\32 20.3\33 20.4\34 20.5\35 21.5\36 22.5\37 23.5\38 23.4\39 24.4\40 25.4\41 26.4\42) do echo %%A >>path
cls

set color.flash=6
set color.norm=7
set error=
set gold.divis=2
set gold.start=25
set hp.multip=1
set life=9
set live.divisor=5
set range=5
set turret.cost=15
set turn=1
set turn.delay=1
set wave.size=5
set wave.spacing=3
set /a gold.plus=%turret.cost%/2


set "spinner.1=|"
set "spinner.2=|"
set "spinner.3=/"
set "spinner.4=/"
set "spinner.5=-"
set "spinner.6=-"
set "spinner.7=\"
set "spinner.8=\"



call :new_game
:loop
call :turn
:end_turn
call :wave
:end_wave
set /a turn+=1
goto :loop




:new_game
for /f "delims=" %%A in ('dir turret* /b') do del /f %%A
for /l %%Y in (1,1,7) do (
for /l %%X in (1,2,26) do (
set "cord.%%X.%%Y=."
)
for /l %%X in (0,2,26) do (
set "cord.%%X.%%Y= "
)
)
for %%A in (1.4 2.4 3.4 4.4 4.3 4.2 4.1 5.1 6.1 7.1 8.1 8.2 8.3 8.4 8.5 8.6 9.6 10.6 11.6 12.6 13.6 14.6 14.5 14.4 15.4 16.4 17.4 18.4 18.3 19.3 20.3 20.4 20.5 21.5 22.5 23.5 23.4 24.4 25.4 26.4) do set "cord.%%A="
for /l %%P in (1,1,42) do set "path.%%P=0"
echo. > turret0
set gold=%gold.start%
set turret=1
goto :eof

:map
REM pause
title Tower Defense
cls
:load_map
if "%life:~2,1%"=="" (
if not "%life:~1,1%"=="" (
set "life.backSpace="
set "life.backSpace2=."
) else (
set "life.backSpace=."
set "life.backSpace2=."
)
) else (
set "life.backspace2="
set "life.backspace="
)
set "lin.01=  A B C D E F G H I J K L M"
set "lin.02=# . . . . . . . . . . . . . #%turn%"
set "lin.03=###############################"
set "lin.1=# %cord.1.1%%cord.2.1%%cord.3.1%%path.9%%path.10%%path.11%%path.12%%path.13%%cord.9.1%%cord.10.1%%cord.11.1%%cord.12.1%%cord.13.1%%cord.14.1%%cord.15.1%%cord.16.1%%cord.17.1%%cord.18.1%%cord.19.1%%cord.20.1%%cord.21.1%%cord.22.1%%cord.23.1%%cord.24.1%%cord.25.1%%cord.26.1%#..1"
set "lin.2=# %cord.1.2%%cord.2.2%%cord.3.2%%path.8%%cord.5.2%%cord.6.2%%cord.7.2%%path.14%%cord.9.2%%cord.10.2%%cord.11.2%%cord.12.2%%cord.13.2%%cord.14.2%%cord.15.2%%cord.16.2%%cord.17.2%%cord.18.2%%cord.19.2%%cord.20.2%%cord.21.2%%cord.22.2%%cord.23.2%%cord.24.2%%cord.25.2%%cord.26.1%#..2"
set "lin.3=# %cord.1.3%%cord.2.3%%cord.3.3%%path.7%%cord.5.3%%cord.6.3%%cord.7.3%%path.15%%cord.9.3%%cord.10.2%%cord.11.3%%cord.12.2%%cord.13.3%%cord.14.3%%cord.15.3%%cord.16.3%%cord.17.3%%path.31%%path.32%%path.33%%cord.21.3%%cord.22.3%%cord.23.3%%cord.24.3%%cord.25.3%%cord.26.3%#..3"
set "lin.4=%path.1%%path.2%%path.3%%path.4%%path.5%%path.6%%cord.5.4%%cord.6.4%%cord.7.4%%path.16%%cord.9.4%%cord.10.4%%cord.11.4%%cord.12.4%%cord.13.4%%path.26%%path.27%%path.28%%path.29%%path.30%%cord.19.4%%path.34%%cord.21.4%%cord.22.4%%path.39%%path.40%%path.41%%path.42%%life%%life.backSpace%%life.backSpace2%4"
set "lin.5=# %cord.1.5%%cord.2.5%%cord.3.5%%cord.4.5%%cord.5.5%%cord.6.5%%cord.7.5%%path.17%%cord.9.5%%cord.10.5%%cord.11.5%%cord.12.5%%cord.13.5%%path.25%%cord.15.5%%cord.16.5%%cord.17.5%%cord.18.5%%cord.19.5%%path.35%%path.36%%path.37%%path.38%%cord.24.5%%cord.25.5%%cord.26.5%#..5"
set "lin.6=# %cord.1.6%%cord.2.6%%cord.3.6%%cord.4.6%%cord.5.6%%cord.6.6%%cord.7.6%%path.18%%path.19%%path.20%%path.21%%path.22%%path.23%%path.24%%cord.15.6%%cord.16.6%%cord.17.6%%cord.18.6%%cord.19.6%%cord.20.6%%cord.21.6%%cord.22.6%%cord.23.6%%cord.24.6%%cord.25.6%%cord.26.6%#..6"
set "lin.7=# %cord.1.7%%cord.2.7%%cord.3.7%%cord.4.7%%cord.5.7%%cord.6.7%%cord.7.7%%cord.8.7%%cord.9.7%%cord.10.7%%cord.11.7%%cord.12.7%%cord.13.7%%cord.14.7%%cord.15.7%%cord.16.7%%cord.17.7%%cord.18.7%%cord.19.7%%cord.20.7%%cord.21.7%%cord.22.7%%cord.23.7%%cord.24.7%%cord.25.7%%cord.26.7%#..7"
set "lin.8=################################"

:draw_map
echo.
echo.
echo.                      %lin.01%
echo.                      %lin.02%
echo.                      %lin.03%
echo.                      %lin.1%
echo.                      %lin.2%
echo.                      %lin.3%
echo.                      %lin.4%
echo.                      %lin.5%
echo.                      %lin.6%
echo.                      %lin.7%
echo.                      %lin.8%

goto :eof

:turn

call :map
echo Gold: %gold%g
echo.%error%
echo.
echo.  buy ^<X.Y^> %turret.cost%g Buys a turret and installs it to (X,Y).
echo.  sell ^<X.Y^> %gold.plus%g Sells the turret at (X,Y).
echo.  pass Ends the buying/selling phase.
set /p cmd=^>
echo. Processing Command. Please wait. . .
for /f "delims= " %%A in ("%cmd%") do call :%%A
goto :turn

:buy
set /a gold-=%turret.cost%
if %gold% LSS 0 (
set /a gold+=%turret.cost%
) else (
for /f "tokens=2 delims= " %%S in ("%cmd%") do (
for /f "tokens=1,2 delims=." %%A in ("%%S") do (

if /i "%%A"=="a" set A=1
if /i "%%A"=="b" set A=3
if /i "%%A"=="c" set A=5
if /i "%%A"=="d" set A=7
if /i "%%A"=="e" set A=9
if /i "%%A"=="f" set A=11
if /i "%%A"=="g" set A=13
if /i "%%A"=="h" set A=15
if /i "%%A"=="i" set A=17
if /i "%%A"=="j" set A=19
if /i "%%A"=="k" set A=21
if /i "%%A"=="l" set A=23
if /i "%%A"=="m" set A=25

if defined cord.!A!.%%B (
set cord.!A!.%%B=T
) else (
set /a gold+=%turret.cost%
set error=Wrong Syntax
goto :eof
)
if "%%B"=="" (
set /a gold+=%turret.cost%
set error=Wrong Syntax
goto :eof
)
if "!A!"=="" (
set /a gold+=%turret.cost%
set error=Wrong Syntax
goto :eof
)
echo !A!.%%B >turret%turret%
call :Func_TurretRange !A! %%B
set /a turret+=1
)
)
)
set error=
goto :eof

:sell
for /f "tokens=2 delims= " %%S in ("%cmd%") do (
for /f "tokens=1,2 delims=." %%A in ("%%S") do (

if /i "%%A"=="a" set A=1
if /i "%%A"=="b" set A=3
if /i "%%A"=="c" set A=5
if /i "%%A"=="d" set A=7
if /i "%%A"=="e" set A=9
if /i "%%A"=="f" set A=11
if /i "%%A"=="g" set A=13
if /i "%%A"=="h" set A=15
if /i "%%A"=="i" set A=17
if /i "%%A"=="j" set A=19
if /i "%%A"=="k" set A=21
if /i "%%A"=="l" set A=23
if /i "%%A"=="m" set A=25


set sell=0
for /f "delims=" %%G in ('dir turret* /b') do (
set /p loc=<%%G
if "!loc!"=="!A!.%%B " (
del /f %%G
set /a gold+=!gold.plus!
set "cord.!A!.%%B=."
set sell=1
)
)
)
)
if "%sell%"=="0" set error=No Turret Exists There.
goto :eof

:pass
goto :end_turn

:wave
:wave.setup
for /l %%A in (1,1,%wave.size%) do (
set /a creap%%A.hp=%turn%*%hp.multip%
if !creap%%A.hp! GTR 9 (
set creap%%A.sym=+
) else (
set creap%%A.sym=!creap%%A.hp!
)
set /a creap%%A.pos=%%A-%wave.size%
set /a creap%%A.pos*=%wave.spacing%
)


:wave.start
REM Define Creap HP
for /f "tokens=1 delims==" %%A in ('set creap ^| find ".sym"') do (
for /f "tokens=1 delims=." %%B in ("%%A") do (
for /f "tokens=2 delims=p" %%C in ("%%B") do (
if !creap%%C.hp! GTR 9 (
set creap%%C.sym=+
) else (
set creap%%C.sym=!creap%%C.hp!
) 2>nul
) 2>nul
) 2>nul
) 2>nul



REM Move creaps
for /f "tokens=1,2 delims==" %%A in ('set creap ^| find ".pos"') do (
set /a %%A=%%B+1
REM echo set /a %%A=%%B+1
for /f "tokens=2 delims=." %%G in ("%%A") do (
if %%B EQU 42 (
for /f "tokens=1 delims=." %%I in ("%%A") do (
for /f "tokens=2 delims=p" %%H in ("%%I") do (
set /a life-=!creap%%H.hp!
set creap%%H.hp=
set creap%%H.pos=
set creap%%H.sym=
) 2>nul
) 2>nul
) 2>nul
) 2>nul
) 2>nul

REM Kill Creaps
for /l %%A in (1,1,%wave.size%) do (
if !creap%%A.hp! LEQ 0 (
if not "!creap%%A.hp!"=="" (
set creap%%A.hp=
set creap%%A.pos=
set creap%%A.sym=
set /a gold.gain=%turn%/%gold.divis%
if !gold.gain! EQU 0 set gold.gain=1
set /a gold+=%gold.gain%
REM set /a gold+=1
)
) 2>nul
) 2>nul

REM Define new path variables
for /l %%A in (0,1,42) do set path.%%A=0
for /f "tokens=1,2 delims==" %%H in ('set creap ^| find ".pos"') do (
for /f "tokens=1 delims=." %%A in ("%%H") do (
for /f "tokens=2 delims=p" %%B in ("%%A") do (
set path.%%I=!creap%%B.sym!
) 2>nul
) 2>nul
) 2>nul

call :map


REM Fire Turrets
for /f "delims=" %%T in ('dir turret* /b') do (
for /f %%N in ('type "%%T" ^| sort /r') do (
if not "!path%%N!"=="0" (
for /f "tokens=1,2 delims==" %%C in ('set creap ^| find ".pos"') do (
if "%%D"=="%%N" (
for /f "tokens=1 delims=." %%X in ("%%C") do (
for /f "tokens=2 delims=p" %%Z in ("%%X") do (
if "!fired!"=="0" (
set /a creap%%Z.hp-=1
color 0%color.flash%
set flash=1
set fired=1
) 2>nul
) 2>nul
) 2>nul
) 2>nul
if "!flash!"=="1" (
ping localhost -n 1 >nul 2>&1
ping localhost -n 1 >nul 2>&1
ping localhost -n 1 >nul 2>&1
color 0%color.norm%
:: call :map
set flash=0
) 2>nul
) 2>nul
) 2>nul
) 2>nul
set fired=0
) 2>nul


if %life% LEQ 0 goto :endgame


ping localhost -n %turn.delay% >nul


set creap>nul 2>&1 || (
set /a life.gain=%turn%/%live.divisor%
set /a life+=!life.gain!
goto :end_wave
)
goto :wave.start

:endgame
set "life=0"
call :map
echo.
echo You lose on turn %turn%.
pause>nul
exit

:Func_TurretRange
set spinner=1
set startx=%1
set starty=%2
for /l %%A in (0,1,30) do (
for /l %%B in (0,1,10) do (
call :Func_TurretRange.check %%A %%B
)
)
set startx=
set starty=
goto :eof
:Func_TurretRange.check

title Tower Defense !spinner.%spinner%!
set /a spinner+=1
if !spinner! EQU 9 set spinner=1

set /a workingx=%startx%-%1
set /a workingy=%starty%-%2
if %workingx% LSS 0 set workingx=%workingx:~1%
if %workingy% LSS 0 set workingy=%workingy:~1%
set /a working=%workingx%+%workingy%
REM if %working% LSS %range% if %working% GTR 0 echo %1.%2 >>turret%turret%
if %working% LSS %range% if %working% GTR 0 for /f "tokens=1,2 delims=\" %%H in (path) do if /i "%1.%2"=="%%H" echo %%I >>turret%turret%

set working=
set workingx=
set workingy=
goto :eof
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.

Batch_gamer



    Starter

    • Experience: Familiar
    • OS: Windows 7
    Re: Batch Programs Thread.
    « Reply #588 on: June 21, 2014, 09:45:27 PM »
    would anyone be so kind as to help me with my batch game's save and load codes? I developed the multi save function part myself and I think they its pretty spectacular up until the loading part. message me if you have successful save and load codes! :P

    Lemonilla



      Apprentice

    • "Too sweet"
    • Thanked: 70
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    Re: Batch Programs Thread.
    « Reply #589 on: June 22, 2014, 07:42:26 AM »
    would anyone be so kind as to help me with my batch game's save and load codes? I developed the multi save function part myself and I think they its pretty spectacular up until the loading part. message me if you have successful save and load codes! :P
    This thread is for completed batch scripts.  You are suppose to make a new thread for each question.
    Quote from: patio
    God Bless the DOS Helpers...
    Quote
    If it compiles, send the files.

    patio

    • Moderator


    • Genius
    • Maud' Dib
    • Thanked: 1769
      • Yes
    • Experience: Beginner
    • OS: Windows 7
    Re: Batch Programs Thread.
    « Reply #590 on: June 22, 2014, 08:49:12 AM »
    2nd warning for multiple Posts...

    3rd one will be the charm.

    patio.
    " Anyone who goes to a psychiatrist should have his head examined. "

    Lemonilla



      Apprentice

    • "Too sweet"
    • Thanked: 70
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    Re: Batch Programs Thread.
    « Reply #591 on: September 26, 2014, 09:49:21 PM »
    Converts inclusive math notation to exclusive math notation.  Does not support exponents, modulo, or parenthesis within parenthesis.  Follows order of operations.
    Examples of conversions:
    5+9  ->  59+
    6+5/9  ->  59/6+
    (6+5)/9  ->  65+9/
    (4+5)/(1+3)  ->  45+13+/

    Code: [Select]
    @echo off
    setlocal EnableDelayedExpansion
    if not "%~2"=="" setlocal
    set op=%~1
    set a=-1
    set "self=%~pdnx0"
    for /f "tokens=1 delims==" %%A in ('set array 2^>nul') do set "%%A="


    REM set up array1 to contain the characters of %op%
    :a
    set /a a+=1
    set working=!op:~%a%,1!
    if not "%working%"=="" (
    set "array1_%a%=%working%"
    goto :a )
    set op_size=%a%



    REM set up array2 to contain order of operations starting from 1
    REM a value of 0 signifies no operation to run, but a digit to move
    set b=-1
    set count=1
    :b
    set /a b+=1
    if not defined array1_%b% set array2_%b%=

    if "!array1_%b%:~0,1!"=="(" call :open

    if "!array1_%b%:~0,1!"=="/" (
    set array2_%b%=%count%
    set /a count+=1
    )
    if "!array1_%b%:~0,1!"=="*" (
    set array2_%b%=%count%
    set /a count+=1
    )
    if not "%b%"=="%op_size%" goto :b
    set b=-1
    :c
    set /a b+=1
    if "!array1_%b%:~0,1!"=="+" (
    set array2_%b%=%count%
    set /a count+=1
    )
    if "!array1_%b%:~0,1!"=="-" (
    set array2_%b%=%count%
    set /a count+=1
    )
    if not "%b%"=="%op_size%" goto :c
    set b=-1
    :d
    set /a b+=1
    if "!array2_%b%!"=="" set array2_%b%=0
    if not "%b%"=="%op_size%" goto :d
    set a=
    set b=


    REM locate operations before and after first operation
    :locate
    set loc=0
    set a=-1
    set last=-1
    set next=
    :e
    set /a a+=1
    if not "!array2_%a%!"=="0" (
    if not "!array2_%a%!"=="1" (
    if "%loc%"=="0" set last=%a%
    if "%loc%"=="1" (
    set next=%a%
    goto :combine
    )
    )
    )
    if "!array2_%a%!"=="1" set loc=1
    if not "%a%"=="%op_size%" goto :e
    set next=%a%
    goto :combine

    :combine
    set working=
    set /a next=%next%-1
    :f
    set /a last=%last%+1
    if not "!array2_%last%!"=="1" (
    set "working=%working%!array1_%last%!"
    set "array1_%last%="
    ) else (
    set "store=!array1_%last%!"
    set "array1_%last%="
    )
    if not "%last%"=="%next%" goto :f
    set "working=%working%%store%"
    set "array1_%next%=%working%"


    REM Check if done
    set g=0
    for /f "tokens=2 delims==" %%A in ('set array2') do if not "%%A"=="0" set g=1
    set a=0
    set z=
    set b=-1
    set count=1
    set next=
    set last=
    set working=
    set store=
    if "%g%"=="1" goto :b



    REM Echo Output and exit
    set output=
    set a=-1
    :out
    set /a out+=1
    if defined array1_%out% (
    set output=!array1_%out%!
    goto :end
    )
    goto :out
    :end
    echo %output%
    endlocal
    goto :exit





    REM comine equations in paranthisis and convert them
    :open

    set last=%b%
    set o=%b%
    set "array1_%o%="
    :op
    set /a o+=1
    if not "!array1_%o%!"==")" goto :op
    set next=%o%

    set working=
    set /a next=%next%-1
    :f2
    set /a last=%last%+1
    if not "!array1_%last%!"=="+" (
    if not "!array1_%last%!"=="/" (
    if not "!array1_%last%!"=="*" (
    if not "!array1_%last%!"=="-" (
    set "working=%working%!array1_%last%!"
    set "array1_%last%="
    ) else (
    set "store=!array1_%last%!"
    set "array1_%last%="
    )
    ) else (
    set "store=!array1_%last%!"
    set "array1_%last%="
    )
    ) else (
    set "store=!array1_%last%!"
    set "array1_%last%="
    )
    ) else (
    set "store=!array1_%last%!"
    set "array1_%last%="
    )
    if not "%last%"=="%next%" goto :f2
    set "working=%working%%store%"
    set "array1_%next%=%working%"
    set /a next+=1
    set "array1_%next%="

    goto :eof
    :exit
    Quote from: patio
    God Bless the DOS Helpers...
    Quote
    If it compiles, send the files.

    Lemonilla



      Apprentice

    • "Too sweet"
    • Thanked: 70
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    Re: Batch Programs Thread.
    « Reply #592 on: December 29, 2014, 09:50:46 PM »
    Kinda a useless thing, but this is a web crawler that will compile a list of all the quotes on Magic: The Gathering cards.  It has an ungodly long run time, so you'd be better off writing this in another language, but a fun side project.  Requires wget.exe and repl.bat. 
    (Tested with repl version 4 and wget version 1.11.4)
    Code: (flavor.bat) [Select]
    @echo off
    setlocal EnableDelayedExpansion

    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :::
    ::: SCRIPT.........: flavor.bat
    ::: VERSION........: 2.0
    ::: DATE...........: 12/18/2014
    ::: AUTHOR.........: Lemonilla
    ::: REQUIRMENTS....: repl.bat; wget.exe;
    ::: DESCRIPTION....: Downloads the flavor text from
    :::                  Magic: The Gathering cards.
    :::
    :::      flavor [threads]
    :::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

    :: Check to see if arg[1] is defined.
    :: If so, this instance is a thread with ID = arg[2]
    if not "%~2"=="" goto :run

    :: Setup threads and run them.
    :: Split total number of cards by the number of threads
    :: and start a thread for each segment.
    :: If arg[0] is not defined, assign the
    :: number of threads to 250.
    set "threads=%~1"
    if not defined total set total=100000
    if not defined threads set threads=250
    set /a add=%total%/%threads%
    set lower=1
    set upper=%add%
    set t_ID=1
    :thread
    start /b "" "%~0" %lower% %upper% %t_ID%
    set /a lower+=%add%
    set /a upper+=%add%
    set /a t_ID+=1
    if %lower% LSS %total% goto :thread
    set /a t_ID-=1

    :: Wait for all the threads to finish.
    :: This is done by waiting for their ID.d
    :: files to appear.
    :: ALso writing current process number to
    :: the screen.
    :wait
    set wait=0
    cls
    for /f "tokens=1 delims=." %%G in (' dir /b *.tmc ') do echo %%G
    for /l %%A in (1,1,%t_ID%) do (
    if not exist %%A.d set wait=1
    )
    timeout /t 1 /nobreak >nul
    if "%wait%"=="1" goto :wait

    :: Combine all list_ID.t files into list.txt
    for /l %%A in (1,1,%t_ID%) do type list_%t_ID%.t >>list.txt

    :: Remove all temporary files and exit
    del *.tmc
    del *.tm
    del *.t
    del *.d
    exit /b

    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    ::::::::::::::::::::::::: Start Recursion :::::::::::::::::::::::::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

    :: Loop through input values arg[0] through arg[1]
    :: Calling :pull on each number
    :: When finished it will create a file with the name
    :: of arg[2] which will be picked up by main's wait loop
    :run
    set ID=%~3
    for /l %%A in (%~1,1,%~2) do call :pull %%A
    echo. >%ID%.d
    exit


    :pull
    set current=%~1

    :: Set flag for error handling
    :rerun

    :: Download html for parsing to ####.tmc
    :: where #### is the current value of the loop in :run
    :: This requires wget.exe
    wget -O %current%.tmc "http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=%current%" 1>nul 2>&1

    :: Parse out the data we need
    :: This requires repl.bat
    1>name_%ID%.tm 2>nul (
    type %current%.tmc | find "<span id=""ctl00_ctl00_ctl00_MainContent_SubContent_SubContentHeader_subtitleDisplay"">" | repl "<span id=\qctl00_ctl00_ctl00_MainContent_SubContent_SubContentHeader_subtitleDisplay\q>" "" x | repl "</span>" "" | repl "  " ""
    )
    1>flavor_%ID%.tm 2>nul (
    type %current%.tmc | find "<div class=""cardtextbox"" style=""padding-left:10px;""><i>" | repl "<div class=\qcardtextbox\q style=\qpadding-left:10px;\q><i>" "" x | repl "</i></div></div>" "" | repl "  " ""
    )

    set /p check_n=<name_%ID%.tm
    set /p check_f=<flavor_%ID%.tm

    :: Check to see if any values were gathered
    :: and write to the list file if they were both found
    if defined check_f (
    if defined check_n (
    1>>list_%ID%.t (
    echo.[%current%]
    echo.%check_n%
    type flavor_%ID%.tm
    echo.
    )
    ) else (
    goto :rerun
    )
    )

    :: Cleanup
    set "check_n="
    set "check_f="
    del %current%.tmc
    del name_%ID%.tm
    del flavor_%ID%.tm

    goto :eof

    Be warned, when you exit the window, background processes will freeze.  Run these commands to total shut down the program:
    taskkill /f /im "cmd.exe"
    taskkill /f /im "cscript.exe"
    taskkill /f /im "find.exe"
    taskkill /f /im "cmd.exe"
    Quote from: patio
    God Bless the DOS Helpers...
    Quote
    If it compiles, send the files.

    1998golfer



      Greenhorn

      • Yes
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 7
    Re: Batch Programs Thread.
    « Reply #593 on: December 29, 2014, 10:02:08 PM »
    Kinda a useless thing, but this is a web crawler that will compile a list of all the quotes on Magic: The Gathering cards.  It has an ungodly long run time, so you'd be better off writing this in another language, but a fun side project.  Requires wget.exe and repl.bat. 
    (Tested with repl version 4 and wget version 1.11.4)
    Code: (flavor.bat) [Select]
    @echo off
    setlocal EnableDelayedExpansion

    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :::
    ::: SCRIPT.........: flavor.bat
    ::: VERSION........: 2.0
    ::: DATE...........: 12/18/2014
    ::: AUTHOR.........: Lemonilla
    ::: REQUIRMENTS....: repl.bat; wget.exe;
    ::: DESCRIPTION....: Downloads the flavor text from
    :::                  Magic: The Gathering cards.
    :::
    :::      flavor [threads]
    :::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

    :: Check to see if arg[1] is defined.
    :: If so, this instance is a thread with ID = arg[2]
    if not "%~2"=="" goto :run

    :: Setup threads and run them.
    :: Split total number of cards by the number of threads
    :: and start a thread for each segment.
    :: If arg[0] is not defined, assign the
    :: number of threads to 250.
    set "threads=%~1"
    if not defined total set total=100000
    if not defined threads set threads=250
    set /a add=%total%/%threads%
    set lower=1
    set upper=%add%
    set t_ID=1
    :thread
    start /b "" "%~0" %lower% %upper% %t_ID%
    set /a lower+=%add%
    set /a upper+=%add%
    set /a t_ID+=1
    if %lower% LSS %total% goto :thread
    set /a t_ID-=1

    :: Wait for all the threads to finish.
    :: This is done by waiting for their ID.d
    :: files to appear.
    :: ALso writing current process number to
    :: the screen.
    :wait
    set wait=0
    cls
    for /f "tokens=1 delims=." %%G in (' dir /b *.tmc ') do echo %%G
    for /l %%A in (1,1,%t_ID%) do (
    if not exist %%A.d set wait=1
    )
    timeout /t 1 /nobreak >nul
    if "%wait%"=="1" goto :wait

    :: Combine all list_ID.t files into list.txt
    for /l %%A in (1,1,%t_ID%) do type list_%t_ID%.t >>list.txt

    :: Remove all temporary files and exit
    del *.tmc
    del *.tm
    del *.t
    del *.d
    exit /b

    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    ::::::::::::::::::::::::: Start Recursion :::::::::::::::::::::::::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

    :: Loop through input values arg[0] through arg[1]
    :: Calling :pull on each number
    :: When finished it will create a file with the name
    :: of arg[2] which will be picked up by main's wait loop
    :run
    set ID=%~3
    for /l %%A in (%~1,1,%~2) do call :pull %%A
    echo. >%ID%.d
    exit


    :pull
    set current=%~1

    :: Set flag for error handling
    :rerun

    :: Download html for parsing to ####.tmc
    :: where #### is the current value of the loop in :run
    :: This requires wget.exe
    wget -O %current%.tmc "http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=%current%" 1>nul 2>&1

    :: Parse out the data we need
    :: This requires repl.bat
    1>name_%ID%.tm 2>nul (
    type %current%.tmc | find "<span id=""ctl00_ctl00_ctl00_MainContent_SubContent_SubContentHeader_subtitleDisplay"">" | repl "<span id=\qctl00_ctl00_ctl00_MainContent_SubContent_SubContentHeader_subtitleDisplay\q>" "" x | repl "</span>" "" | repl "  " ""
    )
    1>flavor_%ID%.tm 2>nul (
    type %current%.tmc | find "<div class=""cardtextbox"" style=""padding-left:10px;""><i>" | repl "<div class=\qcardtextbox\q style=\qpadding-left:10px;\q><i>" "" x | repl "</i></div></div>" "" | repl "  " ""
    )

    set /p check_n=<name_%ID%.tm
    set /p check_f=<flavor_%ID%.tm

    :: Check to see if any values were gathered
    :: and write to the list file if they were both found
    if defined check_f (
    if defined check_n (
    1>>list_%ID%.t (
    echo.[%current%]
    echo.%check_n%
    type flavor_%ID%.tm
    echo.
    )
    ) else (
    goto :rerun
    )
    )

    :: Cleanup
    set "check_n="
    set "check_f="
    del %current%.tmc
    del name_%ID%.tm
    del flavor_%ID%.tm

    goto :eof

    Be warned, when you exit the window, background processes will freeze.  Run these commands to total shut down the program:
    taskkill /f /im "cmd.exe"
    taskkill /f /im "cscript.exe"
    taskkill /f /im "find.exe"
    taskkill /f /im "cmd.exe"
    Where would I find repl.bat?

    foxidrive



      Specialist
    • Thanked: 268
    • Experience: Experienced
    • OS: Windows 8
    Re: Batch Programs Thread.
    « Reply #594 on: December 29, 2014, 11:39:49 PM »
    Where would I find repl.bat?

    A helper batch file called `repl.bat` (by dbenham) - download from:  https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat

    Place `repl.bat` in the same folder as the batch file or in a folder that is on the path.

    millergram



      Rookie

      • Experience: Beginner
      • OS: Windows Vista
      Re: Batch Programs Thread.
      « Reply #595 on: January 06, 2015, 12:26:14 PM »
      Code: [Select]
      MODE CON: COLS=40 LINES=12
      @echo off
      echo.This is A random Number guessing game.
      :main1
      set /p TY=How Many Tries Do You Want?:
      set /p TT=How Many Numbers Do You Want?:
      set tries=%TY%
      set /a guess=%random% %%TT + 1 >nul
      :main
      if %tries%==0 goto loss
      cls
      Echo.This is 1-%TT% guess a number if you get it right then you win
      echo.%username% has %tries% tries left
      echo.Your guess below
      set /p user=
      set /a tries=%tries%-1
      if "%user%"=="%guess%" goto win
      if "%user%"=="" goto main
      if "%user%" LSS "%guess%" echo To low &pause
      if "%user%" GTR "%guess%" echo To high &pause
      goto main
      :win
      cls
      echo.you win! play again?(yes/no)
      set /p yinput=
      if "%yinput%"=="yes" goto main1
      if "%yinput%"=="no" exit
      if "%yinput%"=="" goto win
      :loss
      cls
      echo.sorry you loose
      echo.The number was %guess%
      pause
      goto main1
      This is an improved version of the random number gussing game

      millergram



        Rookie

        • Experience: Beginner
        • OS: Windows Vista
        Re: Batch Programs Thread.
        « Reply #596 on: January 23, 2015, 01:33:59 PM »
        This is a fixed version of the above quoted program.
        Code: [Select]
        MODE CON: COLS=41 LINES=12
        @echo off
        echo.This is A random Number guessing game.
        :main1
        cls
        set /p TY=How Many Tries Do You Want?:
        Echo No Higher Than 32766
        set /p TT=How Many Numbers Do You Want?:
        set tries=%TY%
        set guess=
        set /a guess=%random% %%TT + 1 >nul
        :main
        cls
        if %tries%==0 goto loss
        Echo.This is 1-%TT% guess a number if you get itright then you win
        echo.%username% has %tries% tries left
        echo.Your guess below
        set /p user=
        if "%user%"=="%guess%" goto win
        if "%user%"=="" goto main
        if "%user%"=="debug" goto debug
        set /a tries=%tries%-1
        if "%user%" LSS "%guess%" goto low
        if "%user%" GTR "%guess%" goto high
        goto main
        :win
        cls
        echo.you win! play again?(yes/no)
        set /p yinput=
        if "%yinput%"=="yes" goto main1
        if "%yinput%"=="no" exit
        if "%yinput%"=="" goto win
        :loss
        cls
        echo.sorry you loose
        echo.The number was %guess%
        pause
        goto main1
        :debug
        cls
        Echo.Printing Variables to
        Echo."var.txt"
        Echo.With in current DIR
        echo Date:%DATE%>>var.txt
        echo Guess:%guess%>>Var.txt
        echo TY:%TY%>>Var.txt
        echo TT:%TT%>>Var.txt
        echo Tries:%tries%>>Var.txt
        echo yinput:%yinput%>>Var.txt
        echo Username:%username%>>Var.txt
        echo LastGuessed:%user%>>var.txt
        pause
        goto main
        :low
        echo To low & pause
        goto main
        :high
        echo To high & pause
        goto main

        patio

        • Moderator


        • Genius
        • Maud' Dib
        • Thanked: 1769
          • Yes
        • Experience: Beginner
        • OS: Windows 7
        Re: Batch Programs Thread.
        « Reply #597 on: January 23, 2015, 05:29:16 PM »
        I don't get it...
        " Anyone who goes to a psychiatrist should have his head examined. "

        Deemajeir



          Newbie

          • Experience: Experienced
          • OS: Windows 7
          Game with bad humor
          « Reply #598 on: January 30, 2015, 12:38:21 PM »
          So I did this as a little exercise.
          It was nighttime and I was tired and Skyping with a friend.
          So, you can imagine how it turned out.
          Anyway, it's a little batch multiple-choice adventure game

          I'd love feedback!
          I know the language and details aren't the best(Done at 1am...) but if you have any ideas about the technical part, I'd love to hear it!

          Code:

          @echo off
          title Godzilla burgers
          color A0

          :start
          cls

          echo This is the moment you have been waiting for the whole day. It's 7pm and you are stainding in the line of Godzilla burgers, your local street grill(or "snagari" as your Finnish friends say).
          echo There are three people in front of you. It's quite chilly and you could use a
          echo nice fight to stay warm. You decide to...
          echo A Wait in the line like a good guy
          echo B Pay the guys in front of you to start boxing a little(You definetly don't have the cash but hopefully you can outrun or outsmart them)
          echo C Start bitching the guy in front of you and fight him.
          echo D *censored* this. Just go home.
          set/p "choice=>"
          if %choice%==A goto wait
          if %choice%==B goto dogfight
          if %choice%==C goto battle
          if %choice%==D goto home


          :wait
          cls
          echo You stand in the line and check your phone a couple of times. You almost die of boredom, but it's finally your turn.
          ping localhost -n 5 >nul
          goto order


          :dogfight
          cls
          echo You speak to the two guys in front of you. "Hey guys. Wan't to warm up a bit? You two, mano O mano. Winner gets 20 bucks."
          echo The guys are both rough-bodied construction workers, apparently coworkers. They look at each other and get to boxing stances.
          echo They start hitting each other and continue until the slightly smaller one falls down. You cheer.
          echo.
          ping localhost -n 5 >nul
          echo "Twenty bucks, if you would" The winner says grinning.
          echo You only have money for your hot dog, so you can't pay. You decide to...
          echo 1 Outsmart him
          echo 2 Outrun him
          echo 3 Give him your food money and go home.
          set/p "num=>"
          if %num%==1 goto outsmart
          if %num%==2 goto outrun
          if %num%==3 goto home

          :outsmart
          cls
          echo You smile saying:"If you get the riddle right."
          echo "When the sun goes down, I go up. What am I?"
          echo "The moon" the worker says and puts his hand forth.
          echo You laugh and say:"A *censored*!"
          echo The worker is not amused. He steps toward you.
          ping localhost -n 12 >nul
          goto outrun

          :outrun
          cls
          echo You smile and reach for your pocket.
          echo In a blink of an eye you turn around and start running!
          echo The workers run after you, but you manage to lose them.
          echo.
          echo You realize you can't go back to Godzilla's, so you have to go home.
          pause
          goto home

          REM Tappelut alkaa

          :battle
          cls
          echo You knock on the shoulder of the bald guy in front of you. He turns around.
          echo "Hey" You say."Did you notice you dropped your hair somewhere?"
          echo "And your hair seems to grow from your nose" He answers.
          echo "Let's settle this like gentlemen", you say and raise your fists.
          ping localhost -n 7 >nul

          color 50
          cls
          echo The world around you seems to grow to the size of an arena when you get ready to battle.
          echo You are standing in front of the big man. He is waits for you to make your move.
          echo People are gathering around you and you must decide.
          echo.
          echo attack
          echo Skills: jumpkick, taunt, batbeatdown
          echo Magic: fireball, waterpower

          set/p "fight=>"
          if %fight%==attack goto attack
          if %fight%==jumpkick goto jumpkick
          if %fight%==taunt goto taunt
          if %fight%==batbeatdown goto batbeatdown
          if %fight%==fireball goto fireball
          if %fight%==waterpower goto waterpower

          :attack
          cls
          echo You take all your strenght to this blow nad punch him in the stomach.
          echo He doesen't even blink. Instead, he grabs you and crushes the air from your lungs.
          echo You Try to signal him your surrender, but he breaks your bones.
          echo Ambulance is soon called and you are taken to a hospital.
          echo When you are fixed, it's already too late. Your brains can't work without
          echo Godzilla burgers.
          echo You spend a couple of days in intersive treatment and after that you are sent to a mental hospital.
          echo You have been diagnosed with the brain functions of a vegetable.
          echo You end your days in the hospital.
          ping localhost -n 5 >nul
          echo GAME OVER
          pause
          goto start

          :jumpkick
          cls
          echo You jump to the air and kick him in the face.
          echo ...Well that's what you planned.
          echo He quickly steps back and grabs you when you hit the ground.
          echo The worker does not hesitate.He crushes the air from your lungs.
          echo You Try to signal him your surrender, but he breaks your bones.
          echo Ambulance is soon called and you are taken to a hospital.
          echo When you are fixed, it's already too late. Your brains can't work without
          echo Godzilla burgers.
          echo You spend a couple of days in intersive treatment and after that you are sent to a mental hospital.
          echo You have been diagnosed with the brain functions of a vegetable.
          echo You end your days in the hospital.
          ping localhost -n 5 >nul
          echo GAME OVER
          pause
          goto start

          :taunt
          cls
          echo You decide to anger him first.
          echo "Yo momma's a *censored*!" you shout.
          echo He roars and speeds towards you.
          echo You dodge and try to trip him, but he's too fast.
          echo Your leg breaks and you fall.
          echo He gets the upper hand and steals all your money.
          echo The worker smiles and goes to buy a burger.
          echo You can barely see the gigantic lizard that is approaching the food stand,
          echo but you don't have the power to do anything.
          echo You die out of blood loss.
          pause
          goto start

          :batbeatdown
          cls
          echo "Okay guys", you say loudly
          echo "It's time for a beatdown- A BATBEATDOWN!"
          echo A group of your friends jump from the shadows,
          echo all dressed like bats. They attack the worker
          echo while you pull out your trusty baseball bat.
          echo "HOME RUN!" You shout and hit your opponent in the head.
          pause
          echo He collapses to the ground and you go claim your prize:
          echo A Godzilla Burgers Hot *censored* Dog!
          ping localhost -n 10 >nul
          goto :order

          :fireball
          cls
          echo You smile and raise your hands.
          echo Everyone feels the warmth when fire starts to grow.
          echo You hit your hands together.
          pause
          echo Fire bursts out of your hands and your enemy dodges in terror.
          echo Fire hits Godzilla Burgers stand and it burns to ground!
          echo You shout in terror and collapse.
          echo You can barely see the gigantic lizard that is approaching the burning food stand,
          echo but you don't have the power to do anything.
          echo The lizard cries out of anger because it can't get a burger.
          echo He destroys the world, but you know this is all your fault.
          echo You collapse and when you wake up...
          ping localhost -n 10 >nul
          echo There's nothing left.
          ping localhost -n 3 >nul
          echo you lose!
          pause
          goto start

          :waterpower
          cls
          echo You open your mouth and gallons of water burst out.
          echo Your opponent stands in front of you.
          echo He is soaking wet, but no harm is done.
          echo He roars and speeds towards you.
          echo You dodge and try to trip him, but he's too fast.
          echo Your leg breaks and you fall.
          echo He gets the upper hand and steals all your money.
          echo The worker smiles and goes to buy a burger.
          echo You can barely see the gigantic lizard that is approaching the food stand,
          echo but you don't have the power to do anything.
          echo You die out of blood loss.
          pause
          goto start

          REM Tappelut loppuu


          :home
          cls
          echo You sigh and walk home.
          echo You spend the evening by sitting on your couch and thinking about the epic hot dogs of Godzilla burgers.
          echo.
          echo After four days you friends find you in your apartment, almost dead of hunger and thirst. You are still sitting on the couch, lost in your own world. Your friends can't wake you up, so they call the paramedics.
          echo You spend a couple of days in intersive treatment and after that you are sent to a mental hospital.
          echo You have been diagnosed with the brain functions of a vegetable.
          echo You end your days in the hospital.
          ping localhost -n 5 >nul
          echo GAME OVER
          pause
          goto :start


          :order
          cls
          echo You stand in front of Mike, the owner of Godzilla's.
          echo He smiles and asks:
          echo "Godzilla burgers Hot *censored* Dog, right?"
          echo "*censored* right" You say and hand him the money.
          echo "Coming with a large coke" Mike adds and gets to work.
          pause
          echo You soon get your hot dog and smile.
          echo Just when you're about to eat it you hear a loud roar.
          echo Mike is looking behind you, he's mouth hanging open.
          echo You turn around and see what you thought only exists in stories.
          ping localhost -n 8 >nul
          echo A gigantic lizard stands in front of you.
          echo.
          echo.
          echo.
          echo "Godzilla" Mike says in amazement behind you. His mouth hangs open.
          ping localhost -n 3 >nul
          echo Godzilla looks at Mike and puts his lizardous "hand" forward.
          echo "BURRRRRGGGEEEEERRRRRRRR" It groans
          echo Mike stares in terror without moving.
          echo "BURRRRGEEEEEEEEEEEEEEERRRRRRRRR!" Godzilla cries, sounding a lot angryer.
          echo Clearly Mike does not realize what's going on.You have to do something!
          echo D Make Mike realize he must make a burger
          echo E Attack Godzilla
          echo F *censored* this. Eat your hot dog!
          REM  ^ ^ Coincidence?I THINK NOT!
          set/p "savetheday=>"
          if %savetheday%==D goto Happygodzillaending
          if %savetheday%==E goto SadGodzillaending
          if %savetheday%==F goto Moralofthestory

          :Happygodzillaending
          cls
          echo You punch Mike in the elbow and shout:
          echo "Mike!Snap out of it!Make a burger!"
          echo Mike blinks a couple of times and then gets to work.
          echo Godzilla waits patiently while Mike is cooking.
          echo You notice people around you staring in amazement,
          echo but Godzilla doesen't seem to care.
          pause
          echo Mike gets the burger done and gives it to Godzilla
          echo with his trembling hands.
          ping localhost -n 5 >nul
          echo Godzillas expression changes.
          echo Is it...It's smiling!
          echo Godzilla takes the gigantic burger that
          echo looks tiny in it's hand.
          ping localhost -n 5 >nul
          echo Godzilla throws the burger in it's mouth and seems
          echo to really enjoy it.
          echo Godzilla bows a little and walks away.
          echo It disappears in the smog.
          ping localhost -n 10 >nul
          goto theend

          :SadGodzillaending
          cls
          echo You pull out your knife and strike it to
          echo Godzilla's huge toe.
          echo.
          echo.
          echo Godzilla looks down and you see tears
          echo coming from his eyes.
          echo It's hard to believe, but...He's crying!
          echo Godzilla runs to the smog and disappears.
          echo He takes your knife with you, but
          echo you don't even care.
          ping localhost -n 5 >nul
          echo People gather around and cheer your name.
          echo Still, you can't celebrate with them.
          echo You are the only one who realizes...
          echo He was like a human...
          echo And all this could have been avoided,
          echo just if you wouldn't have judged
          echo him by his looks.
          echo He was just trying to get a burger.
          echo Just like you.
          pause
          goto theend


          :Moralofthestory
          cls
          echo You just lean to the food stand
          echo and bite your hot dog.
          echo Mike still stares at Godzilla.
          echo Godzilla gets angry. It roars and
          echo kicks Mike's stand which flies away.
          echo Godzilla runs over you and disappears to
          echo the mist.
          pause
          echo Moral of the story:
          echo Don't be a *censored*.
          echo People will run over you.
          ping localhost -n 5 >nul
          color A0
          cls
          echo Thanks for playing!
          echo Would you like to restart?
          set/p "restart=>"
          if %restart%==Yes goto start
          if %restart%==yes goto start
          if %restart%==No goto exit
          if %restart%==no goto exit

          :theend
          color A0
          cls
          echo Congratulations!
          echo You survived alive and that's
          echo quite cool!
          echo Remember, there are still endings to find,
          echo so would you like to restart?
          set/p "restart=>"
          if %restart%==Yes goto start
          if %restart%==yes goto start
          if %restart%==No goto exit
          if %restart%==no goto exit


          :exit
          exit

          Squashman



            Specialist
          • Thanked: 134
          • Experience: Experienced
          • OS: Other
          Re: Batch Programs Thread.
          « Reply #599 on: January 30, 2015, 01:10:48 PM »
          Please use BB CODE tags when posting code.

          You are not validating any input from the user.  What happens when someone inputs an invalid option to any of your choices.
          You also don't need to check for multiple casing of input.  Read the help for the IF command.